From 607f8163d3da22c1587d207a76146a06a8376abb Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sun, 10 Jul 2022 18:54:58 +0800 Subject: [PATCH 01/65] feat:add logic for get_tmq_meta_json --- include/client/taos.h | 4 +- include/common/tdataformat.h | 3 +- include/common/tmsg.h | 6 + include/libs/parser/parser.h | 6 +- source/client/src/clientSml.c | 2 +- source/client/src/clientStmt.c | 11 +- source/client/src/tmq.c | 233 ++++++++++++++---- source/common/src/tmsg.c | 16 ++ source/dnode/mnode/impl/src/mndStb.c | 12 +- source/libs/parser/src/parInsert.c | 38 +-- source/libs/parser/src/parTranslater.c | 18 +- source/libs/parser/src/parUtil.c | 3 +- source/libs/scalar/src/sclfunc.c | 2 +- .../libs/scalar/test/scalar/scalarTests.cpp | 4 +- 14 files changed, 261 insertions(+), 97 deletions(-) diff --git a/include/client/taos.h b/include/client/taos.h index 362782b420..690c473986 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -265,7 +265,9 @@ typedef struct tmq_raw_data tmq_raw_data; DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); DLL_EXPORT tmq_raw_data *tmq_get_raw_meta(TAOS_RES *res); DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta); -DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed. +DLL_EXPORT void tmq_free_raw_meta(tmq_raw_data *rawMeta); +DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta +DLL_EXPORT void tmq_free_json_meta(char* jsonMeta); DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index e70008e4ef..95ab12b94e 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -78,7 +78,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf); +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf, const char* colName); // STRUCT ================= struct STColumn { @@ -147,6 +147,7 @@ struct SColVal { #pragma pack(push, 1) struct STagVal { + char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta union { int16_t cid; char *pKey; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 896ea27598..6140d30771 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1915,6 +1915,8 @@ typedef struct SVCreateStbReq { SSchemaWrapper schemaRow; SSchemaWrapper schemaTag; SRSmaParam rsmaParam; + int32_t alterOriDataLen; + void* alterOriData; } SVCreateStbReq; int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq); @@ -1942,6 +1944,7 @@ typedef struct SVCreateTbReq { int8_t type; union { struct { + char* name; tb_uid_t suid; uint8_t* pTag; } ctb; @@ -1959,6 +1962,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) { taosMemoryFreeClear(req->comment); if (req->type == TSDB_CHILD_TABLE) { taosMemoryFreeClear(req->ctb.pTag); + taosMemoryFreeClear(req->ctb.name); } else if (req->type == TSDB_NORMAL_TABLE) { taosMemoryFreeClear(req->ntb.schemaRow.pSchema); } @@ -2042,12 +2046,14 @@ typedef struct { int32_t bytes; // TSDB_ALTER_TABLE_DROP_COLUMN // TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES + int8_t colModType; int32_t colModBytes; // TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME char* colNewName; // TSDB_ALTER_TABLE_UPDATE_TAG_VAL char* tagName; int8_t isNull; + int8_t tagType; uint32_t nTagVal; uint8_t* pTagVal; // TSDB_ALTER_TABLE_UPDATE_OPTIONS diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index a4aec72d4f..a3de9164a2 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -29,7 +29,7 @@ struct SMetaData; typedef struct SStmtCallback { TAOS_STMT* pStmt; int32_t (*getTbNameFn)(TAOS_STMT*, char**); - int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, char*, bool, SHashObj*, SHashObj*); + int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, char*, bool, SHashObj*, SHashObj*, const char*); int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**); } SStmtCallback; @@ -84,7 +84,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu int32_t rowNum); int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields); int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields); -int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tName, TAOS_MULTI_BIND* bind, +int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen); void destroyBoundColumnInfo(void* pBoundInfo); int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf, @@ -93,7 +93,7 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* void* smlInitHandle(SQuery* pQuery); void smlDestroyHandle(void* pHandle); int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta, - char* tableName, char* msgBuf, int16_t msgBufLen); + char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen); int32_t smlBuildOutput(void* handle, SHashObj* pVgHash); int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index b6972e4670..df62f25168 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2256,7 +2256,7 @@ static int32_t smlInsertData(SSmlHandle *info) { (*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat, - (*pMeta)->tableMeta, tableData->childTableName, info->msgBuf.buf, info->msgBuf.len); + (*pMeta)->tableMeta, tableData->childTableName, tableData->sTableName, tableData->sTableNameLen, info->msgBuf.buf, info->msgBuf.len); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%" PRIx64 " smlBindData failed", info->id); return code; diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 1e0f30695d..7287c46796 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -128,7 +128,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) { return TSDB_CODE_SUCCESS; } -int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName) { +int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, const char* sTableName) { STscStmt* pStmt = (STscStmt*)stmt; strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1); @@ -139,6 +139,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, pStmt->bInfo.tbType = pTableMeta->tableType; pStmt->bInfo.boundTags = tags; pStmt->bInfo.tagsCached = false; + strcpy(pStmt->bInfo.stbFName, sTableName); return TSDB_CODE_SUCCESS; } @@ -154,10 +155,10 @@ int32_t stmtUpdateExecInfo(TAOS_STMT* stmt, SHashObj* pVgHash, SHashObj* pBlockH } int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, bool autoCreateTbl, - SHashObj* pVgHash, SHashObj* pBlockHash) { + SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName) { STscStmt* pStmt = (STscStmt*)stmt; - STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName)); + STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName, sTableName)); STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash, autoCreateTbl)); pStmt->sql.autoCreateTbl = autoCreateTbl; @@ -247,7 +248,7 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) { destroyBoundColumnInfo(pStmt->bInfo.boundTags); taosMemoryFreeClear(pStmt->bInfo.boundTags); } - + memset(pStmt->bInfo.stbFName, 0, TSDB_TABLE_FNAME_LEN); return TSDB_CODE_SUCCESS; } @@ -568,7 +569,7 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) { STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.sname.tname, + STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName, pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen)); return TSDB_CODE_SUCCESS; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 907691698c..fa9f715be3 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -1867,10 +1867,10 @@ static char *buildCreateTableJson(SSchemaWrapper *schemaRow, SSchemaWrapper* sch cJSON* type = cJSON_CreateString("create"); cJSON_AddItemToObject(json, "type", type); - char uid[32] = {0}; - sprintf(uid, "%"PRIi64, id); - cJSON* id_ = cJSON_CreateString(uid); - cJSON_AddItemToObject(json, "id", id_); +// char uid[32] = {0}; +// sprintf(uid, "%"PRIi64, id); +// cJSON* id_ = cJSON_CreateString(uid); +// cJSON_AddItemToObject(json, "id", id_); cJSON* tableName = cJSON_CreateString(name); cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString(t == TSDB_NORMAL_TABLE ? "normal" : "super"); @@ -1925,6 +1925,98 @@ static char *buildCreateTableJson(SSchemaWrapper *schemaRow, SSchemaWrapper* sch return string; } +static char *buildAlterSTableJson(void* alterData, int32_t alterDataLen){ + SMAlterStbReq req = {0}; + cJSON* json = NULL; + char* string = NULL; + + if (tDeserializeSMAlterStbReq(alterData, alterDataLen, &req) != 0) { + goto end; + } + + json = cJSON_CreateObject(); + if (json == NULL) { + goto end; + } + cJSON* type = cJSON_CreateString("alter"); + cJSON_AddItemToObject(json, "type", type); +// cJSON* uid = cJSON_CreateNumber(id); +// cJSON_AddItemToObject(json, "uid", uid); + SName name = {0}; + tNameFromString(&name, req.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + cJSON* tableName = cJSON_CreateString(name.tname); + cJSON_AddItemToObject(json, "tableName", tableName); + cJSON* tableType = cJSON_CreateString("super"); + cJSON_AddItemToObject(json, "tableType", tableType); + + cJSON* alterType = cJSON_CreateNumber(req.alterType); + cJSON_AddItemToObject(json, "alterType", alterType); + switch (req.alterType) { + case TSDB_ALTER_TABLE_ADD_TAG: + case TSDB_ALTER_TABLE_ADD_COLUMN: { + TAOS_FIELD *field = taosArrayGet(req.pFields, 0); + cJSON* colName = cJSON_CreateString(field->name); + cJSON_AddItemToObject(json, "colName", colName); + cJSON* colType = cJSON_CreateNumber(field->type); + cJSON_AddItemToObject(json, "colType", colType); + + if(field->type == TSDB_DATA_TYPE_BINARY){ + int32_t length = field->bytes - VARSTR_HEADER_SIZE; + cJSON* cbytes = cJSON_CreateNumber(length); + cJSON_AddItemToObject(json, "colLength", cbytes); + }else if (field->type == TSDB_DATA_TYPE_NCHAR){ + int32_t length = (field->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE; + cJSON* cbytes = cJSON_CreateNumber(length); + cJSON_AddItemToObject(json, "colLength", cbytes); + } + break; + } + case TSDB_ALTER_TABLE_DROP_TAG: + case TSDB_ALTER_TABLE_DROP_COLUMN:{ + TAOS_FIELD *field = taosArrayGet(req.pFields, 0); + cJSON* colName = cJSON_CreateString(field->name); + cJSON_AddItemToObject(json, "colName", colName); + break; + } + case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: + case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:{ + TAOS_FIELD *field = taosArrayGet(req.pFields, 0); + cJSON* colName = cJSON_CreateString(field->name); + cJSON_AddItemToObject(json, "colName", colName); + cJSON* colType = cJSON_CreateNumber(field->type); + cJSON_AddItemToObject(json, "colType", colType); + if(field->type == TSDB_DATA_TYPE_BINARY){ + int32_t length = field->bytes - VARSTR_HEADER_SIZE; + cJSON* cbytes = cJSON_CreateNumber(length); + cJSON_AddItemToObject(json, "colLength", cbytes); + }else if (field->type == TSDB_DATA_TYPE_NCHAR){ + int32_t length = (field->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE; + cJSON* cbytes = cJSON_CreateNumber(length); + cJSON_AddItemToObject(json, "colLength", cbytes); + } + break; + } + case TSDB_ALTER_TABLE_UPDATE_TAG_NAME: + case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:{ + TAOS_FIELD *oldField = taosArrayGet(req.pFields, 0); + TAOS_FIELD *newField = taosArrayGet(req.pFields, 1); + cJSON* colName = cJSON_CreateString(oldField->name); + cJSON_AddItemToObject(json, "colName", colName); + cJSON* colNewName = cJSON_CreateString(newField->name); + cJSON_AddItemToObject(json, "colNewName", colNewName); + break; + } + default: + break; + } + string = cJSON_PrintUnformatted(json); + +end: + cJSON_Delete(json); + tFreeSMAltertbReq(&req); + return string; +} + static char *processCreateStb(SMqMetaRsp *metaRsp){ SVCreateStbReq req = {0}; SDecoder coder; @@ -1947,53 +2039,74 @@ _err: return string; } -static char *buildCreateCTableJson(STag* pTag, int64_t sid, char* name, int64_t id){ +static char *processAlterStb(SMqMetaRsp *metaRsp){ + SVCreateStbReq req = {0}; + SDecoder coder; char* string = NULL; + + // decode and process req + void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); + int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + + if (tDecodeSVCreateStbReq(&coder, &req) < 0) { + goto _err; + } + string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen); + tDecoderClear(&coder); + return string; + + _err: + tDecoderClear(&coder); + return string; +} + +static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t id){ + char* string = NULL; + SArray* pTagVals = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { return string; } cJSON* type = cJSON_CreateString("create"); cJSON_AddItemToObject(json, "type", type); - char cid[32] = {0}; - sprintf(cid, "%"PRIi64, id); - cJSON* cid_ = cJSON_CreateString(cid); - cJSON_AddItemToObject(json, "id", cid_); +// char cid[32] = {0}; +// sprintf(cid, "%"PRIi64, id); +// cJSON* cid_ = cJSON_CreateString(cid); +// cJSON_AddItemToObject(json, "id", cid_); cJSON* tableName = cJSON_CreateString(name); cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString("child"); cJSON_AddItemToObject(json, "tableType", tableType); - - char sid_[32] = {0}; - sprintf(sid_, "%"PRIi64, sid); - cJSON* using = cJSON_CreateString(sid_); + cJSON* using = cJSON_CreateString(sname); cJSON_AddItemToObject(json, "using", using); // cJSON* version = cJSON_CreateNumber(1); // cJSON_AddItemToObject(json, "version", version); cJSON* tags = cJSON_CreateArray(); + int32_t code = tTagToValArray(pTag, &pTagVals); + if (code) { + goto end; + } - if (tTagIsJson(pTag)) { // todo + if (tTagIsJson(pTag)) { + STag* p = (STag*)pTag; + if(p->nTag == 0){ + goto end; + } char* pJson = parseTagDatatoJson(pTag); - cJSON* tag = cJSON_CreateObject(); - cJSON* tname = cJSON_CreateString("unknown"); // todo + STagVal* pTagVal = taosArrayGet(pTagVals, 0); + + cJSON* tname = cJSON_CreateString(pTagVal->colName); cJSON_AddItemToObject(tag, "name", tname); cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON); cJSON_AddItemToObject(tag, "type", ttype); cJSON* tvalue = cJSON_CreateString(pJson); cJSON_AddItemToObject(tag, "value", tvalue); cJSON_AddItemToArray(tags, tag); - cJSON_AddItemToObject(json, "tags", tags); - - string = cJSON_PrintUnformatted(json); - goto end; - } - - SArray* pTagVals = NULL; - int32_t code = tTagToValArray(pTag, &pTagVals); - if (code) { + taosMemoryFree(pJson); goto end; } @@ -2001,8 +2114,7 @@ static char *buildCreateCTableJson(STag* pTag, int64_t sid, char* name, int64_t STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, i); cJSON* tag = cJSON_CreateObject(); -// cJSON* tname = cJSON_CreateNumber(pTagVal->cid); - cJSON* tname = cJSON_CreateString("unkonwn"); // todo + cJSON* tname = cJSON_CreateString(pTagVal->colName); cJSON_AddItemToObject(tag, "name", tname); cJSON* ttype = cJSON_CreateNumber(pTagVal->type); cJSON_AddItemToObject(tag, "type", ttype); @@ -2021,12 +2133,12 @@ static char *buildCreateCTableJson(STag* pTag, int64_t sid, char* name, int64_t cJSON_AddItemToObject(tag, "value", tvalue); cJSON_AddItemToArray(tags, tag); } + + end: cJSON_AddItemToObject(json, "tags", tags); string = cJSON_PrintUnformatted(json); - -end: - cJSON_Delete(json); + taosArrayDestroy(pTagVals); return string; } @@ -2047,7 +2159,7 @@ static char *processCreateTable(SMqMetaRsp *metaRsp){ for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; if(pCreateReq->type == TSDB_CHILD_TABLE){ - string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.suid, pCreateReq->name, pCreateReq->uid); + string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, pCreateReq->uid); }else if(pCreateReq->type == TSDB_NORMAL_TABLE){ string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } @@ -2085,11 +2197,11 @@ static char *processAlterTable(SMqMetaRsp *metaRsp){ cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString(vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_TAG_VAL ? "child" : "normal"); cJSON_AddItemToObject(json, "tableType", tableType); + cJSON* alterType = cJSON_CreateNumber(vAlterTbReq.action); + cJSON_AddItemToObject(json, "alterType", alterType); switch (vAlterTbReq.action) { case TSDB_ALTER_TABLE_ADD_COLUMN: { - cJSON* alterType = cJSON_CreateNumber(TSDB_ALTER_TABLE_ADD_COLUMN); - cJSON_AddItemToObject(json, "alterType", alterType); cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); cJSON_AddItemToObject(json, "colName", colName); cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type); @@ -2107,33 +2219,27 @@ static char *processAlterTable(SMqMetaRsp *metaRsp){ break; } case TSDB_ALTER_TABLE_DROP_COLUMN:{ - cJSON* alterType = cJSON_CreateNumber(TSDB_ALTER_TABLE_DROP_COLUMN); - cJSON_AddItemToObject(json, "alterType", alterType); cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); cJSON_AddItemToObject(json, "colName", colName); break; } case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:{ - cJSON* alterType = cJSON_CreateNumber(TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES); - cJSON_AddItemToObject(json, "alterType", alterType); cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); cJSON_AddItemToObject(json, "colName", colName); - cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type); + cJSON* colType = cJSON_CreateNumber(vAlterTbReq.colModType); cJSON_AddItemToObject(json, "colType", colType); - if(vAlterTbReq.type == TSDB_DATA_TYPE_BINARY){ - int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE; + if(vAlterTbReq.colModType == TSDB_DATA_TYPE_BINARY){ + int32_t length = vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); - }else if (vAlterTbReq.type == TSDB_DATA_TYPE_NCHAR){ - int32_t length = (vAlterTbReq.bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE; + }else if (vAlterTbReq.colModType == TSDB_DATA_TYPE_NCHAR){ + int32_t length = (vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); } break; } case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:{ - cJSON* alterType = cJSON_CreateNumber(TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME); - cJSON_AddItemToObject(json, "alterType", alterType); cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); cJSON_AddItemToObject(json, "colName", colName); cJSON* colNewName = cJSON_CreateString(vAlterTbReq.colNewName); @@ -2141,12 +2247,25 @@ static char *processAlterTable(SMqMetaRsp *metaRsp){ break; } case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:{ - cJSON* alterType = cJSON_CreateNumber(TSDB_ALTER_TABLE_UPDATE_TAG_VAL); - cJSON_AddItemToObject(json, "alterType", alterType); cJSON* tagName = cJSON_CreateString(vAlterTbReq.tagName); cJSON_AddItemToObject(json, "colName", tagName); - cJSON* colValue = cJSON_CreateString("invalid, todo"); // todo - cJSON_AddItemToObject(json, "colValue", colValue); + + if (!vAlterTbReq.isNull){ + char* buf = NULL; + + if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) { + ASSERT(tTagIsJson(vAlterTbReq.pTagVal) == true); + buf = parseTagDatatoJson(vAlterTbReq.pTagVal); + } else { + buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 1, 1); + dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL); + } + + cJSON* colValue = cJSON_CreateString(buf); + cJSON_AddItemToObject(json, "colValue", colValue); + taosMemoryFree(buf); + } + cJSON* isNull = cJSON_CreateBool(vAlterTbReq.isNull); cJSON_AddItemToObject(json, "colValueNull", isNull); break; @@ -2180,10 +2299,6 @@ static char *processDropSTable(SMqMetaRsp *metaRsp){ } cJSON* type = cJSON_CreateString("drop"); cJSON_AddItemToObject(json, "type", type); - char uid[32] = {0}; - sprintf(uid, "%"PRIi64, req.suid); - cJSON* id = cJSON_CreateString(uid); - cJSON_AddItemToObject(json, "id", id); cJSON* tableName = cJSON_CreateString(req.name); cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString("super"); @@ -2224,7 +2339,7 @@ static char *processDropTable(SMqMetaRsp *metaRsp){ for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { SVDropTbReq* pDropTbReq = req.pReqs + iReq; - cJSON* tableName = cJSON_CreateString(pDropTbReq->name); // todo + cJSON* tableName = cJSON_CreateString(pDropTbReq->name); cJSON_AddItemToArray(tableNameList, tableName); } cJSON_AddItemToObject(json, "tableNameList", tableNameList); @@ -2245,7 +2360,7 @@ char *tmq_get_json_meta(TAOS_RES *res){ if(pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_STB){ return processCreateStb(&pMetaRspObj->metaRsp); }else if(pMetaRspObj->metaRsp.resMsgType == TDMT_VND_ALTER_STB){ - return processCreateStb(&pMetaRspObj->metaRsp); + return processAlterStb(&pMetaRspObj->metaRsp); }else if(pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_STB){ return processDropSTable(&pMetaRspObj->metaRsp); }else if(pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_TABLE){ @@ -2258,6 +2373,10 @@ char *tmq_get_json_meta(TAOS_RES *res){ return NULL; } +void tmq_free_json_meta(char* jsonMeta){ + taosMemoryFreeClear(jsonMeta); +} + static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ SVCreateStbReq req = {0}; SDecoder coder; @@ -2310,6 +2429,7 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ pReq.commentLen = -1; pReq.suid = req.suid; pReq.source = 1; + pReq.igExists = true; SName tableName; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -2747,6 +2867,7 @@ end: } int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ + return 0; if (!taos || !raw_meta) { return TSDB_CODE_INVALID_PARA; } @@ -2767,6 +2888,10 @@ int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ return TSDB_CODE_INVALID_PARA; } +void tmq_free_raw_meta(tmq_raw_data *rawMeta){ + taosMemoryFreeClear(rawMeta); +} + void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { tmqCommitInner2(tmq, msg, 0, 1, cb, param); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 165e8631c4..0ffb4f6d2a 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4803,6 +4803,11 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) { if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } + if (tEncodeI32(pCoder, pReq->alterOriDataLen) < 0) return -1; + if (pReq->alterOriDataLen > 0) { + if (tEncodeBinary(pCoder, pReq->alterOriData, pReq->alterOriDataLen) < 0) return -1; + } + tEndEncode(pCoder); return 0; } @@ -4819,6 +4824,11 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) { if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } + if (tDecodeI32(pCoder, &pReq->alterOriDataLen) < 0) return -1; + if (pReq->alterOriDataLen > 0) { + if (tDecodeBinary(pCoder, (uint8_t **)&pReq->alterOriData, NULL) < 0) return -1; + } + tEndDecode(pCoder); return 0; } @@ -4862,6 +4872,7 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) { } if (pReq->type == TSDB_CHILD_TABLE) { + if (tEncodeCStr(pCoder, pReq->ctb.name) < 0) return -1; if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1; if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1; } else if (pReq->type == TSDB_NORMAL_TABLE) { @@ -4891,6 +4902,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { } if (pReq->type == TSDB_CHILD_TABLE) { + if (tDecodeCStr(pCoder, &pReq->ctb.name) < 0) return -1; if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1; } else if (pReq->type == TSDB_NORMAL_TABLE) { @@ -5224,6 +5236,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) { break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1; + if (tEncodeI8(pEncoder, pReq->colModType) < 0) return -1; if (tEncodeI32v(pEncoder, pReq->colModBytes) < 0) return -1; break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: @@ -5233,6 +5246,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) { case TSDB_ALTER_TABLE_UPDATE_TAG_VAL: if (tEncodeCStr(pEncoder, pReq->tagName) < 0) return -1; if (tEncodeI8(pEncoder, pReq->isNull) < 0) return -1; + if (tEncodeI8(pEncoder, pReq->tagType) < 0) return -1; if (!pReq->isNull) { if (tEncodeBinary(pEncoder, pReq->pTagVal, pReq->nTagVal) < 0) return -1; } @@ -5272,6 +5286,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) { break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1; + if (tDecodeI8(pDecoder, &pReq->colModType) < 0) return -1; if (tDecodeI32v(pDecoder, &pReq->colModBytes) < 0) return -1; break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: @@ -5281,6 +5296,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) { case TSDB_ALTER_TABLE_UPDATE_TAG_VAL: if (tDecodeCStr(pDecoder, &pReq->tagName) < 0) return -1; if (tDecodeI8(pDecoder, &pReq->isNull) < 0) return -1; + if (tDecodeI8(pDecoder, &pReq->tagType) < 0) return -1; if (!pReq->isNull) { if (tDecodeBinary(pDecoder, &pReq->pTagVal, &pReq->nTagVal) < 0) return -1; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 6d1cc05ace..17885de60b 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -409,7 +409,7 @@ static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void * return 0; } -static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) { +static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen, void* alterOriData, int32_t alterOriDataLen) { SEncoder encoder = {0}; int32_t contLen; SName name = {0}; @@ -422,6 +422,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.name = (char *)tNameGetTableName(&name); req.suid = pStb->uid; req.rollup = pStb->ast1Len > 0 ? 1 : 0; + req.alterOriData = alterOriData; + req.alterOriDataLen = alterOriDataLen; // todo req.schemaRow.nCols = pStb->numOfColumns; req.schemaRow.version = pStb->colVer; @@ -626,7 +628,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj continue; } - void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen); + void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, NULL, 0); if (pReq == NULL) { sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pVgroup); @@ -1278,7 +1280,7 @@ static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj * return 0; } -static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { +static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb, void* alterOriData, int32_t alterOriDataLen) { SSdb *pSdb = pMnode->pSdb; SVgObj *pVgroup = NULL; void *pIter = NULL; @@ -1292,7 +1294,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj continue; } - void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen); + void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, alterOriData, alterOriDataLen); if (pReq == NULL) { sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pVgroup); @@ -1575,7 +1577,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; - if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj, pReq->pCont, pReq->contLen) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index a5cf755a74..576dc6d8d3 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -71,6 +71,7 @@ typedef struct SInsertParseContext { SVnodeModifOpStmt* pOutput; SStmtCallback* pStmtCb; SParseMetaCache* pMetaCache; + char sTableName[TSDB_TABLE_NAME_LEN]; } SInsertParseContext; typedef struct SInsertParseSyntaxCxt { @@ -811,10 +812,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* return TSDB_CODE_SUCCESS; } -static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid) { +static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname) { pTbReq->type = TD_CHILD_TABLE; pTbReq->name = strdup(tname); pTbReq->ctb.suid = suid; + if(sname) pTbReq->ctb.name = strdup(sname); pTbReq->ctb.pTag = (uint8_t*)pTag; pTbReq->commentLen = -1; @@ -835,6 +837,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16 return TSDB_CODE_SUCCESS; } + strcpy(val->colName, pSchema->name); val->cid = pSchema->colId; val->type = pSchema->type; @@ -1051,7 +1054,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint if (isNullStr(&sToken)) { code = tTagNew(pTagVals, 1, true, &pTag); } else { - code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg); + code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg, pTagSchema->name); } taosMemoryFree(tmpTokenBuf); if (code != TSDB_CODE_SUCCESS) { @@ -1081,7 +1084,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint goto end; } - buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid); + buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName); end: for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { @@ -1166,6 +1169,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg); char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(&sname, dbFName); + strcpy(pCxt->sTableName, sname.tname); CHECK_CODE(getSTableMeta(pCxt, &sname, dbFName)); if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) { @@ -1402,15 +1406,10 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SToken filePath, STa return TSDB_CODE_SUCCESS; } -void destroyCreateSubTbReq(SVCreateTbReq* pReq) { - taosMemoryFreeClear(pReq->name); - taosMemoryFreeClear(pReq->ctb.pTag); -} - static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) { taosMemoryFreeClear(pCxt->pTableMeta); destroyBoundColumnInfo(&pCxt->tags); - destroyCreateSubTbReq(&pCxt->createTblReq); + tdDestroySVCreateTbReq(&pCxt->createTblReq); } static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); } @@ -1556,7 +1555,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { } memcpy(tags, &pCxt->tags, sizeof(pCxt->tags)); (*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pCxt->pTableMeta, tags, tbFName, autoCreateTbl, - pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj); + pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj, pCxt->sTableName); memset(&pCxt->tags, 0, sizeof(pCxt->tags)); pCxt->pVgroupsHashObj = NULL; @@ -1865,7 +1864,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash return TSDB_CODE_SUCCESS; } -int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tName, TAOS_MULTI_BIND* bind, +int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) { STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; @@ -1904,13 +1903,14 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN isJson = true; char* tmp = taosMemoryCalloc(1, colLen + 1); memcpy(tmp, bind[c].buffer, colLen); - code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); + code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf, pTagSchema->name); taosMemoryFree(tmp); if (code != TSDB_CODE_SUCCESS) { goto end; } } else { STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { val.pData = (uint8_t*)bind[c].buffer; val.nData = colLen; @@ -1947,9 +1947,9 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN } SVCreateTbReq tbReq = {0}; - buildCreateTbReq(&tbReq, tName, pTag, suid); + buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName); code = buildCreateTbMsg(pDataBlock, &tbReq); - destroyCreateSubTbReq(&tbReq); + tdDestroySVCreateTbReq(&tbReq); end: for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { @@ -2213,7 +2213,7 @@ typedef struct SmlExecHandle { static void smlDestroyTableHandle(void* pHandle) { SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle; destroyBoundColumnInfo(&handle->tags); - destroyCreateSubTbReq(&handle->createTblReq); + tdDestroySVCreateTbReq(&handle->createTblReq); } static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema) { @@ -2311,6 +2311,7 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p SSmlKv* kv = taosArrayGetP(cols, i); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { val.pData = (uint8_t*)kv->value; val.nData = kv->length; @@ -2354,7 +2355,7 @@ end: } int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta, - char* tableName, char* msgBuf, int16_t msgBufLen) { + char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen) { SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle; @@ -2372,7 +2373,10 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols return ret; } - buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid); + buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL); + smlHandle->tableExecHandle.createTblReq.ctb.name = taosMemoryMalloc(sTableNameLen + 1); + memcpy(smlHandle->tableExecHandle.createTblReq.ctb.name, sTableName, sTableNameLen); + smlHandle->tableExecHandle.createTblReq.ctb.name[sTableNameLen] = 0; STableDataBlocks* pDataBlock = NULL; ret = getDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid), diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ed6d3c1c93..5ea06ca892 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5369,7 +5369,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { } static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt, - const STag* pTag, uint64_t suid, SVgroupInfo* pVgInfo) { + const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo) { // char dbFName[TSDB_DB_FNAME_LEN] = {0}; // SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; // strcpy(name.dbname, pStmt->dbName); @@ -5386,6 +5386,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S req.commentLen = -1; } req.ctb.suid = suid; + req.ctb.name = strdup(sTableNmae); req.ctb.pTag = (uint8_t*)pTag; if (pStmt->ignoreExists) { req.flags |= TD_CREATE_IF_NOT_EXISTS; @@ -5471,13 +5472,14 @@ static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SVa return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); } - return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); + return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf, pTagSchema->name); } static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { void* nodeVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + strcpy(val.colName, pTagSchema->name); if (IS_VAR_DATA_TYPE(pTagSchema->type)) { val.pData = varDataVal(nodeVal); val.nData = varDataLen(nodeVal); @@ -5571,6 +5573,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + strcpy(val.colName, pTagSchema->name); if (IS_VAR_DATA_TYPE(pTagSchema->type)) { val.pData = varDataVal(tmpVal); val.nData = varDataLen(tmpVal); @@ -5627,7 +5630,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, &info); + addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info); } taosMemoryFreeClear(pSuperTableMeta); @@ -5845,8 +5848,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS } pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); + pReq->tagType = targetDt.type; if (targetDt.type == TSDB_DATA_TYPE_JSON) { - pReq->isNull = 0; if (pStmt->pVal->literal && strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal); @@ -5855,7 +5858,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS int32_t code = TSDB_CODE_SUCCESS; STag* pTag = NULL; do { - code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf); + code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf, pReq->tagName); if (TSDB_CODE_SUCCESS != code) { break; } @@ -5870,6 +5873,9 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS if (code != TSDB_CODE_SUCCESS) { return code; } + if(pTag->nTag == 0){ + pReq->isNull = true; + } pReq->nTagVal = pTag->len; pReq->pTagVal = (uint8_t*)pTag; pStmt->pVal->datum.p = (char*)pTag; // for free @@ -5927,7 +5933,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, SVAlterTbReq* pReq) { pReq->colModBytes = calcTypeBytes(pStmt->dataType); - + pReq->colModType = pStmt->dataType.type; SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 7a23338035..2f12c9adf6 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -341,7 +341,7 @@ static bool isValidateTag(char* input) { return true; } -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf) { +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf, const char* colName) { int32_t retCode = TSDB_CODE_SUCCESS; cJSON* root = NULL; SHashObj* keyHash = NULL; @@ -389,6 +389,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi continue; } STagVal val = {0}; + strcpy(val.colName, colName); val.pKey = jsonKey; taosHashPut(keyHash, jsonKey, keyLen, &keyLen, CHAR_BYTES); // add key to hash to remove dumplicate, value is useless diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index df5df127f0..dd0a60dced 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1150,7 +1150,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu } memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; - if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){ + if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL, "")){ tTagNew(pTagVals, 1, true, &pTag); } } diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 07440e7435..8fcc76f51f 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -1114,7 +1114,7 @@ TEST(columnTest, json_column_arith_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL); + parseJsontoTagData(rightv, tags, &row, NULL, ""); const int32_t len = 8; EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, @@ -1262,7 +1262,7 @@ TEST(columnTest, json_column_logic_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL); + parseJsontoTagData(rightv, tags, &row, NULL, ""); const int32_t len0 = 6; const int32_t len = 9; From 2411a1416a849fa761149040476a27daf434c8b0 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sun, 10 Jul 2022 19:01:56 +0800 Subject: [PATCH 02/65] fix:conflicts --- source/dnode/mnode/impl/src/mndStb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index c60058e496..2117ef24d9 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -45,7 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); static int32_t mndProcessTableCfgReq(SRpcMsg *pReq); -static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp); +static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen); int32_t mndInitStb(SMnode *pMnode) { SSdbTable table = { @@ -936,7 +936,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { if (isAlter) { bool needRsp = false; - code = mndAlterStbImp(pMnode, pReq, pDb, pStb, needRsp); + code = mndAlterStbImp(pMnode, pReq, pDb, pStb, needRsp, NULL, 0); } else { code = mndCreateStb(pMnode, pReq, &createReq, pDb); } @@ -1544,7 +1544,7 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i return 0; } -static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp) { +static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq); if (pTrans == NULL) goto _OVER; @@ -1561,7 +1561,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; - if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; + if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, pStb, alterOriData, alterOriDataLen) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; @@ -1622,7 +1622,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p } if (code != 0) goto _OVER; - code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp); + code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp, pReq->pCont, pReq->contLen); _OVER: taosMemoryFreeClear(stbObj.pTags); From 3d2e129dd634ef4064cb71b025dcb8f20d1ac104 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 10:18:01 +0800 Subject: [PATCH 03/65] feat:add tmq get meta --- source/client/src/tmq.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 90cb43c676..6d24d8d9ff 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2869,7 +2869,6 @@ end: } int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ - return 0; if (!taos || !raw_meta) { return TSDB_CODE_INVALID_PARA; } From 0a193cf811df5443aa7231d08f3b2b56a2d239d3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 16:12:07 +0800 Subject: [PATCH 04/65] feat:get meta ok --- examples/c/tmq.c | 67 +++++++++++++++++----------- include/common/tmsg.h | 7 ++- include/util/tlog.h | 2 +- source/dnode/mnode/impl/src/mndStb.c | 50 ++++++++++++++++++--- source/dnode/vnode/src/tq/tq.c | 2 +- 5 files changed, 91 insertions(+), 37 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 5d7f1bbe70..c6248a62c1 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -30,10 +30,25 @@ static void msg_process(TAOS_RES* msg) { if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { tmq_raw_data *raw = tmq_get_raw_meta(msg); if(raw){ - TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", "abc1", 0); + TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", NULL, 0); if (pConn == NULL) { return; } + + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + if (taos_errno(pRes) != 0) { + printf("error in create db, reason:%s\n", taos_errstr(pRes)); + return; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + return; + } + taos_free_result(pRes); + int32_t ret = taos_write_raw_meta(pConn, raw); printf("write raw data: %s\n", tmq_err2str(ret)); free(raw); @@ -132,12 +147,12 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); - if (taos_errno(pRes) != 0) { - printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); +// pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); +// if (taos_errno(pRes) != 0) { +// printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); +// return -1; +// } +// taos_free_result(pRes); pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)"); if (taos_errno(pRes) != 0) { @@ -160,19 +175,19 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "drop table ct3 ct1"); - if (taos_errno(pRes) != 0) { - printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "drop table st1"); - if (taos_errno(pRes) != 0) { - printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); +// pRes = taos_query(pConn, "drop table ct3 ct1"); +// if (taos_errno(pRes) != 0) { +// printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); +// return -1; +// } +// taos_free_result(pRes); +// +// pRes = taos_query(pConn, "drop table st1"); +// if (taos_errno(pRes) != 0) { +// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); +// return -1; +// } +// taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); if (taos_errno(pRes) != 0) { @@ -209,12 +224,12 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "drop table n1"); - if (taos_errno(pRes) != 0) { - printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); +// pRes = taos_query(pConn, "drop table n1"); +// if (taos_errno(pRes) != 0) { +// printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); +// return -1; +// } +// taos_free_result(pRes); pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); if (taos_errno(pRes) != 0) { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index b67f220e1c..01f8ad99fd 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2843,8 +2843,8 @@ typedef struct { static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) { int32_t tlen = 0; - // tlen += taosEncodeFixedI64(buf, pRsp->reqOffset); - // tlen += taosEncodeFixedI64(buf, pRsp->rspOffset); + tlen += taosEncodeFixedI64(buf, pRsp->reqOffset); + tlen += taosEncodeFixedI64(buf, pRsp->rspOffset); tlen += taosEncodeFixedI16(buf, pRsp->resMsgType); tlen += taosEncodeFixedI32(buf, pRsp->metaRspLen); tlen += taosEncodeBinary(buf, pRsp->metaRsp, pRsp->metaRspLen); @@ -2852,8 +2852,7 @@ static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp } static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) { - // buf = taosDecodeFixedI64(buf, &pRsp->reqOffset); - // buf = taosDecodeFixedI64(buf, &pRsp->rspOffset); + buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);buf = taosDecodeFixedI64(buf, &pRsp->rspOffset); buf = taosDecodeFixedI16(buf, &pRsp->resMsgType); buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen); buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen); diff --git a/include/util/tlog.h b/include/util/tlog.h index a8c9eeabde..d186c32841 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -94,7 +94,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons #define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); } #define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); } // clang-format on -#define BUF_PAGE_DEBUG +//#define BUF_PAGE_DEBUG #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 2117ef24d9..3a7b137f9f 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -708,7 +708,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat memcpy(pDst->db, pDb->name, TSDB_DB_FNAME_LEN); pDst->createdTime = taosGetTimestampMs(); pDst->updateTime = pDst->createdTime; - pDst->uid = (pCreate->source == 1) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); + pDst->uid = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); pDst->dbUid = pDb->uid; pDst->tagVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->tagVer : 1; pDst->colVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->colVer : 1; @@ -883,9 +883,9 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH; goto _OVER; } else if (createReq.tagVer > 0 || createReq.colVer > 0) { - int32_t tagDelta = pStb->tagVer - createReq.tagVer; - int32_t colDelta = pStb->colVer - createReq.colVer; - int32_t verDelta = tagDelta + verDelta; + int32_t tagDelta = createReq.tagVer - pStb->tagVer; + int32_t colDelta = createReq.colVer - pStb->colVer; + int32_t verDelta = tagDelta + colDelta; mInfo("stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d", createReq.name, createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer); if (tagDelta <= 0 && colDelta <= 0) { @@ -936,7 +936,47 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { if (isAlter) { bool needRsp = false; - code = mndAlterStbImp(pMnode, pReq, pDb, pStb, needRsp, NULL, 0); + SStbObj pDst = {0}; + taosRLockLatch(&pStb->lock); + memcpy(&pDst, pStb, sizeof(SStbObj)); + taosRUnLockLatch(&pStb->lock); + + pDst.updateTime = taosGetTimestampMs(); + pDst.nextColId = 1; + pDst.numOfColumns = createReq.numOfColumns; + pDst.numOfTags = createReq.numOfTags; + pDst.pColumns = taosMemoryCalloc(1, pDst.numOfColumns * sizeof(SSchema)); + pDst.pTags = taosMemoryCalloc(1, pDst.numOfTags * sizeof(SSchema)); + if (pDst.pColumns == NULL || pDst.pTags == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + for (int32_t i = 0; i < pDst.numOfColumns; ++i) { + SField *pField = taosArrayGet(createReq.pColumns, i); + SSchema *pSchema = &pDst.pColumns[i]; + pSchema->type = pField->type; + pSchema->bytes = pField->bytes; + pSchema->flags = pField->flags; + memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); + pSchema->colId = pDst.nextColId; + pDst.nextColId++; + } + + for (int32_t i = 0; i < pDst.numOfTags; ++i) { + SField *pField = taosArrayGet(createReq.pTags, i); + SSchema *pSchema = &pDst.pTags[i]; + pSchema->type = pField->type; + pSchema->bytes = pField->bytes; + memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); + pSchema->colId = pDst.nextColId; + pDst.nextColId++; + } + pDst.tagVer = createReq.tagVer; + pDst.colVer = createReq.colVer; + code = mndAlterStbImp(pMnode, pReq, pDb, &pDst, needRsp, NULL, 0); + taosMemoryFreeClear(pDst.pTags); + taosMemoryFreeClear(pDst.pColumns); } else { code = mndCreateStb(pMnode, pReq, &createReq, pDb); } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 52949838b9..d97a958888 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -406,7 +406,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { tqInfo("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); SMqMetaRsp metaRsp = {0}; /*metaRsp.reqOffset = pReq->reqOffset.version;*/ - /*metaRsp.rspOffset = fetchVer;*/ + metaRsp.rspOffset = fetchVer; /*metaRsp.rspOffsetNew.version = fetchVer;*/ tqOffsetResetToLog(&metaRsp.reqOffsetNew, pReq->reqOffset.version); tqOffsetResetToLog(&metaRsp.rspOffsetNew, fetchVer); From c54bc76925b01793bca4b0a81b03f1007a862b40 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 17:36:07 +0800 Subject: [PATCH 05/65] feat:get meta ok --- examples/c/tmq.c | 71 +++++++++------ source/client/src/tmq.c | 4 +- source/dnode/mnode/impl/src/mndStb.c | 126 +++++++++++++++------------ 3 files changed, 116 insertions(+), 85 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index c6248a62c1..c55cb2ca58 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -51,15 +51,14 @@ static void msg_process(TAOS_RES* msg) { int32_t ret = taos_write_raw_meta(pConn, raw); printf("write raw data: %s\n", tmq_err2str(ret)); - free(raw); taos_close(pConn); } + tmq_free_raw_meta(raw); char* result = tmq_get_json_meta(msg); if(result){ printf("meta result: %s\n", result); - free(result); } - printf("meta:%p\n", raw); + tmq_free_json_meta(result); return; } while (1) { @@ -83,7 +82,7 @@ int32_t init_env() { return -1; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 3"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return -1; @@ -126,6 +125,13 @@ int32_t init_env() { } taos_free_result(pRes); + pRes = taos_query(pConn, "create table if not exists ct2 using st1 tags(NULL)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + pRes = taos_query(pConn, "insert into ct1 values(now, 3, 4, 'b')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes)); @@ -147,12 +153,12 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); -// if (taos_errno(pRes) != 0) { -// printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); + if (taos_errno(pRes) != 0) { + printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)"); if (taos_errno(pRes) != 0) { @@ -175,19 +181,19 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "drop table ct3 ct1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); -// -// pRes = taos_query(pConn, "drop table st1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, "drop table ct3 ct1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); if (taos_errno(pRes) != 0) { @@ -224,12 +230,12 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "drop table n1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, "drop table n1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); if (taos_errno(pRes) != 0) { @@ -245,6 +251,13 @@ int32_t init_env() { } taos_free_result(pRes); + pRes = taos_query(pConn, "create table jt2 using jt tags('')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + return 0; } diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 6d24d8d9ff..4dc0dbfa64 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2430,7 +2430,7 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ pReq.numOfTags = req.schemaTag.nCols; pReq.commentLen = -1; pReq.suid = req.suid; - pReq.source = 1; + pReq.source = TD_REQ_FROM_TAOX; pReq.igExists = true; SName tableName; @@ -2497,7 +2497,7 @@ static int32_t taosDropStb(TAOS *taos, void *meta, int32_t metaLen){ // build drop stable pReq.igNotExists = true; - pReq.source = 1; + pReq.source = TD_REQ_FROM_TAOX; pReq.suid = req.suid; SName tableName; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3a7b137f9f..5040b556e7 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -851,6 +851,75 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) { return 0; } +static int32_t mndFindSuperTableTagIndex(const SStbObj *pStb, const char *tagName) { + for (int32_t tag = 0; tag < pStb->numOfTags; tag++) { + if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) { + return tag; + } + } + + return -1; +} + +static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *colName) { + for (int32_t col = 0; col < pStb->numOfColumns; col++) { + if (strcasecmp(pStb->pColumns[col].name, colName) == 0) { + return col; + } + } + + return -1; +} + +static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq *createReq) { + taosRLockLatch(&pStb->lock); + memcpy(pDst, pStb, sizeof(SStbObj)); + taosRUnLockLatch(&pStb->lock); + + pDst->updateTime = taosGetTimestampMs(); + pDst->numOfColumns = createReq->numOfColumns; + pDst->numOfTags = createReq->numOfTags; + pDst->pColumns = taosMemoryCalloc(1, pDst->numOfColumns * sizeof(SSchema)); + pDst->pTags = taosMemoryCalloc(1, pDst->numOfTags * sizeof(SSchema)); + if (pDst->pColumns == NULL || pDst->pTags == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < pDst->numOfColumns; ++i) { + SField *pField = taosArrayGet(createReq->pColumns, i); + SSchema *pSchema = &pDst->pColumns[i]; + pSchema->type = pField->type; + pSchema->bytes = pField->bytes; + pSchema->flags = pField->flags; + memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); + int32_t cIndex = mndFindSuperTableColumnIndex(pStb, pField->name); + if (cIndex >= 0){ + pSchema->colId = pStb->pColumns[cIndex].colId; + }else{ + pSchema->colId = pDst->nextColId++; + } + } + + for (int32_t i = 0; i < pDst->numOfTags; ++i) { + SField *pField = taosArrayGet(createReq->pTags, i); + SSchema *pSchema = &pDst->pTags[i]; + pSchema->type = pField->type; + pSchema->bytes = pField->bytes; + memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); + int32_t cIndex = mndFindSuperTableTagIndex(pStb, pField->name); + if (cIndex >= 0){ + pSchema->colId = pStb->pTags[cIndex].colId; + }else{ + pSchema->colId = pDst->nextColId++; + } + + } + pDst->tagVer = createReq->tagVer; + pDst->colVer = createReq->colVer; + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; @@ -937,43 +1006,12 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { if (isAlter) { bool needRsp = false; SStbObj pDst = {0}; - taosRLockLatch(&pStb->lock); - memcpy(&pDst, pStb, sizeof(SStbObj)); - taosRUnLockLatch(&pStb->lock); - - pDst.updateTime = taosGetTimestampMs(); - pDst.nextColId = 1; - pDst.numOfColumns = createReq.numOfColumns; - pDst.numOfTags = createReq.numOfTags; - pDst.pColumns = taosMemoryCalloc(1, pDst.numOfColumns * sizeof(SSchema)); - pDst.pTags = taosMemoryCalloc(1, pDst.numOfTags * sizeof(SSchema)); - if (pDst.pColumns == NULL || pDst.pTags == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + if (mndBuildStbFromAlter(pStb, &pDst, &createReq) != 0) { + taosMemoryFreeClear(pDst.pTags); + taosMemoryFreeClear(pDst.pColumns); goto _OVER; } - for (int32_t i = 0; i < pDst.numOfColumns; ++i) { - SField *pField = taosArrayGet(createReq.pColumns, i); - SSchema *pSchema = &pDst.pColumns[i]; - pSchema->type = pField->type; - pSchema->bytes = pField->bytes; - pSchema->flags = pField->flags; - memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); - pSchema->colId = pDst.nextColId; - pDst.nextColId++; - } - - for (int32_t i = 0; i < pDst.numOfTags; ++i) { - SField *pField = taosArrayGet(createReq.pTags, i); - SSchema *pSchema = &pDst.pTags[i]; - pSchema->type = pField->type; - pSchema->bytes = pField->bytes; - memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); - pSchema->colId = pDst.nextColId; - pDst.nextColId++; - } - pDst.tagVer = createReq.tagVer; - pDst.colVer = createReq.colVer; code = mndAlterStbImp(pMnode, pReq, pDb, &pDst, needRsp, NULL, 0); taosMemoryFreeClear(pDst.pTags); taosMemoryFreeClear(pDst.pColumns); @@ -1014,26 +1052,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) { return 0; } -static int32_t mndFindSuperTableTagIndex(const SStbObj *pStb, const char *tagName) { - for (int32_t tag = 0; tag < pStb->numOfTags; tag++) { - if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) { - return tag; - } - } - - return -1; -} - -static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *colName) { - for (int32_t col = 0; col < pStb->numOfColumns; col++) { - if (strcasecmp(pStb->pColumns[col].name, colName) == 0) { - return col; - } - } - - return -1; -} - static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) { pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema)); pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema)); From a196298640d91d04fd8f7737412d1ed081355b2e Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 18:07:46 +0800 Subject: [PATCH 06/65] fix:disable colName in tag --- source/client/src/tmq.c | 13 +++++++++---- source/libs/parser/src/parInsert.c | 6 +++--- source/libs/parser/src/parTranslater.c | 4 ++-- source/libs/parser/src/parUtil.c | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 4dc0dbfa64..5f0fcf1d78 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2101,8 +2101,10 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); STagVal* pTagVal = taosArrayGet(pTagVals, 0); - cJSON* tname = cJSON_CreateString(pTagVal->colName); - cJSON_AddItemToObject(tag, "name", tname); +// cJSON* tname = cJSON_CreateString(pTagVal->colName); +// cJSON_AddItemToObject(tag, "name", tname); + cJSON* cid_ = cJSON_CreateString(""); + cJSON_AddItemToObject(tag, "cid", cid_); cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON); cJSON_AddItemToObject(tag, "type", ttype); cJSON* tvalue = cJSON_CreateString(pJson); @@ -2116,8 +2118,11 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, i); cJSON* tag = cJSON_CreateObject(); - cJSON* tname = cJSON_CreateString(pTagVal->colName); - cJSON_AddItemToObject(tag, "name", tname); + + char cid[32] = {0}; + sprintf(cid, "%d", pTagVal->cid); + cJSON* cid_ = cJSON_CreateString(cid); + cJSON_AddItemToObject(tag, "cid", cid_); cJSON* ttype = cJSON_CreateNumber(pTagVal->type); cJSON_AddItemToObject(tag, "type", ttype); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 576dc6d8d3..ad0877476d 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -837,7 +837,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16 return TSDB_CODE_SUCCESS; } - strcpy(val->colName, pSchema->name); +// strcpy(val->colName, pSchema->name); val->cid = pSchema->colId; val->type = pSchema->type; @@ -1910,7 +1910,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch } } else { STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - strcpy(val.colName, pTagSchema->name); +// strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { val.pData = (uint8_t*)bind[c].buffer; val.nData = colLen; @@ -2311,7 +2311,7 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p SSmlKv* kv = taosArrayGetP(cols, i); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - strcpy(val.colName, pTagSchema->name); +// strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { val.pData = (uint8_t*)kv->value; val.nData = kv->length; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a03cdb6485..75fc2b71dc 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5555,7 +5555,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { void* nodeVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - strcpy(val.colName, pTagSchema->name); +// strcpy(val.colName, pTagSchema->name); if (IS_VAR_DATA_TYPE(pTagSchema->type)) { val.pData = varDataVal(nodeVal); val.nData = varDataLen(nodeVal); @@ -5649,7 +5649,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - strcpy(val.colName, pTagSchema->name); +// strcpy(val.colName, pTagSchema->name); if (IS_VAR_DATA_TYPE(pTagSchema->type)) { val.pData = varDataVal(tmpVal); val.nData = varDataLen(tmpVal); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 2f12c9adf6..b6ebb0de22 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -389,7 +389,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi continue; } STagVal val = {0}; - strcpy(val.colName, colName); +// strcpy(val.colName, colName); val.pKey = jsonKey; taosHashPut(keyHash, jsonKey, keyLen, &keyLen, CHAR_BYTES); // add key to hash to remove dumplicate, value is useless From 4862f032d6b3691ff903ffe7a784b445bdad63eb Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 18:07:54 +0800 Subject: [PATCH 07/65] fix:disable colName in tag --- include/common/tdataformat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index e768f89372..d37b8ce1ca 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -167,7 +167,7 @@ struct SColVal { #pragma pack(push, 1) struct STagVal { - char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta +// char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta union { int16_t cid; char *pKey; From 5d3e07c0220ec84e7db53431166edde50f678990 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 19:10:41 +0800 Subject: [PATCH 08/65] fix:conflict from 3.0 --- source/client/src/tmq.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index e3dfdc68a8..649584a9a1 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2114,8 +2114,8 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t // cJSON* tname = cJSON_CreateString(pTagVal->colName); // cJSON_AddItemToObject(tag, "name", tname); - cJSON* cid_ = cJSON_CreateString(""); - cJSON_AddItemToObject(tag, "cid", cid_); +// cJSON* cid_ = cJSON_CreateString(""); +// cJSON_AddItemToObject(tag, "cid", cid_); cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON); cJSON_AddItemToObject(tag, "type", ttype); cJSON* tvalue = cJSON_CreateString(pJson); @@ -2130,10 +2130,8 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); - char cid[32] = {0}; - sprintf(cid, "%d", pTagVal->cid); - cJSON* cid_ = cJSON_CreateString(cid); - cJSON_AddItemToObject(tag, "cid", cid_); + cJSON* cid = cJSON_CreateNumber(pTagVal->cid); + cJSON_AddItemToObject(tag, "cid", cid); cJSON* ttype = cJSON_CreateNumber(pTagVal->type); cJSON_AddItemToObject(tag, "type", ttype); From 1f5663f03ef8c6bb6635f1686383caa182145bd0 Mon Sep 17 00:00:00 2001 From: tomchon Date: Mon, 11 Jul 2022 19:52:18 +0800 Subject: [PATCH 09/65] test:add test case of tsbs query --- tests/system-test/2-query/tsbsQuery.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index d24e5ea283..819380d7fd 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -58,11 +58,18 @@ class TDTestCase: tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") tdSql.checkRows(1) + # test insert into + tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") + tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") + tdSql.checkRows(1) + + tdSql.query("insert into testsnode(c1,c2,c3,c4) SELECT avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m);") + tdSql.checkRows(1) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") - self.tsbsIotQuery() + self.prepareData() self.tsbsIotQuery() From 8684f75dcdeafbe05a5b566efd5d1f42907195ba Mon Sep 17 00:00:00 2001 From: tomchon Date: Mon, 11 Jul 2022 20:00:11 +0800 Subject: [PATCH 10/65] test:add test case of tsbs query --- tests/system-test/2-query/tsbsQuery.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 819380d7fd..bc7095f627 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -8,7 +8,12 @@ from util.sql import * from util.cases import * class TDTestCase: - + + clientCfgDict = {'queryproxy': '1','debugFlag': 135} + clientCfgDict["debugFlag"] = 143 + updatecfgDict = {'clientCfg': {}} + updatecfgDict["clientCfg"] = clientCfgDict + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), True) @@ -61,10 +66,8 @@ class TDTestCase: # test insert into tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") - tdSql.checkRows(1) - + tdSql.query("insert into testsnode(c1,c2,c3,c4) SELECT avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m);") - tdSql.checkRows(1) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring From 218c71df6a8bdc02dea0af36d2f1eadd09ec15c7 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Jul 2022 20:03:57 +0800 Subject: [PATCH 11/65] feat:add tmq alter table option --- examples/c/tmq.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index c55cb2ca58..f421f344a2 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -223,6 +223,13 @@ int32_t init_env() { } taos_free_result(pRes); + pRes = taos_query(pConn, "alter table n1 comment 'hello'"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + pRes = taos_query(pConn, "alter table n1 drop column c1"); if (taos_errno(pRes) != 0) { printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); From e3a48b01ecf1109a9fd8f86069c687c9b8dc7c8d Mon Sep 17 00:00:00 2001 From: tomchon Date: Tue, 12 Jul 2022 14:25:02 +0800 Subject: [PATCH 12/65] test:add testcase of qnode --- tests/system-test/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 3b0dd76a30..1884420ccd 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -120,7 +120,7 @@ python3 ./test.py -f 2-query/irate.py python3 ./test.py -f 2-query/and_or_for_byte.py python3 ./test.py -f 2-query/function_null.py -#python3 ./test.py -f 2-query/queryQnode.py +python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 6-cluster/5dnode1mnode.py #BUG python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 From 2641714e87808cfe3c40b4b1cd81803b8d33f26a Mon Sep 17 00:00:00 2001 From: tomchon Date: Tue, 12 Jul 2022 15:20:05 +0800 Subject: [PATCH 13/65] test:add test case of tsbs query --- tests/system-test/2-query/tsbsQuery.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index bc7095f627..be3a788006 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -10,8 +10,9 @@ from util.cases import * class TDTestCase: clientCfgDict = {'queryproxy': '1','debugFlag': 135} - clientCfgDict["debugFlag"] = 143 + clientCfgDict["debugFlag"] = 131 updatecfgDict = {'clientCfg': {}} + updatecfgDict = {'debugFlag': 131} updatecfgDict["clientCfg"] = clientCfgDict def init(self, conn, logSql): @@ -60,9 +61,14 @@ class TDTestCase: def tsbsIotQuery(self): tdSql.execute("use db_tsbs") + + # test interval and partition + tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") + parRows=tdSql.queryRows tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") - tdSql.checkRows(1) - + tdSql.checkRows(parRows) + + # test insert into tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") From 2b442621e85fc31e6d17b2bd95f7108ab7d8d38a Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 12 Jul 2022 18:58:33 +0800 Subject: [PATCH 14/65] feat:get child table name in tmq meta --- examples/c/tmq.c | 10 ++--- include/common/tdataformat.h | 2 +- include/common/tmsg.h | 4 +- source/client/src/tmq.c | 16 +++++--- source/common/src/tmsg.c | 15 +++++++ source/dnode/mnode/sdb/inc/sdb.h | 1 + source/libs/parser/src/parInsert.c | 39 +++++++++++++++---- source/libs/parser/src/parTranslater.c | 25 ++++++++---- source/libs/parser/src/parUtil.c | 2 +- source/libs/scalar/src/sclfunc.c | 2 +- .../libs/scalar/test/scalar/scalarTests.cpp | 4 +- 11 files changed, 87 insertions(+), 33 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index f421f344a2..c114237353 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -97,14 +97,14 @@ int32_t init_env() { taos_free_result(pRes); pRes = - taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int)"); + taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)"); if (taos_errno(pRes) != 0) { printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000)"); + pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)"); if (taos_errno(pRes) != 0) { printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes)); return -1; @@ -118,14 +118,14 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct1 using st1 tags(2000)"); + pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes)); return -1; } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct2 using st1 tags(NULL)"); + pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes)); return -1; @@ -139,7 +139,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create table if not exists ct3 using st1 tags(3000)"); + pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)"); if (taos_errno(pRes) != 0) { printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index d37b8ce1ca..6f54472dbb 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -97,7 +97,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf, const char* colName); +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf); // STRUCT ================= struct STColumn { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e157c4cc1b..5e7e045b78 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1968,8 +1968,9 @@ typedef struct SVCreateTbReq { int8_t type; union { struct { - char* name; + char* name; // super table name tb_uid_t suid; + SArray* tagName; uint8_t* pTag; } ctb; struct { @@ -1987,6 +1988,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) { if (req->type == TSDB_CHILD_TABLE) { taosMemoryFreeClear(req->ctb.pTag); taosMemoryFreeClear(req->ctb.name); + taosArrayDestroy(req->ctb.tagName); } else if (req->type == TSDB_NORMAL_TABLE) { taosMemoryFreeClear(req->ntb.schemaRow.pSchema); } diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 649584a9a1..c5cf6eecdf 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2074,7 +2074,7 @@ static char *processAlterStb(SMqMetaRsp *metaRsp){ return string; } -static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t id){ +static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* tagName, int64_t id){ char* string = NULL; SArray* pTagVals = NULL; cJSON* json = cJSON_CreateObject(); @@ -2112,8 +2112,9 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); STagVal* pTagVal = taosArrayGet(pTagVals, 0); -// cJSON* tname = cJSON_CreateString(pTagVal->colName); -// cJSON_AddItemToObject(tag, "name", tname); + char* ptname = taosArrayGet(tagName, 0); + cJSON* tname = cJSON_CreateString(ptname); + cJSON_AddItemToObject(tag, "name", tname); // cJSON* cid_ = cJSON_CreateString(""); // cJSON_AddItemToObject(tag, "cid", cid_); cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON); @@ -2130,8 +2131,11 @@ static char *buildCreateCTableJson(STag* pTag, char* sname, char* name, int64_t cJSON* tag = cJSON_CreateObject(); - cJSON* cid = cJSON_CreateNumber(pTagVal->cid); - cJSON_AddItemToObject(tag, "cid", cid); + char* ptname = taosArrayGet(tagName, i); + cJSON* tname = cJSON_CreateString(ptname); + cJSON_AddItemToObject(tag, "name", tname); +// cJSON* cid = cJSON_CreateNumber(pTagVal->cid); +// cJSON_AddItemToObject(tag, "cid", cid); cJSON* ttype = cJSON_CreateNumber(pTagVal->type); cJSON_AddItemToObject(tag, "type", ttype); @@ -2175,7 +2179,7 @@ static char *processCreateTable(SMqMetaRsp *metaRsp){ for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; if(pCreateReq->type == TSDB_CHILD_TABLE){ - string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, pCreateReq->uid); + string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, pCreateReq->ctb.tagName, pCreateReq->uid); }else if(pCreateReq->type == TSDB_NORMAL_TABLE){ string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 7245a62eb2..8901014600 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4943,6 +4943,12 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) { if (tEncodeCStr(pCoder, pReq->ctb.name) < 0) return -1; if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1; if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1; + int32_t len = taosArrayGetSize(pReq->ctb.tagName); + if (tEncodeI32(pCoder, len) < 0) return -1; + for (int32_t i = 0; i < len; i++){ + char* name = taosArrayGet(pReq->ctb.tagName, i); + if (tEncodeCStr(pCoder, name) < 0) return -1; + } } else if (pReq->type == TSDB_NORMAL_TABLE) { if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { @@ -4973,6 +4979,15 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { if (tDecodeCStr(pCoder, &pReq->ctb.name) < 0) return -1; if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1; + int32_t len = 0; + if (tDecodeI32(pCoder, &len) < 0) return -1; + pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); + if(pReq->ctb.tagName == NULL) return -1; + for (int32_t i = 0; i < len; i++){ + char *name = NULL; + if (tDecodeCStr(pCoder, &name) < 0) return -1; + taosArrayPush(pReq->ctb.tagName, name); + } } else if (pReq->type == TSDB_NORMAL_TABLE) { if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index 1294f0cff3..be56d901de 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -163,6 +163,7 @@ typedef struct SSdbRow { ESdbType type; ESdbStatus status; int32_t refCount; + int64_t forAlign; char pObj[]; } SSdbRow; diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 9bb55cf663..46a8ffcc6c 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -732,12 +732,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* return TSDB_CODE_SUCCESS; } -static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname) { +static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, SArray* tagName) { pTbReq->type = TD_CHILD_TABLE; pTbReq->name = strdup(tname); pTbReq->ctb.suid = suid; if(sname) pTbReq->ctb.name = strdup(sname); pTbReq->ctb.pTag = (uint8_t*)pTag; + pTbReq->ctb.tagName = taosArrayDup(tagName); pTbReq->commentLen = -1; return; @@ -936,6 +937,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16 static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint8_t precision, const char* tName) { int32_t code = TSDB_CODE_SUCCESS; SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal)); + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); SToken sToken; bool isParseBindParam = false; bool isJson = false; @@ -965,6 +967,10 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint taosMemoryFree(tmpTokenBuf); goto end; } + + if (!isNullStr(&sToken)) { + taosArrayPush(tagName, pTagSchema->name); + } if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (sToken.n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { code = buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", sToken.z); @@ -974,7 +980,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint if (isNullStr(&sToken)) { code = tTagNew(pTagVals, 1, true, &pTag); } else { - code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg, pTagSchema->name); + code = parseJsontoTagData(sToken.z, pTagVals, &pTag, &pCxt->msg); } taosMemoryFree(tmpTokenBuf); if (code != TSDB_CODE_SUCCESS) { @@ -1004,7 +1010,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint goto end; } - buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName); + buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName); end: for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { @@ -1014,6 +1020,7 @@ end: } } taosArrayDestroy(pTagVals); + taosArrayDestroy(tagName); return code; } @@ -1798,6 +1805,11 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch return buildInvalidOperationMsg(&pBuf, "out of memory"); } + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!tagName) { + return buildInvalidOperationMsg(&pBuf, "out of memory"); + } + int32_t code = TSDB_CODE_SUCCESS; SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); @@ -1814,6 +1826,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch if (IS_VAR_DATA_TYPE(pTagSchema->type)) { colLen = bind[c].length[0]; } + taosArrayPush(tagName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer); @@ -1823,7 +1836,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch isJson = true; char* tmp = taosMemoryCalloc(1, colLen + 1); memcpy(tmp, bind[c].buffer, colLen); - code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf, pTagSchema->name); + code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); taosMemoryFree(tmp); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -1867,7 +1880,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch } SVCreateTbReq tbReq = {0}; - buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName); + buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName); code = buildCreateTbMsg(pDataBlock, &tbReq); tdDestroySVCreateTbReq(&tbReq); @@ -1879,6 +1892,7 @@ end: } } taosArrayDestroy(pTagArray); + taosArrayDestroy(tagName); return code; } @@ -2219,17 +2233,22 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS * @param msg * @return int32_t */ -static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SMsgBuf* msg) { +static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName, SMsgBuf* msg) { SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); if (!pTagArray) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } + *tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!*tagName) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } int32_t code = TSDB_CODE_SUCCESS; for (int i = 0; i < tags->numOfBound; ++i) { SSchema* pTagSchema = &pSchema[tags->boundColumns[i]]; SSmlKv* kv = taosArrayGetP(cols, i); + taosArrayPush(*tagName, pTagSchema->name); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; // strcpy(val.colName, pTagSchema->name); if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { @@ -2288,12 +2307,16 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols return ret; } STag* pTag = NULL; - ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &pBuf); + SArray* tagName = NULL; + ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &tagName, &pBuf); if (ret != TSDB_CODE_SUCCESS) { + taosArrayDestroy(tagName); return ret; } - buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL); + buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName); + taosArrayDestroy(tagName); + smlHandle->tableExecHandle.createTblReq.ctb.name = taosMemoryMalloc(sTableNameLen + 1); memcpy(smlHandle->tableExecHandle.createTblReq.ctb.name, sTableName, sTableNameLen); smlHandle->tableExecHandle.createTblReq.ctb.name[sTableNameLen] = 0; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index f822945ef5..ffacafb504 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5263,6 +5263,8 @@ static void destroyCreateTbReqBatch(void* data) { taosMemoryFreeClear(pTableReq->ntb.schemaRow.pSchema); } else if (pTableReq->type == TSDB_CHILD_TABLE) { taosMemoryFreeClear(pTableReq->ctb.pTag); + taosMemoryFreeClear(pTableReq->ctb.name); + taosArrayDestroy(pTableReq->ctb.tagName); } } @@ -5334,7 +5336,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { } static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt, - const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo) { + const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo, SArray* tagName) { // char dbFName[TSDB_DB_FNAME_LEN] = {0}; // SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; // strcpy(name.dbname, pStmt->dbName); @@ -5353,6 +5355,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S req.ctb.suid = suid; req.ctb.name = strdup(sTableNmae); req.ctb.pTag = (uint8_t*)pTag; + req.ctb.tagName = taosArrayDup(tagName); if (pStmt->ignoreExists) { req.flags |= TD_CREATE_IF_NOT_EXISTS; } @@ -5437,7 +5440,7 @@ static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SVa return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); } - return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf, pTagSchema->name); + return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); } static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { @@ -5457,7 +5460,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S } static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - STag** ppTag) { + STag** ppTag, SArray* tagName) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { @@ -5488,8 +5491,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla if (pSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag); + taosArrayPush(tagName, pCol->colName); } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray); + taosArrayPush(tagName, pCol->colName); } } if (TSDB_CODE_SUCCESS == code) { @@ -5510,7 +5515,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla } static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - STag** ppTag) { + STag** ppTag, SArray* tagName) { if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } @@ -5535,6 +5540,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag); + taosArrayPush(tagName, pTagSchema->name); } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; @@ -5546,6 +5552,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau memcpy(&val.i64, tmpVal, pTagSchema->bytes); } taosArrayPush(pTagArray, &val); + taosArrayPush(tagName, pTagSchema->name); } } if (TSDB_CODE_SUCCESS == code) { @@ -5581,12 +5588,13 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla } STag* pTag = NULL; + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); if (TSDB_CODE_SUCCESS == code) { if (NULL != pStmt->pSpecificTags) { - code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag); + code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName); } else { - code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag); + code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName); } } @@ -5595,9 +5603,10 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info); + addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info, tagName); } + taosArrayDestroy(tagName); taosMemoryFreeClear(pSuperTableMeta); return code; } @@ -5823,7 +5832,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS int32_t code = TSDB_CODE_SUCCESS; STag* pTag = NULL; do { - code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf, pReq->tagName); + code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf); if (TSDB_CODE_SUCCESS != code) { break; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index b6ebb0de22..69cc95a726 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -341,7 +341,7 @@ static bool isValidateTag(char* input) { return true; } -int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf, const char* colName) { +int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, void* pMsgBuf) { int32_t retCode = TSDB_CODE_SUCCESS; cJSON* root = NULL; SHashObj* keyHash = NULL; diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index dd0a60dced..df5df127f0 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1150,7 +1150,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu } memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; - if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL, "")){ + if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){ tTagNew(pTagVals, 1, true, &pTag); } } diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 6663fc3cc4..9b40f0a465 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -1114,7 +1114,7 @@ TEST(columnTest, json_column_arith_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL, ""); + parseJsontoTagData(rightv, tags, &row, NULL); const int32_t len = 8; EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, @@ -1262,7 +1262,7 @@ TEST(columnTest, json_column_logic_op) { memcpy(rightv, rightvTmp, strlen(rightvTmp)); SArray *tags = taosArrayInit(1, sizeof(STagVal)); STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL, ""); + parseJsontoTagData(rightv, tags, &row, NULL); const int32_t len0 = 6; const int32_t len = 9; From ebb2f34de14db5800e643e75a23f603d812a18c7 Mon Sep 17 00:00:00 2001 From: tomchon Date: Wed, 13 Jul 2022 10:43:59 +0800 Subject: [PATCH 15/65] test:add test case of tsbs query --- tests/system-test/2-query/tsbsQuery.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index be3a788006..63f243baa0 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -66,16 +66,19 @@ class TDTestCase: tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") parRows=tdSql.queryRows tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") - tdSql.checkRows(parRows) + # tdSql.checkRows(parRows) # test insert into tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") - tdSql.query("insert into testsnode(c1,c2,c3,c4) SELECT avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m);") + tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") + # test interval fill + tdSql.query("SELECT name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0) ;") + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") self.prepareData() From 0857ab35319c5aa7e53338be2be58fdf4123afd6 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 11:39:32 +0800 Subject: [PATCH 16/65] fix:core dump if consumer multi vgroup message with sequence:create/alter/delete/create or create/delete/create --- source/client/src/tmq.c | 15 ++++++++++----- source/dnode/mnode/impl/src/mndStb.c | 12 ++++++++++-- source/libs/parser/src/parTranslater.c | 3 +++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index c5cf6eecdf..9d4eeb3233 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2397,7 +2397,7 @@ void tmq_free_json_meta(char* jsonMeta){ taosMemoryFreeClear(jsonMeta); } -static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ +static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen, bool isCreate){ SVCreateStbReq req = {0}; SDecoder coder; SMCreateStbReq pReq = {0}; @@ -2436,8 +2436,13 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ strcpy(field.name, pSchema->name); taosArrayPush(pReq.pTags, &field); } - pReq.colVer = req.schemaRow.version; - pReq.tagVer = req.schemaTag.version; + if(isCreate){ + pReq.colVer = 1; + pReq.tagVer = 1; + }else{ + pReq.colVer = req.schemaRow.version; + pReq.tagVer = req.schemaTag.version; + } pReq.numOfColumns = req.schemaRow.nCols; pReq.numOfTags = req.schemaTag.nCols; pReq.commentLen = -1; @@ -2871,9 +2876,9 @@ int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ } if(raw_meta->raw_meta_type == TDMT_VND_CREATE_STB) { - return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len, true); }else if(raw_meta->raw_meta_type == TDMT_VND_ALTER_STB){ - return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len, false); }else if(raw_meta->raw_meta_type == TDMT_VND_DROP_STB){ return taosDropStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); }else if(raw_meta->raw_meta_type == TDMT_VND_CREATE_TABLE){ diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 16143619c1..e170a2916f 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -710,8 +710,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat pDst->updateTime = pDst->createdTime; pDst->uid = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); pDst->dbUid = pDb->uid; - pDst->tagVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->tagVer : 1; - pDst->colVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->colVer : 1; + pDst->tagVer = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->tagVer : 1; + pDst->colVer = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->colVer : 1; pDst->smaVer = 1; pDst->nextColId = 1; pDst->maxdelay[0] = pCreate->delay1; @@ -981,6 +981,14 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { } } else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) { goto _OVER; + } else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer != 1 || createReq.colVer != 1)){ + mInfo("stb:%s, alter table does not need to be done, because table is deleted", createReq.name); + code = 0; + goto _OVER; + } else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer == 1 || createReq.colVer == 1)){ //metaSaveToSkmDb does not delete pMeta->pSkmDb, if receivet tmq message is: create stable1 then delete stable1 then create stable1 + mInfo("stb:%s, create table from taosx", createReq.name); + createReq.tagVer++; + createReq.colVer++; } pDb = mndAcquireDbByStb(pMnode, createReq.name); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ffacafb504..d78e7d1ba2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3685,6 +3685,9 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm pReq->delay2 = pStmt->pOptions->maxDelay2; pReq->watermark1 = pStmt->pOptions->watermark1; pReq->watermark2 = pStmt->pOptions->watermark2; + pReq->colVer = 1; + pReq->tagVer = 1; + pReq->source = TD_REQ_FROM_APP; columnDefNodeToField(pStmt->pCols, &pReq->pColumns); columnDefNodeToField(pStmt->pTags, &pReq->pTags); pReq->numOfColumns = LIST_LENGTH(pStmt->pCols); From 037ea1519c3e1fe14b32ab9ba55cd760a70ba631 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 13:42:55 +0800 Subject: [PATCH 17/65] fix:core dump if consumer multi vgroup message with sequence:create/alter/delete/create or create/delete/create --- examples/c/tmq.c | 17 +++++++++++++++-- source/client/src/tmq.c | 16 ++++++---------- source/dnode/mnode/impl/src/mndStb.c | 8 ++------ source/dnode/vnode/src/meta/metaTable.c | 5 +++++ 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index c114237353..24c415b2fc 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -96,8 +96,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = - taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)"); + pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)"); if (taos_errno(pRes) != 0) { printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); return -1; @@ -265,6 +264,20 @@ int32_t init_env() { } taos_free_result(pRes); + pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + return 0; } diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 9d4eeb3233..ed9efdf3da 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2397,7 +2397,7 @@ void tmq_free_json_meta(char* jsonMeta){ taosMemoryFreeClear(jsonMeta); } -static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen, bool isCreate){ +static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ SVCreateStbReq req = {0}; SDecoder coder; SMCreateStbReq pReq = {0}; @@ -2436,13 +2436,9 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen, bool isCre strcpy(field.name, pSchema->name); taosArrayPush(pReq.pTags, &field); } - if(isCreate){ - pReq.colVer = 1; - pReq.tagVer = 1; - }else{ - pReq.colVer = req.schemaRow.version; - pReq.tagVer = req.schemaTag.version; - } + + pReq.colVer = req.schemaRow.version; + pReq.tagVer = req.schemaTag.version; pReq.numOfColumns = req.schemaRow.nCols; pReq.numOfTags = req.schemaTag.nCols; pReq.commentLen = -1; @@ -2876,9 +2872,9 @@ int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ } if(raw_meta->raw_meta_type == TDMT_VND_CREATE_STB) { - return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len, true); + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); }else if(raw_meta->raw_meta_type == TDMT_VND_ALTER_STB){ - return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len, false); + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); }else if(raw_meta->raw_meta_type == TDMT_VND_DROP_STB){ return taosDropStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); }else if(raw_meta->raw_meta_type == TDMT_VND_CREATE_TABLE){ diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index e170a2916f..51f550ad92 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -710,8 +710,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat pDst->updateTime = pDst->createdTime; pDst->uid = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); pDst->dbUid = pDb->uid; - pDst->tagVer = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->tagVer : 1; - pDst->colVer = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->colVer : 1; + pDst->tagVer = 1; + pDst->colVer = 1; pDst->smaVer = 1; pDst->nextColId = 1; pDst->maxdelay[0] = pCreate->delay1; @@ -985,10 +985,6 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { mInfo("stb:%s, alter table does not need to be done, because table is deleted", createReq.name); code = 0; goto _OVER; - } else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer == 1 || createReq.colVer == 1)){ //metaSaveToSkmDb does not delete pMeta->pSkmDb, if receivet tmq message is: create stable1 then delete stable1 then create stable1 - mInfo("stb:%s, create table from taosx", createReq.name); - createReq.tagVer++; - createReq.colVer++; } pDb = mndAcquireDbByStb(pMnode, createReq.name); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index daf7ccb26a..29c10c40c2 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -1125,6 +1125,11 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { skmDbKey.uid = pME->uid; skmDbKey.sver = pSW->version; + // if receive tmq meta message is: create stable1 then delete stable1 then create stable1 with multi vgroups + if (tdbTbGet(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), NULL, NULL) == 0) { + return rcode; + } + // encode schema int32_t ret = 0; tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen, ret); From 0237ccbbb693ecb2fbd2926bed884f65d0456db7 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 15:33:31 +0800 Subject: [PATCH 18/65] fix:error in tmq meta --- include/common/tcommon.h | 1 - source/client/src/tmq.c | 1 + source/dnode/mnode/impl/src/mndStb.c | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 3d15e8b087..9440a3452b 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -40,7 +40,6 @@ enum { || x == TDMT_VND_CREATE_TABLE \ || x == TDMT_VND_ALTER_TABLE \ || x == TDMT_VND_DROP_TABLE \ - || x == TDMT_VND_DROP_TTL_TABLE \ ) // clang-format on diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index ed9efdf3da..7e01e5cd83 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2713,6 +2713,7 @@ static int32_t taosDropTable(TAOS *taos, void *meta, int32_t metaLen){ // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pDropReq = req.pReqs + iReq; + pDropReq->igNotExists = true; SVgroupInfo pInfo = {0}; SName pName; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 51f550ad92..bff33af5af 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1849,8 +1849,8 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { } } - if (dropReq.source != TD_REQ_FROM_APP && pStb->uid != dropReq.suid) { - terrno = TSDB_CODE_MND_STB_NOT_EXIST; + if (dropReq.source == TD_REQ_FROM_TAOX && pStb->uid != dropReq.suid) { + code = 0; goto _OVER; } From 531dfd4452e75f924584908a93eb2bdc52ff97dd Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 16:00:06 +0800 Subject: [PATCH 19/65] fix:error in tmq meta --- examples/c/tmq.c | 4 ++-- source/client/src/tmq.c | 3 +++ source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 24c415b2fc..94e0b86821 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -35,7 +35,7 @@ static void msg_process(TAOS_RES* msg) { return; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 5"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return; @@ -82,7 +82,7 @@ int32_t init_env() { return -1; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 3"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 5"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 7e01e5cd83..d4d7c05b56 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2856,6 +2856,9 @@ static int32_t taosAlterTable(TAOS *taos, void *meta, int32_t metaLen){ pVgData = NULL; pArray = NULL; code = pRequest->code; + if (code == TSDB_CODE_VND_TABLE_NOT_EXIST){ + code = 0; + } end: taosArrayDestroy(pArray); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d25ae817c7..d369475437 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -611,7 +611,7 @@ static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pRe // process if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq, &vMetaRsp) < 0) { - vAlterTbRsp.code = TSDB_CODE_INVALID_MSG; + vAlterTbRsp.code = terrno; tDecoderClear(&dc); rcode = -1; goto _exit; From a015aca162066abe644db333b4ccd4499324c012 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 17:16:34 +0800 Subject: [PATCH 20/65] fix:core dump if stable name is null in SVCreateTbReq --- source/dnode/vnode/src/tq/tqSink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index dbbb2b2661..25615f8d5c 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -50,6 +50,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo SVCreateTbReq createTbReq = {0}; createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId); + createTbReq.ctb.name = strdup(stbFullName); createTbReq.flags = 0; createTbReq.type = TSDB_CHILD_TABLE; createTbReq.ctb.suid = suid; From 8aa04f8e5549c8c46ba0890675731f3964e70b18 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 18:49:57 +0800 Subject: [PATCH 21/65] fix:error in tmq meta --- include/util/tencode.h | 4 ++-- source/common/src/tmsg.c | 6 ++++-- source/dnode/vnode/src/vnd/vnodeSvr.c | 10 +++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/util/tencode.h b/include/util/tencode.h index e318d4f240..ad642cd612 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -440,7 +440,7 @@ static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size = static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; @@ -451,7 +451,7 @@ static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 714a17df0d..9ebfa78b80 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4984,8 +4984,10 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); if(pReq->ctb.tagName == NULL) return -1; for (int32_t i = 0; i < len; i++){ - char *name = NULL; - if (tDecodeCStr(pCoder, &name) < 0) return -1; + char name[TSDB_COL_NAME_LEN] = {0}; + char *tmp = NULL; + if (tDecodeCStr(pCoder, &tmp) < 0) return -1; + strcpy(name, tmp); taosArrayPush(pReq->ctb.tagName, name); } } else if (pReq->type == TSDB_NORMAL_TABLE) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d369475437..cca212a4e4 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -494,8 +494,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR taosArrayPush(rsp.pArray, &cRsp); } - tDecoderClear(&decoder); - tqUpdateTbUidList(pVnode->pTq, tbUids, true); tdUpdateTbUidList(pVnode->pSma, pStore); tdUidStoreFree(pStore); @@ -512,9 +510,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR } tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncodeSVCreateTbBatchRsp(&encoder, &rsp); - tEncoderClear(&encoder); _exit: + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosArrayDestroy(pCreateReq->ctb.tagName); + } taosArrayDestroy(rsp.pArray); taosArrayDestroy(tbUids); tDecoderClear(&decoder); @@ -795,6 +796,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) { pRsp->code = TSDB_CODE_INVALID_MSG; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } @@ -802,6 +804,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { submitBlkRsp.code = terrno; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } } @@ -822,6 +825,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid"); #endif tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); } else { submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN); sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname); From 88d1d8fad21771ace5f654d2979e0f248bc2a3cd Mon Sep 17 00:00:00 2001 From: tomchon Date: Wed, 13 Jul 2022 20:21:13 +0800 Subject: [PATCH 22/65] test:add test case of tsbs query --- tests/system-test/2-query/tsbsQuery.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 63f243baa0..8180f511e2 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -76,9 +76,19 @@ class TDTestCase: tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") - # test interval fill - tdSql.query("SELECT name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0) ;") + # test paitition interval fill + # tdSql.query("SELECT name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0) ;") + + # # test partition interval limit + # tdSql.query("SELECT ts,model,floor(2*(sum(nzs)/count(nzs)))/floor(2*(sum(nzs)/count(nzs))) AS broken_down FROM (SELECT ts,model, status/status AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model,ts interval(10m) limit 10;") + # tdSql.checkRows(10) + + # test partition interval Pseudo time-column + tdSql.query("SELECT count(ms1)/144 FROM (SELECT _wstartts as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") + + + # test def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") self.prepareData() From 56ec0a3920dc66f005d381e7dabc90f347747ac2 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 20:42:49 +0800 Subject: [PATCH 23/65] fix: json null --- source/client/src/tmq.c | 11 ++++++++--- source/libs/parser/src/parTranslater.c | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 2741ea0670..ad47348c22 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2269,7 +2269,12 @@ static char *processAlterTable(SMqMetaRsp *metaRsp){ cJSON* tagName = cJSON_CreateString(vAlterTbReq.tagName); cJSON_AddItemToObject(json, "colName", tagName); - if (!vAlterTbReq.isNull){ + bool isNull = vAlterTbReq.isNull; + if(vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON){ + STag *jsonTag = (STag *)vAlterTbReq.pTagVal; + if(jsonTag->nTag == 0) isNull = true; + } + if (!isNull){ char* buf = NULL; if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) { @@ -2285,8 +2290,8 @@ static char *processAlterTable(SMqMetaRsp *metaRsp){ taosMemoryFree(buf); } - cJSON* isNull = cJSON_CreateBool(vAlterTbReq.isNull); - cJSON_AddItemToObject(json, "colValueNull", isNull); + cJSON* isNullCJson = cJSON_CreateBool(isNull); + cJSON_AddItemToObject(json, "colValueNull", isNullCJson); break; } default: diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 6654bc26cd..a8fbc8d7ab 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5872,9 +5872,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS if (code != TSDB_CODE_SUCCESS) { return code; } - if(pTag->nTag == 0){ - pReq->isNull = true; - } pReq->nTagVal = pTag->len; pReq->pTagVal = (uint8_t*)pTag; pStmt->pVal->datum.p = (char*)pTag; // for free From 2647a3d9eeb3a12dcb10ca3d3fb2043c94d21047 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 21:00:54 +0800 Subject: [PATCH 24/65] fix: json null --- source/libs/parser/src/parTranslater.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a8fbc8d7ab..87a5258774 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5846,7 +5846,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return pCxt->errCode; } - pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); pReq->tagType = targetDt.type; if (targetDt.type == TSDB_DATA_TYPE_JSON) { if (pStmt->pVal->literal && @@ -5876,6 +5875,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS pReq->pTagVal = (uint8_t*)pTag; pStmt->pVal->datum.p = (char*)pTag; // for free } else { + pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); pReq->nTagVal = pStmt->pVal->node.resType.bytes; pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal); From 9d13ee914841aefc8829893af33a518ac14aebb5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 10:20:30 +0800 Subject: [PATCH 25/65] test: restore some 2.0 case --- tests/script/general/rm_bak/tag/testSuite.sim | 25 ----------------- tests/script/jenkins/basic.txt | 28 +++++++++++++++++++ .../script/{general/rm_bak => tsim}/tag/3.sim | 17 +++++------ .../script/{general/rm_bak => tsim}/tag/4.sim | 8 +----- .../script/{general/rm_bak => tsim}/tag/5.sim | 8 +----- .../script/{general/rm_bak => tsim}/tag/6.sim | 8 +----- .../{general/rm_bak => tsim}/tag/add.sim | 6 +--- .../{general/rm_bak => tsim}/tag/bigint.sim | 7 +---- .../{general/rm_bak => tsim}/tag/binary.sim | 7 +---- .../rm_bak => tsim}/tag/binary_binary.sim | 7 +---- .../{general/rm_bak => tsim}/tag/bool.sim | 7 +---- .../rm_bak => tsim}/tag/bool_binary.sim | 7 +---- .../{general/rm_bak => tsim}/tag/bool_int.sim | 7 +---- .../{general/rm_bak => tsim}/tag/change.sim | 6 +--- .../{general/rm_bak => tsim}/tag/column.sim | 7 +---- .../{general/rm_bak => tsim}/tag/commit.sim | 6 +--- .../{general/rm_bak => tsim}/tag/create.sim | 5 ---- .../{general/rm_bak => tsim}/tag/delete.sim | 6 +--- .../{general/rm_bak => tsim}/tag/double.sim | 7 +---- .../{general/rm_bak => tsim}/tag/filter.sim | 4 +-- .../{general/rm_bak => tsim}/tag/float.sim | 7 +---- .../{general/rm_bak => tsim}/tag/int.sim | 7 +---- .../rm_bak => tsim}/tag/int_binary.sim | 7 +---- .../rm_bak => tsim}/tag/int_float.sim | 7 +---- .../{general/rm_bak => tsim}/tag/set.sim | 6 +--- .../{general/rm_bak => tsim}/tag/smallint.sim | 7 +---- .../{general/rm_bak => tsim}/tag/tinyint.sim | 7 +---- 27 files changed, 58 insertions(+), 173 deletions(-) delete mode 100644 tests/script/general/rm_bak/tag/testSuite.sim rename tests/script/{general/rm_bak => tsim}/tag/3.sim (97%) rename tests/script/{general/rm_bak => tsim}/tag/4.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/5.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/6.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/add.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/bigint.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/binary.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/binary_binary.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/bool.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/bool_binary.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/bool_int.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/change.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/column.sim (95%) rename tests/script/{general/rm_bak => tsim}/tag/commit.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/create.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/delete.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/double.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/filter.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/float.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/int.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/int_binary.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/int_float.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/set.sim (99%) rename tests/script/{general/rm_bak => tsim}/tag/smallint.sim (98%) rename tests/script/{general/rm_bak => tsim}/tag/tinyint.sim (98%) diff --git a/tests/script/general/rm_bak/tag/testSuite.sim b/tests/script/general/rm_bak/tag/testSuite.sim deleted file mode 100644 index 45356efac1..0000000000 --- a/tests/script/general/rm_bak/tag/testSuite.sim +++ /dev/null @@ -1,25 +0,0 @@ -run general/tag/3.sim -run general/tag/4.sim -run general/tag/5.sim -run general/tag/6.sim -run general/tag/add.sim -run general/tag/bigint.sim -run general/tag/binary_binary.sim -run general/tag/binary.sim -run general/tag/bool_binary.sim -run general/tag/bool_int.sim -run general/tag/bool.sim -run general/tag/change.sim -run general/tag/column.sim -run general/tag/commit.sim -run general/tag/create.sim -run general/tag/delete.sim -run general/tag/double.sim -run general/tag/filter.sim -run general/tag/float.sim -run general/tag/int_binary.sim -run general/tag/int_float.sim -run general/tag/int.sim -run general/tag/set.sim -run general/tag/smallint.sim -run general/tag/tinyint.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index dad4dbbe29..af0e338c9b 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -279,4 +279,32 @@ # ---- wal ./test.sh -f tsim/wal/kill.sim +# ---- tag +./test.sh -f tsim/tag/3.sim +./test.sh -f tsim/tag/4.sim +./test.sh -f tsim/tag/5.sim +./test.sh -f tsim/tag/6.sim +./test.sh -f tsim/tag/add.sim +./test.sh -f tsim/tag/bigint.sim +./test.sh -f tsim/tag/binary_binary.sim +./test.sh -f tsim/tag/binary.sim +./test.sh -f tsim/tag/bool_binary.sim +./test.sh -f tsim/tag/bool_int.sim +./test.sh -f tsim/tag/bool.sim +./test.sh -f tsim/tag/change.sim +./test.sh -f tsim/tag/column.sim +./test.sh -f tsim/tag/commit.sim +./test.sh -f tsim/tag/create.sim +./test.sh -f tsim/tag/delete.sim +./test.sh -f tsim/tag/double.sim +./test.sh -f tsim/tag/filter.sim +./test.sh -f tsim/tag/float.sim +./test.sh -f tsim/tag/int_binary.sim +./test.sh -f tsim/tag/int_float.sim +./test.sh -f tsim/tag/int.sim +./test.sh -f tsim/tag/set.sim +./test.sh -f tsim/tag/smallint.sim +./test.sh -f tsim/tag/tinyint.sim + + #======================b1-end=============== diff --git a/tests/script/general/rm_bak/tag/3.sim b/tests/script/tsim/tag/3.sim similarity index 97% rename from tests/script/general/rm_bak/tag/3.sim rename to tests/script/tsim/tag/3.sim index 20185f5f01..d816aec3e3 100644 --- a/tests/script/general/rm_bak/tag/3.sim +++ b/tests/script/tsim/tag/3.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -494,28 +491,28 @@ if $data00 != 25 then endi print =============== step19 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 partition by tgcol1 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 partition by tgcol2 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 partition by tgcol3 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/4.sim b/tests/script/tsim/tag/4.sim similarity index 99% rename from tests/script/general/rm_bak/tag/4.sim rename to tests/script/tsim/tag/4.sim index ee3c8efa6c..0bb1cde75d 100644 --- a/tests/script/general/rm_bak/tag/4.sim +++ b/tests/script/tsim/tag/4.sim @@ -1,13 +1,7 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect -sql reset query cache print ======================== dnode1 start @@ -708,7 +702,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/5.sim b/tests/script/tsim/tag/5.sim similarity index 99% rename from tests/script/general/rm_bak/tag/5.sim rename to tests/script/tsim/tag/5.sim index 895b1a9492..e3edbcaa5d 100644 --- a/tests/script/general/rm_bak/tag/5.sim +++ b/tests/script/tsim/tag/5.sim @@ -1,13 +1,7 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect -sql reset query cache print ======================== dnode1 start @@ -831,7 +825,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/6.sim b/tests/script/tsim/tag/6.sim similarity index 99% rename from tests/script/general/rm_bak/tag/6.sim rename to tests/script/tsim/tag/6.sim index 9190998bb3..d4e1d52c3c 100644 --- a/tests/script/general/rm_bak/tag/6.sim +++ b/tests/script/tsim/tag/6.sim @@ -1,13 +1,7 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect -sql reset query cache print ======================== dnode1 start @@ -986,7 +980,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/add.sim b/tests/script/tsim/tag/add.sim similarity index 99% rename from tests/script/general/rm_bak/tag/add.sim rename to tests/script/tsim/tag/add.sim index 4a3871235e..2901614889 100644 --- a/tests/script/general/rm_bak/tag/add.sim +++ b/tests/script/tsim/tag/add.sim @@ -1,10 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -849,7 +845,7 @@ step142: print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/bigint.sim b/tests/script/tsim/tag/bigint.sim similarity index 98% rename from tests/script/general/rm_bak/tag/bigint.sim rename to tests/script/tsim/tag/bigint.sim index 3e5d528980..2e1af227c0 100644 --- a/tests/script/general/rm_bak/tag/bigint.sim +++ b/tests/script/tsim/tag/bigint.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/binary.sim b/tests/script/tsim/tag/binary.sim similarity index 98% rename from tests/script/general/rm_bak/tag/binary.sim rename to tests/script/tsim/tag/binary.sim index 960f45675d..2cabf30bb1 100644 --- a/tests/script/general/rm_bak/tag/binary.sim +++ b/tests/script/tsim/tag/binary.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/binary_binary.sim b/tests/script/tsim/tag/binary_binary.sim similarity index 99% rename from tests/script/general/rm_bak/tag/binary_binary.sim rename to tests/script/tsim/tag/binary_binary.sim index 3a0fb56848..8a77de5226 100644 --- a/tests/script/general/rm_bak/tag/binary_binary.sim +++ b/tests/script/tsim/tag/binary_binary.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -304,7 +299,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/bool.sim b/tests/script/tsim/tag/bool.sim similarity index 98% rename from tests/script/general/rm_bak/tag/bool.sim rename to tests/script/tsim/tag/bool.sim index e37cba669b..26e320c41e 100644 --- a/tests/script/general/rm_bak/tag/bool.sim +++ b/tests/script/tsim/tag/bool.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -235,7 +230,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/bool_binary.sim b/tests/script/tsim/tag/bool_binary.sim similarity index 99% rename from tests/script/general/rm_bak/tag/bool_binary.sim rename to tests/script/tsim/tag/bool_binary.sim index 9f6e4f7344..d776127757 100644 --- a/tests/script/general/rm_bak/tag/bool_binary.sim +++ b/tests/script/tsim/tag/bool_binary.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -304,7 +299,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/bool_int.sim b/tests/script/tsim/tag/bool_int.sim similarity index 99% rename from tests/script/general/rm_bak/tag/bool_int.sim rename to tests/script/tsim/tag/bool_int.sim index 60345c2d68..daeb0c711f 100644 --- a/tests/script/general/rm_bak/tag/bool_int.sim +++ b/tests/script/tsim/tag/bool_int.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -320,7 +315,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/change.sim b/tests/script/tsim/tag/change.sim similarity index 99% rename from tests/script/general/rm_bak/tag/change.sim rename to tests/script/tsim/tag/change.sim index 6f294c0f48..f58e387217 100644 --- a/tests/script/general/rm_bak/tag/change.sim +++ b/tests/script/tsim/tag/change.sim @@ -1,10 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -508,7 +504,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/column.sim b/tests/script/tsim/tag/column.sim similarity index 95% rename from tests/script/general/rm_bak/tag/column.sim rename to tests/script/tsim/tag/column.sim index 5a0cd169c5..c73999230f 100644 --- a/tests/script/general/rm_bak/tag/column.sim +++ b/tests/script/tsim/tag/column.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -89,7 +84,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/commit.sim b/tests/script/tsim/tag/commit.sim similarity index 99% rename from tests/script/general/rm_bak/tag/commit.sim rename to tests/script/tsim/tag/commit.sim index bcd9d7c618..18128fc464 100644 --- a/tests/script/general/rm_bak/tag/commit.sim +++ b/tests/script/tsim/tag/commit.sim @@ -1,10 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -1177,7 +1173,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/create.sim b/tests/script/tsim/tag/create.sim similarity index 99% rename from tests/script/general/rm_bak/tag/create.sim rename to tests/script/tsim/tag/create.sim index 95b4166543..e25f1eb71f 100644 --- a/tests/script/general/rm_bak/tag/create.sim +++ b/tests/script/tsim/tag/create.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/rm_bak/tag/delete.sim b/tests/script/tsim/tag/delete.sim similarity index 99% rename from tests/script/general/rm_bak/tag/delete.sim rename to tests/script/tsim/tag/delete.sim index 2a0aa27bde..bcfd822dbd 100644 --- a/tests/script/general/rm_bak/tag/delete.sim +++ b/tests/script/tsim/tag/delete.sim @@ -1,10 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -820,7 +816,7 @@ step145: print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/double.sim b/tests/script/tsim/tag/double.sim similarity index 98% rename from tests/script/general/rm_bak/tag/double.sim rename to tests/script/tsim/tag/double.sim index f17043393f..3f936318fb 100644 --- a/tests/script/general/rm_bak/tag/double.sim +++ b/tests/script/tsim/tag/double.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/filter.sim b/tests/script/tsim/tag/filter.sim similarity index 99% rename from tests/script/general/rm_bak/tag/filter.sim rename to tests/script/tsim/tag/filter.sim index 7a899a7e67..b9f2df0cc6 100644 --- a/tests/script/general/rm_bak/tag/filter.sim +++ b/tests/script/tsim/tag/filter.sim @@ -1,8 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -142,7 +140,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/float.sim b/tests/script/tsim/tag/float.sim similarity index 98% rename from tests/script/general/rm_bak/tag/float.sim rename to tests/script/tsim/tag/float.sim index 35bf7d6090..215869e003 100644 --- a/tests/script/general/rm_bak/tag/float.sim +++ b/tests/script/tsim/tag/float.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/int.sim b/tests/script/tsim/tag/int.sim similarity index 98% rename from tests/script/general/rm_bak/tag/int.sim rename to tests/script/tsim/tag/int.sim index 4eea02c9cd..d97079de91 100644 --- a/tests/script/general/rm_bak/tag/int.sim +++ b/tests/script/tsim/tag/int.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/int_binary.sim b/tests/script/tsim/tag/int_binary.sim similarity index 99% rename from tests/script/general/rm_bak/tag/int_binary.sim rename to tests/script/tsim/tag/int_binary.sim index 9a75697676..fef77a16d9 100644 --- a/tests/script/general/rm_bak/tag/int_binary.sim +++ b/tests/script/tsim/tag/int_binary.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -304,7 +299,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/int_float.sim b/tests/script/tsim/tag/int_float.sim similarity index 99% rename from tests/script/general/rm_bak/tag/int_float.sim rename to tests/script/tsim/tag/int_float.sim index a03c4b7148..f184fdce0c 100644 --- a/tests/script/general/rm_bak/tag/int_float.sim +++ b/tests/script/tsim/tag/int_float.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -320,7 +315,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/set.sim b/tests/script/tsim/tag/set.sim similarity index 99% rename from tests/script/general/rm_bak/tag/set.sim rename to tests/script/tsim/tag/set.sim index cbc964fad7..2c14313a07 100644 --- a/tests/script/general/rm_bak/tag/set.sim +++ b/tests/script/tsim/tag/set.sim @@ -1,10 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -452,7 +448,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/smallint.sim b/tests/script/tsim/tag/smallint.sim similarity index 98% rename from tests/script/general/rm_bak/tag/smallint.sim rename to tests/script/tsim/tag/smallint.sim index e69eef05f2..cb65a93d5f 100644 --- a/tests/script/general/rm_bak/tag/smallint.sim +++ b/tests/script/tsim/tag/smallint.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/rm_bak/tag/tinyint.sim b/tests/script/tsim/tag/tinyint.sim similarity index 98% rename from tests/script/general/rm_bak/tag/tinyint.sim rename to tests/script/tsim/tag/tinyint.sim index 2d70dc7d48..c6d9df2597 100644 --- a/tests/script/general/rm_bak/tag/tinyint.sim +++ b/tests/script/tsim/tag/tinyint.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ======================== dnode1 start @@ -237,7 +232,7 @@ endi print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi From e9accd26dffcfef19af87d9545b8f701781ee4c1 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 14 Jul 2022 10:40:46 +0800 Subject: [PATCH 26/65] fix:double free error for parserTest --- include/common/tmsg.h | 1 + source/libs/parser/src/parInsert.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5e7e045b78..c8e13fce3d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1989,6 +1989,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) { taosMemoryFreeClear(req->ctb.pTag); taosMemoryFreeClear(req->ctb.name); taosArrayDestroy(req->ctb.tagName); + req->ctb.tagName = NULL; } else if (req->type == TSDB_NORMAL_TABLE) { taosMemoryFreeClear(req->ntb.schemaRow.pSchema); } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 935cadc484..005a7f919a 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1514,6 +1514,7 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache .pSql = (char*)pContext->pSql, .msg = {.buf = pContext->pMsg, .len = pContext->msgLen}, .pTableMeta = NULL, + .createTblReq = {0}, .pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK), .pTableNameHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK), .pDbFNameHashObj = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK), From 59062a9bae55fca614ba6eb8feaae956f5985bb0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 10:41:22 +0800 Subject: [PATCH 27/65] fix: memory leak while dnode exiting --- source/dnode/mgmt/mgmt_mnode/src/mmWorker.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index a171d2e1e4..d2b071ec61 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -168,7 +168,12 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { memcpy(pMsg, pRpc, sizeof(SRpcMsg)); dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType)); - return mmPutMsgToWorker(pMgmt, pWorker, pMsg); + int32_t code = mmPutMsgToWorker(pMgmt, pWorker, pMsg); + if (code != 0) { + dTrace("msg:%p, is freed", pMsg); + taosFreeQitem(pMsg); + } + return code; } int32_t mmStartWorker(SMnodeMgmt *pMgmt) { From c7e64933d0832a346d4475fb7652301563373475 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 14 Jul 2022 10:43:54 +0800 Subject: [PATCH 28/65] fix: use calcTypeBytes for table altering --- source/libs/parser/src/parTranslater.c | 3 ++- tests/script/tsim/alter/table.sim | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d12f1cfe7c..837d0f5773 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5939,7 +5939,8 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S pReq->type = pStmt->dataType.type; pReq->flags = COL_SMA_ON; - pReq->bytes = pStmt->dataType.bytes; + // pReq->bytes = pStmt->dataType.bytes; + pReq->bytes = calcTypeBytes(pStmt->dataType); return TSDB_CODE_SUCCESS; } diff --git a/tests/script/tsim/alter/table.sim b/tests/script/tsim/alter/table.sim index cc995d171f..348bef21fe 100644 --- a/tests/script/tsim/alter/table.sim +++ b/tests/script/tsim/alter/table.sim @@ -660,8 +660,8 @@ endi print ======= over sql drop database d1 sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT From fb49fd40cddccccf4a3a3933a173ffcf9302d028 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Jul 2022 10:44:35 +0800 Subject: [PATCH 29/65] fix(query):fix invalid write in sample query processing. --- source/libs/function/src/builtinsimpl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index e622c0c1af..97cb1f0ee1 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -3461,9 +3461,16 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData } } +/* + * +------------------------------------+--------------+--------------+ + * | null bitmap | | | + * |(n columns, one bit for each column)| src column #1| src column #2| + * +------------------------------------+--------------+--------------+ + */ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) { SFilePage* pPage = NULL; + // todo refactor: move away int32_t completeRowSize = pCtx->subsidiaries.num * sizeof(bool); for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) { SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; @@ -3476,12 +3483,15 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS } else { pPage = getBufPage(pCtx->pBuf, pCtx->curBufPage); if (pPage->num + completeRowSize > getBufPageSize(pCtx->pBuf)) { + // current page is all used, let's prepare a new buffer page + releaseBufPage(pCtx->pBuf, pPage); pPage = getNewBufPage(pCtx->pBuf, 0, &pCtx->curBufPage); pPage->num = sizeof(SFilePage); } } pPos->pageId = pCtx->curBufPage; + pPos->offset = pPage->num; // keep the current row data, extract method int32_t offset = 0; @@ -3509,7 +3519,6 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS offset += pCol->info.bytes; } - pPos->offset = pPage->num; pPage->num += completeRowSize; setBufPageDirty(pPage, true); @@ -4839,7 +4848,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da if (pInfo->numSampled < pInfo->samples) { sampleAssignResult(pInfo, data, pInfo->numSampled); if (pCtx->subsidiaries.num > 0) { - saveTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + pInfo->numSampled * sizeof(STuplePos)); + saveTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[pInfo->numSampled]); } pInfo->numSampled++; } else { @@ -4847,7 +4856,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da if (j < pInfo->samples) { sampleAssignResult(pInfo, data, j); if (pCtx->subsidiaries.num > 0) { - copyTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + j * sizeof(STuplePos)); + copyTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[j]); } } } @@ -4885,7 +4894,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; for (int32_t i = 0; i < pInfo->numSampled; ++i) { colDataAppend(pCol, currentRow + i, pInfo->data + i * pInfo->colBytes, false); - setSelectivityValue(pCtx, pBlock, pInfo->tuplePos + i * sizeof(STuplePos), currentRow + i); + setSelectivityValue(pCtx, pBlock, &pInfo->tuplePos[i], currentRow + i); } return pInfo->numSampled; From e8c041f09856e5845be679718c9a52868d1ce0f7 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 14 Jul 2022 10:49:09 +0800 Subject: [PATCH 30/65] fix:filter child table with tag --- source/libs/executor/src/executil.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 2469062d09..6b2bea273d 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -347,25 +347,25 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, terrno = code; return code; } - - if (pTagCond) { - int32_t i = 0; - while (i < taosArrayGetSize(pListInfo->pTableList)) { - STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i); - bool isOk = isTableOk(info, pTagCond, metaHandle); - if (terrno) return terrno; - if (!isOk) { - taosArrayRemove(pListInfo->pTableList, i); - continue; - } - i++; - } - } } else { // Create one table group. STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0}; taosArrayPush(pListInfo->pTableList, &info); } + if (pTagCond) { + int32_t i = 0; + while (i < taosArrayGetSize(pListInfo->pTableList)) { + STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i); + bool isOk = isTableOk(info, pTagCond, metaHandle); + if (terrno) return terrno; + if (!isOk) { + taosArrayRemove(pListInfo->pTableList, i); + continue; + } + i++; + } + } + pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES); if (pListInfo->pGroupList == NULL) { return TSDB_CODE_OUT_OF_MEMORY; From 724d2e0f5fdf6c43fc23a2ae9b2d111d4a3fe1fd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 10:51:09 +0800 Subject: [PATCH 31/65] test: valgrind case --- tests/script/sh/deploy.sh | 4 ++-- tests/script/tsim/valgrind/checkError2.sim | 24 +++++++++++++++++++--- tests/script/tsim/valgrind/checkError3.sim | 16 +++++++-------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index de7b8ecfbf..5f497a248f 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -127,8 +127,8 @@ echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG echo "debugFlag 0" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "uDebugFlag 131" >> $TAOS_CFG -echo "rpcDebugFlag 131" >> $TAOS_CFG +echo "uDebugFlag 143" >> $TAOS_CFG +echo "rpcDebugFlag 143" >> $TAOS_CFG echo "jniDebugFlag 143" >> $TAOS_CFG echo "qDebugFlag 143" >> $TAOS_CFG echo "cDebugFlag 143" >> $TAOS_CFG diff --git a/tests/script/tsim/valgrind/checkError2.sim b/tests/script/tsim/valgrind/checkError2.sim index 3939b7c854..3a82218015 100644 --- a/tests/script/tsim/valgrind/checkError2.sim +++ b/tests/script/tsim/valgrind/checkError2.sim @@ -37,22 +37,40 @@ endi print =============== step4: create show table sql create table ct1 using stb tags(1000) +sql create table ct2 using stb tags(2000) +sql create table ct3 using stb tags(3000) sql show tables -if $rows != 1 then +if $rows != 3 then return -1 endi print =============== step5: insert data sql insert into ct1 values(now+0s, 10, 2.0, 3.0) sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) +sql insert into ct2 values(now+0s, 10, 2.0, 3.0) +sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) +sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0) -print =============== step6: select data +print =============== step6: query data sql select * from ct1 sql select * from stb +sql select c1, c2, c3 from ct1 +sql select ts, c1, c2, c3 from stb + +print =============== step7: count +sql select count(*) from ct1; +sql select count(*) from stb; +sql select count(ts), count(c1), count(c2), count(c3) from ct1 +sql select count(ts), count(c1), count(c2), count(c3) from stb + +print =============== step8: func +sql select first(ts), first(c1), first(c2), first(c3) from ct1 +sql select min(c1), min(c2), min(c3) from ct1 +sql select max(c1), max(c2), max(c3) from ct1 +sql select sum(c1), sum(c2), sum(c3) from ct1 _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT - print =============== check $null= diff --git a/tests/script/tsim/valgrind/checkError3.sim b/tests/script/tsim/valgrind/checkError3.sim index d5a407f6f8..10a8f01fb3 100644 --- a/tests/script/tsim/valgrind/checkError3.sim +++ b/tests/script/tsim/valgrind/checkError3.sim @@ -68,16 +68,16 @@ sql select ts, c1, t1 from stb sql select ts, c1, t1 from stb_2 print =============== stepb: count -#sql select count(*) from c1; -#sql select count(*) from stb; -#sql select count(ts), count(c1), count(c2), count(c3) from c1 -#sql select count(ts), count(c1), count(c2), count(c3) from stb +sql select count(*) from c1; +sql select count(*) from stb; +sql select count(ts), count(c1), count(c2), count(c3) from c1 +sql select count(ts), count(c1), count(c2), count(c3) from stb print =============== stepc: func -#sql select first(ts), first(c1), first(c2), first(c3) from c1 -#sql select min(c1), min(c2), min(c3) from c1 -#sql select max(c1), max(c2), max(c3) from c1 -#sql select sum(c1), sum(c2), sum(c3) from c1 +sql select first(ts), first(c1), first(c2), first(c3) from c1 +sql select min(c2), min(c3), min(c4) from c1 +sql select max(c2), max(c3), max(c4) from c1 +sql select sum(c2), sum(c3), sum(c4) from c1 _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT From 6fd4684a26c1f13a51e90db6b144bb368a0a598a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Jul 2022 11:16:15 +0800 Subject: [PATCH 32/65] fix(query): ensure buffer before load data. --- source/common/src/tdatablock.c | 5 ++++- source/libs/executor/src/tfill.c | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f51023189d..9f5a247d76 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -542,8 +542,10 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) { } int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { - pBlock->info.rows = *(int32_t*)buf; + int32_t numOfRows = *(int32_t*) buf; + blockDataEnsureCapacity(pBlock, numOfRows); + pBlock->info.rows = numOfRows; size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); const char* pStart = buf + sizeof(uint32_t); @@ -589,6 +591,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { return TSDB_CODE_SUCCESS; } +// todo remove this int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) { pBlock->info.rows = *(int32_t*)buf; pBlock->info.groupId = *(uint64_t*)(buf + sizeof(int32_t)); diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index c008c7c4a9..959c03a3b1 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -53,8 +53,8 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) { // the first are always the timestamp column, so start from the second column. for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) { SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i); - if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) { - colDataAppend(p, rowIndex, (const char*)&ts, false); + if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) { // handle timestamp + colDataAppend(p, rowIndex, (const char*)&ts, false); } else { colDataAppendNULL(p, rowIndex); } @@ -83,15 +83,20 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* if (pFillInfo->type == TSDB_FILL_PREV) { SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev : pFillInfo->next; - for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; if (TSDB_COL_IS_TAG(pCol->flag)) { continue; } - SGroupKeys* pKey = taosArrayGet(p, i); SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol)); - doSetVal(pDstColInfoData, index, pKey); + + if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) { + colDataAppend(pDstColInfoData, index, (const char*)&ts, false); + } else { + SGroupKeys* pKey = taosArrayGet(p, i); + doSetVal(pDstColInfoData, index, pKey); + } } } else if (pFillInfo->type == TSDB_FILL_NEXT) { SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev; @@ -264,9 +269,8 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t assert(pFillInfo->currentKey == ts); if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) { - ++pFillInfo->index; - copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next); - --pFillInfo->index; + int32_t nextRowIndex = pFillInfo->index + 1; + copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, pFillInfo->next); } // assign rows to dst buffer From f02d8c2596f8386deecbc59ec9f5b4cb0c11c47a Mon Sep 17 00:00:00 2001 From: Xuefeng Tan <1172915550@qq.com> Date: Thu, 14 Jul 2022 11:19:31 +0800 Subject: [PATCH 33/65] enh(taosAdapter): update taosAdapter (#14858) --- tools/taosadapter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/taosadapter b/tools/taosadapter index c885e967e4..df8678f070 160000 --- a/tools/taosadapter +++ b/tools/taosadapter @@ -1 +1 @@ -Subproject commit c885e967e490105999b84d009a15168728dfafaf +Subproject commit df8678f070e3f707faf59baebec90065f6e1268b From 13519f8fd925a6fd3615ffcd49bc88fce605184c Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Thu, 14 Jul 2022 10:15:20 +0800 Subject: [PATCH 34/65] feat(stream): interval offset --- source/libs/executor/src/executil.c | 3 +++ source/libs/stream/src/streamUpdate.c | 2 +- tests/script/jenkins/basic.txt | 1 + tests/script/tsim/stream/sliding.sim | 8 ++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 2469062d09..4b8eed57d7 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -853,6 +853,9 @@ static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) { w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; } else { int64_t st = w.skey; + if (pInterval->offset > 0) { + st = taosTimeAdd(st, pInterval->offset, pInterval->offsetUnit, pInterval->precision); + } if (st > ts) { st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 3d64cec8d8..d0fb9c22e1 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -17,7 +17,7 @@ #include "ttime.h" #define DEFAULT_FALSE_POSITIVE 0.01 -#define DEFAULT_BUCKET_SIZE 1024 +#define DEFAULT_BUCKET_SIZE 131072 #define ROWS_PER_MILLISECOND 1 #define MAX_NUM_SCALABLE_BF 100000 #define MIN_NUM_SCALABLE_BF 10 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index dad4dbbe29..3fa0df5a7d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -114,6 +114,7 @@ # ./test.sh -f tsim/stream/schedSnode.sim ./test.sh -f tsim/stream/windowClose.sim ./test.sh -f tsim/stream/ignoreExpiredData.sim +./test.sh -f tsim/stream/sliding.sim # ---- transaction ./test.sh -f tsim/trans/lossdata1.sim diff --git a/tests/script/tsim/stream/sliding.sim b/tests/script/tsim/stream/sliding.sim index 750be7cb49..44f96cbefa 100644 --- a/tests/script/tsim/stream/sliding.sim +++ b/tests/script/tsim/stream/sliding.sim @@ -17,10 +17,10 @@ sql use test sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int); sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); -sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s) sliding (5s); -sql create stream streams2 trigger at_once watermark 1d into streamt2 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s) sliding (5s); -sql create stream stream_t1 trigger at_once into streamtST as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); -sql create stream stream_t2 trigger at_once watermark 1d into streamtST2 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); +sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s) sliding (5s); +sql create stream streams2 trigger at_once watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s) sliding (5s); +sql create stream stream_t1 trigger at_once into streamtST as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); +sql create stream stream_t2 trigger at_once watermark 1d into streamtST2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); sql insert into t1 values(1648791210000,1,2,3,1.0); sql insert into t1 values(1648791216000,2,2,3,1.1); From 3c755c483464c825a0afb19e6d135cbb15739ada Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 14 Jul 2022 11:41:34 +0800 Subject: [PATCH 35/65] opt:remove useless code --- source/libs/executor/src/executil.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 6b2bea273d..744dac85b9 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -307,7 +307,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagIndexCond = (SNode*)pListInfo->pTagIndexCond; if (pScanNode->tableType == TSDB_SUPER_TABLE) { if (pTagIndexCond) { - ///<<<<<<< HEAD SIndexMetaArg metaArg = { .metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid}; @@ -315,20 +314,9 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SIdxFltStatus status = SFLT_NOT_INDEX; code = doFilterTag(pTagIndexCond, &metaArg, res, &status); if (code != 0 || status == SFLT_NOT_INDEX) { - code = TSDB_CODE_INDEX_REBUILDING; - } - //======= - // SArray* res = taosArrayInit(8, sizeof(uint64_t)); - // // code = doFilterTag(pTagIndexCond, &metaArg, res); - // code = TSDB_CODE_INDEX_REBUILDING; - //>>>>>>> dvv - if (code == TSDB_CODE_INDEX_REBUILDING) { + qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); +// code = TSDB_CODE_INDEX_REBUILDING; code = vnodeGetAllTableList(pVnode, tableUid, pListInfo->pTableList); - } else if (code != TSDB_CODE_SUCCESS) { - qError("failed to get tableIds, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); - taosArrayDestroy(res); - terrno = code; - return code; } else { qDebug("success to get tableIds, size:%d, suid:%" PRIu64, (int)taosArrayGetSize(res), tableUid); } From b1cdc7ff3cb3099aaeefb5fb659889d5b5cc08a7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 11:42:55 +0800 Subject: [PATCH 36/65] test: valgrind case --- tests/script/tsim/insert/basic0.sim | 163 +++++++++++--------------- tests/script/tsim/insert/basic1.sim | 41 ++----- tests/script/tsim/valgrind/basic1.sim | 70 ++++++----- 3 files changed, 116 insertions(+), 158 deletions(-) diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim index 722bc0f907..6de904eca1 100644 --- a/tests/script/tsim/insert/basic0.sim +++ b/tests/script/tsim/insert/basic0.sim @@ -32,7 +32,6 @@ if $rows != 3 then return -1 endi - print =============== insert data, mode1: one row one table in sql print =============== insert data, mode1: mulit rows one table in sql #print =============== insert data, mode1: one rows mulit table in sql @@ -41,9 +40,6 @@ sql insert into ct1 values(now+0s, 10, 2.0, 3.0) sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) sql insert into ct2 values(now+0s, 10, 2.0, 3.0) sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) -#sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4) -#sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) - sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0) #=================================================================== @@ -67,16 +63,6 @@ endi if $data03 != 3.000000000 then return -1 endi -#if $data41 != -14 then -# return -1 -#endi -#if $data42 != -2.40000 then -# return -1 -#endi -#if $data43 != -3.400000000 then -# return -1 -#endi - print =============== select count(*) from child table sql select count(*) from ct1 @@ -107,10 +93,10 @@ if $data03 != 4 then endi #print =============== select first(*)/first(column) from child table -#sql select first(*) from ct1 -#print ====> select first(*) from ct1 -#print rows: $rows -#print $data00 $data01 $data02 $data03 +sql select first(*) from ct1 +print ====> select first(*) from ct1 +print rows: $rows +print $data00 $data01 $data02 $data03 sql select first(ts), first(c1), first(c2), first(c3) from ct1 print ====> select first(ts), first(c1), first(c2), first(c3) from ct1 @@ -217,23 +203,23 @@ if $data32 != -3.300000000 then return -1 endi #=================================================================== -#=================================================================== #print =============== query data from stb -#sql select * from stb -#if $rows != 4 then -# return -1 -#endi +sql select * from stb +print $rows +if $rows != 9 then + return -1 +endi #print =============== select count(*) from supter table -#sql select count(*) from stb -#print $data00 $data01 $data02 -#if $rows != 1 then -# return -1 -#endi -#if $data00 != 9 then -# return -1 -#endi +sql select count(*) from stb +print $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi print =============== select count(column) from supter table sql select ts, c1, c2, c3 from stb @@ -264,28 +250,23 @@ if $data03 != 3.000000000 then endi #print =============== select count(column) from supter table -#sql select count(ts), count(c1), count(c2), count(c3) from stb -#print rows: $rows -#print $data00 $data01 $data02 $data03 -#print $data10 $data11 $data12 $data13 -#print $data20 $data21 $data22 $data23 -#print $data30 $data31 $data32 $data33 -#if $data00 != 9 then -# return -1 -#endi -#if $data01 != 8 then -# return -1 -#endi -#if $data02 != 8 then -# return -1 -#endi -#if $data03 != 8 then -# return -1 -#endi +sql select count(ts), count(c1), count(c2), count(c3) from stb +print rows: $rows +print $data00 $data01 $data02 $data03 +if $data00 != 9 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != 9 then + return -1 +endi +if $data03 != 9 then + return -1 +endi #=================================================================== -#=================================================================== - print =============== stop and restart taosd, then again do query above system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start @@ -326,16 +307,6 @@ endi if $data03 != 3.000000000 then return -1 endi -#if $data41 != -14 then -# return -1 -#endi -#if $data42 != -2.40000 then -# return -1 -#endi -#if $data43 != -3.400000000 then -# return -1 -#endi - print =============== select count(*) from child table sql select count(*) from ct1 @@ -366,10 +337,10 @@ if $data03 != 4 then endi #print =============== select first(*)/first(column) from child table -#sql select first(*) from ct1 -#print ====> select first(*) from ct1 -#print rows: $rows -#print $data00 $data01 $data02 $data03 +sql select first(*) from ct1 +print ====> select first(*) from ct1 +print rows: $rows +print $data00 $data01 $data02 $data03 sql select first(ts), first(c1), first(c2), first(c3) from ct1 print ====> select first(ts), first(c1), first(c2), first(c3) from ct1 @@ -474,24 +445,23 @@ endi if $data32 != -3.300000000 then return -1 endi -#=================================================================== -#=================================================================== -#print =============== query data from stb -#sql select * from stb -#if $rows != 4 then -# return -1 -#endi +#=================================================================== +print =============== query data from stb +sql select * from stb +if $rows != 9 then + return -1 +endi -#print =============== select count(*) from supter table -#sql select count(*) from stb -#print $data00 $data01 $data02 -#if $rows != 1 then -# return -1 -#endi -#if $data00 != 9 then -# return -1 -#endi +print =============== select count(*) from supter table +sql select count(*) from stb +print $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi print =============== select count(column) from supter table sql select ts, c1, c2, c3 from stb @@ -521,20 +491,19 @@ if $data03 != 3.000000000 then endi #print =============== select count(column) from supter table -#sql select count(ts), count(c1), count(c2), count(c3) from stb -#print $data00 $data01 $data02 $data03 -#if $data00 != 8 then -# return -1 -#endi -#if $data01 != 8 then -# return -1 -#endi -#if $data02 != 8 then -# return -1 -#endi -#if $data03 != 8 then -# return -1 -#endi +sql select count(ts), count(c1), count(c2), count(c3) from stb +print $data00 $data01 $data02 $data03 +if $data00 != 9 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != 9 then + return -1 +endi +if $data03 != 9 then + return -1 +endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/insert/basic1.sim b/tests/script/tsim/insert/basic1.sim index d98407b380..6d31dcdffb 100644 --- a/tests/script/tsim/insert/basic1.sim +++ b/tests/script/tsim/insert/basic1.sim @@ -1,9 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 50 sql connect - print =============== create database sql create database d1 sql show databases @@ -17,7 +15,6 @@ sql use d1 print =============== create super table, include all type sql create table if not exists stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(16), c9 nchar(16), c10 timestamp, c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned) tags (t1 bool, t2 tinyint, t3 smallint, t4 int, t5 bigint, t6 float, t7 double, t8 binary(16), t9 nchar(16), t10 timestamp, t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned) - sql create stable if not exists stb_1 (ts timestamp, i int) tags (j int) sql create table stb_2 (ts timestamp, i int) tags (j int) sql create stable stb_3 (ts timestamp, i int) tags (j int) @@ -36,11 +33,6 @@ if $rows != 2 then return -1 endi - -print =============== insert data, mode1: one row one table in sql -print =============== insert data, mode1: mulit rows one table in sql -print =============== insert data, mode1: one rows mulit table in sql -print =============== insert data, mode1: mulit rows mulit table in sql sql insert into c1 values(now-1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) @@ -69,32 +61,15 @@ if $data03 != -2 then endi print =============== query data from st, but not support select * from super table, waiting fix -#sql select * from st -#if $rows != 4 then -# return -1 -#endi +sql select * from stb +if $rows != 4 then + return -1 +endi print =============== stop and restart taosd system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - print =============== query data sql select * from c1 print rows: $rows @@ -119,9 +94,9 @@ if $data03 != -2 then endi print =============== query data from st, but not support select * from super table, waiting fix -#sql select * from st -#if $rows != 4 then -# return -1 -#endi +sql select * from stb +if $rows != 4 then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index f0430195c9..784b83d96b 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c debugflag -v 131 -system sh/exec.sh -n dnode1 -s start -v +system sh/exec.sh -n dnode1 -s start sql connect print =============== step1: create drop show dnodes @@ -23,51 +23,65 @@ if $data(1)[4] != ready then endi print =============== step2: create db -sql create database d1 vgroups 1 buffer 3 +sql create database d1 vgroups 3 buffer 3 sql show databases sql use d1 sql show vgroups -print =============== step3: create show stable -sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) +print =============== step3: create show stable, include all type +sql create table if not exists stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(16), c9 nchar(16), c10 timestamp, c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned) tags (t1 bool, t2 tinyint, t3 smallint, t4 int, t5 bigint, t6 float, t7 double, t8 binary(16), t9 nchar(16), t10 timestamp, t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned) +sql create stable if not exists stb_1 (ts timestamp, c1 int) tags (j int) +sql create table stb_2 (ts timestamp, c1 int) tags (t1 int) +sql create stable stb_3 (ts timestamp, c1 int) tags (t1 int) sql show stables -if $rows != 1 then +if $rows != 4 then return -1 endi -print =============== step4: create show table -sql create table ct1 using stb tags(1000) -sql create table ct2 using stb tags(2000) -sql create table ct3 using stb tags(3000) +print =============== step4: ccreate child table +sql create table c1 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql create table c2 using stb tags(false, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 2', 'child tbl 2', '2022-02-25 18:00:00.000', 10, 20, 30, 40) sql show tables -if $rows != 3 then +if $rows != 2 then return -1 endi print =============== step5: insert data -sql insert into ct1 values(now+0s, 10, 2.0, 3.0) -sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) -sql insert into ct2 values(now+0s, 10, 2.0, 3.0) -sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) -sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0) +sql insert into c1 values(now-1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql insert into c2 values(now-1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql insert into c2 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) -print =============== step6: query data -sql select * from ct1 -sql select * from stb -sql select c1, c2, c3 from ct1 -sql select ts, c1, c2, c3 from stb +print =============== step6: alter insert +sql insert into c3 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) values(now-1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql insert into c3 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) -print =============== step7: count -sql select count(*) from ct1; +print =============== restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start -v + +print =============== stepa: query data +sql select * from c1 +#sql select * from stb +#sql select * from stb_1 +#sql select ts, c1, c2, c3 from c1 +#sql select ts, c1, c2, c3 from stb +#sql select ts, c1 from stb_2 +#sql select ts, c1, t1 from c1 +#sql select ts, c1, t1 from stb +#sql select ts, c1, t1 from stb_2 + +print =============== stepb: count +#sql select count(*) from c1; #sql select count(*) from stb; -#sql select count(ts), count(c1), count(c2), count(c3) from ct1 +#sql select count(ts), count(c1), count(c2), count(c3) from c1 #sql select count(ts), count(c1), count(c2), count(c3) from stb -print =============== step8: func -#sql select first(ts), first(c1), first(c2), first(c3) from ct1 -#sql select min(c1), min(c2), min(c3) from ct1 -#sql select max(c1), max(c2), max(c3) from ct1 -#sql select sum(c1), sum(c2), sum(c3) from ct1 +print =============== stepc: func +#sql select first(ts), first(c1), first(c2), first(c3) from c1 +#sql select min(c2), min(c3), min(c4) from c1 +#sql select max(c2), max(c3), max(c4) from c1 +#sql select sum(c2), sum(c3), sum(c4) from c1 _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT From 1657df208d6e34ac1524f22d27d1599457355d25 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 13:40:52 +0800 Subject: [PATCH 37/65] test: restore some 2.0 case --- tests/script/jenkins/basic.txt | 18 +++++++++--------- tests/script/tsim/tag/4.sim | 16 ++++++++-------- tests/script/tsim/tag/5.sim | 20 ++++++++++---------- tests/script/tsim/tag/6.sim | 24 ++++++++++++------------ tests/script/tsim/tag/bigint.sim | 5 ++--- tests/script/tsim/tag/binary.sim | 5 ++--- tests/script/tsim/tag/binary_binary.sim | 4 ++-- tests/script/tsim/tag/bool.sim | 7 +++---- tests/script/tsim/tag/bool_binary.sim | 4 ++-- tests/script/tsim/tag/bool_int.sim | 4 ++-- tests/script/tsim/tag/double.sim | 4 ++-- tests/script/tsim/tag/float.sim | 4 ++-- tests/script/tsim/tag/int.sim | 5 ++--- tests/script/tsim/tag/int_binary.sim | 4 ++-- tests/script/tsim/tag/int_float.sim | 4 ++-- tests/script/tsim/tag/smallint.sim | 5 ++--- tests/script/tsim/tag/tinyint.sim | 5 ++--- 17 files changed, 66 insertions(+), 72 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index af0e338c9b..78dec01a74 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -283,21 +283,21 @@ ./test.sh -f tsim/tag/3.sim ./test.sh -f tsim/tag/4.sim ./test.sh -f tsim/tag/5.sim -./test.sh -f tsim/tag/6.sim -./test.sh -f tsim/tag/add.sim +#./test.sh -f tsim/tag/6.sim +#./test.sh -f tsim/tag/add.sim ./test.sh -f tsim/tag/bigint.sim ./test.sh -f tsim/tag/binary_binary.sim ./test.sh -f tsim/tag/binary.sim ./test.sh -f tsim/tag/bool_binary.sim ./test.sh -f tsim/tag/bool_int.sim ./test.sh -f tsim/tag/bool.sim -./test.sh -f tsim/tag/change.sim -./test.sh -f tsim/tag/column.sim -./test.sh -f tsim/tag/commit.sim -./test.sh -f tsim/tag/create.sim -./test.sh -f tsim/tag/delete.sim -./test.sh -f tsim/tag/double.sim -./test.sh -f tsim/tag/filter.sim +#./test.sh -f tsim/tag/change.sim +#./test.sh -f tsim/tag/column.sim +#./test.sh -f tsim/tag/commit.sim +#./test.sh -f tsim/tag/create.sim +#./test.sh -f tsim/tag/delete.sim +#./test.sh -f tsim/tag/double.sim +#./test.sh -f tsim/tag/filter.sim ./test.sh -f tsim/tag/float.sim ./test.sh -f tsim/tag/int_binary.sim ./test.sh -f tsim/tag/int_float.sim diff --git a/tests/script/tsim/tag/4.sim b/tests/script/tsim/tag/4.sim index 0bb1cde75d..fcdb146fb9 100644 --- a/tests/script/tsim/tag/4.sim +++ b/tests/script/tsim/tag/4.sim @@ -675,27 +675,27 @@ if $data00 != 25 then endi print =============== step24 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol1 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol2 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol3 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 partition by tgcol4 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/5.sim b/tests/script/tsim/tag/5.sim index e3edbcaa5d..92695ddfcf 100644 --- a/tests/script/tsim/tag/5.sim +++ b/tests/script/tsim/tag/5.sim @@ -792,33 +792,33 @@ endi print =============== step27 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol1 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol2 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol3 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 partition by tgcol4 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 partition by tgcol5 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/6.sim b/tests/script/tsim/tag/6.sim index d4e1d52c3c..4f7f5b88d1 100644 --- a/tests/script/tsim/tag/6.sim +++ b/tests/script/tsim/tag/6.sim @@ -941,39 +941,39 @@ if $data00 != 25 then endi print =============== step31 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol1 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol2 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 partition by tgcol3 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 partition by tgcol4 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 partition by tgcol5 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 partition by tgcol6 interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/bigint.sim b/tests/script/tsim/tag/bigint.sim index 2e1af227c0..813387eb38 100644 --- a/tests/script/tsim/tag/bigint.sim +++ b/tests/script/tsim/tag/bigint.sim @@ -221,11 +221,10 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/binary.sim b/tests/script/tsim/tag/binary.sim index 2cabf30bb1..6ede988954 100644 --- a/tests/script/tsim/tag/binary.sim +++ b/tests/script/tsim/tag/binary.sim @@ -221,11 +221,10 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/binary_binary.sim b/tests/script/tsim/tag/binary_binary.sim index 8a77de5226..071b457b44 100644 --- a/tests/script/tsim/tag/binary_binary.sim +++ b/tests/script/tsim/tag/binary_binary.sim @@ -290,9 +290,9 @@ if $data00 != 25 then endi print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/bool.sim b/tests/script/tsim/tag/bool.sim index 26e320c41e..356269e1e1 100644 --- a/tests/script/tsim/tag/bool.sim +++ b/tests/script/tsim/tag/bool.sim @@ -218,12 +218,11 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/bool_binary.sim b/tests/script/tsim/tag/bool_binary.sim index d776127757..3fcb085e37 100644 --- a/tests/script/tsim/tag/bool_binary.sim +++ b/tests/script/tsim/tag/bool_binary.sim @@ -290,9 +290,9 @@ if $data00 != 25 then endi print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/bool_int.sim b/tests/script/tsim/tag/bool_int.sim index daeb0c711f..2ff640b329 100644 --- a/tests/script/tsim/tag/bool_int.sim +++ b/tests/script/tsim/tag/bool_int.sim @@ -306,9 +306,9 @@ if $data00 != 25 then endi print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/double.sim b/tests/script/tsim/tag/double.sim index 3f936318fb..fedc1c89ec 100644 --- a/tests/script/tsim/tag/double.sim +++ b/tests/script/tsim/tag/double.sim @@ -223,9 +223,9 @@ endi print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/float.sim b/tests/script/tsim/tag/float.sim index 215869e003..0ed12d2269 100644 --- a/tests/script/tsim/tag/float.sim +++ b/tests/script/tsim/tag/float.sim @@ -223,9 +223,9 @@ endi print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/int.sim b/tests/script/tsim/tag/int.sim index d97079de91..e561cde56a 100644 --- a/tests/script/tsim/tag/int.sim +++ b/tests/script/tsim/tag/int.sim @@ -221,11 +221,10 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/int_binary.sim b/tests/script/tsim/tag/int_binary.sim index fef77a16d9..01d73cf0c2 100644 --- a/tests/script/tsim/tag/int_binary.sim +++ b/tests/script/tsim/tag/int_binary.sim @@ -290,9 +290,9 @@ if $data00 != 25 then endi print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/int_float.sim b/tests/script/tsim/tag/int_float.sim index f184fdce0c..0b20ff3d62 100644 --- a/tests/script/tsim/tag/int_float.sim +++ b/tests/script/tsim/tag/int_float.sim @@ -306,9 +306,9 @@ if $data00 != 25 then endi print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/smallint.sim b/tests/script/tsim/tag/smallint.sim index cb65a93d5f..47e28db46c 100644 --- a/tests/script/tsim/tag/smallint.sim +++ b/tests/script/tsim/tag/smallint.sim @@ -221,11 +221,10 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi diff --git a/tests/script/tsim/tag/tinyint.sim b/tests/script/tsim/tag/tinyint.sim index c6d9df2597..0941c9cf18 100644 --- a/tests/script/tsim/tag/tinyint.sim +++ b/tests/script/tsim/tag/tinyint.sim @@ -221,11 +221,10 @@ if $data00 != 25 then return -1 endi - print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt partition by tgcol interval(1d) print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then +if $data00 != 100 then return -1 endi From 91a59257348752373cfa9e50edb53519b19ec204 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 13:41:43 +0800 Subject: [PATCH 38/65] test: restore some 2.0 case --- .../script/general/connection/connection.sim | 21 ------------ tests/script/general/connection/mqtt.sim | 19 ----------- tests/script/general/connection/sim.tar.gz | Bin 9104 -> 0 bytes .../general/connection/test_old_data.sim | 32 ------------------ tests/script/jenkins/basic.txt | 4 +-- 5 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 tests/script/general/connection/connection.sim delete mode 100644 tests/script/general/connection/mqtt.sim delete mode 100644 tests/script/general/connection/sim.tar.gz delete mode 100644 tests/script/general/connection/test_old_data.sim diff --git a/tests/script/general/connection/connection.sim b/tests/script/general/connection/connection.sim deleted file mode 100644 index 1af6e1fda6..0000000000 --- a/tests/script/general/connection/connection.sim +++ /dev/null @@ -1,21 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -print ============= step1 -sql close -print close1 -sql connect - -print ============= step2 -sql close -sql connect - -print ============= step3 -sql close -sql connect - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/connection/mqtt.sim b/tests/script/general/connection/mqtt.sim deleted file mode 100644 index c2c50ef17e..0000000000 --- a/tests/script/general/connection/mqtt.sim +++ /dev/null @@ -1,19 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000 -system sh/cfg.sh -n dnode1 -c http -v 1 -system sh/cfg.sh -n dnode1 -c mqtt -v 1 - -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect -sql create database mqttdb; -sql create table mqttdb.devices(ts timestamp, value double) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16)); - -sleep 1000 -system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/connection/sim.tar.gz b/tests/script/general/connection/sim.tar.gz deleted file mode 100644 index 10bc1a6bace1c8b6796a98c53e3aa3c15e0bfd7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9104 zcmbWbbx>7b^zcmySGtiF5ou8bK|rpQw1i5-1?iAbTHp{;(k&pZh%`voC8PvNB^8kF zh6~)-4_}|(yzgJ{JM%ne&diy;*WPQ+teVeSoKY~me-GidDMdW}uPo@EG+OR!CE1N& z72pR)PRamZ&!8hqzuR>eq_aZjFjPcseS88bU*Z!Pey^*2TaNXpS zn$m0i&%D;(<3tNz8Qcm;{-o4>DE2uuLq-I%zWPiZtW8f+e&Rq#FEN5E9&VMhp!Qe{%3jR_IM!*dD=X^C&Yt=@QDbdM3cl{&2DcdLxIH_14({jF#l3~*E z@VK5@)q}hy;C`?Wn93H*Q`@byLrvh?aIgBR*keAnz$iO~#=pPZJQ~EPhk1yd_=APq zru*XAX;c!v=RFokaz|eaqAzE2Fc!5*dvpEM4FwBUmiW3&-zIsZ$Y<5MjkMD4t@1_e zr_W&@HD>OkKlVjN3#-yLn5@9Qrl?8_CUu?~ibb)FKedht`}|g1mA(F{cs7;7=J00L z+rFM(G&{u~Qm0>X-FzK+GTKqbtQlh^VV9orC7PJ1ib}#=xOjE(f>=CLn37N+Ma-Vo z{iTDquydo5tm0FOS6A)&N<5c;p4oUCrK!KSr~Kk3&OGt`D`!v4+%5Et)W$!Ctigd~ zg(beX9b-s)Q?$KaatwWZWzRR!PR-M2awC=PS@<|!FblAL6x_d=ZYLR zZd5-aEw=IE?Q$HbcGlbV>Tprry;4fi>0lx#7?;`-Fy7Oq8B+2l%~dC&rln6((8xsH z&esO@%ZNp=$l%q~P4|?-aN~y5*xpV7nfpeMxr!*qJxY zW`6xZDV^;OEI^V{ErtVDmS1jqu0@Xb?SH?FZkD;?vi6Xp9ac*ThbcoCjn~6ZC2ot^ z-LYY;8mjvm<{m;%WDb3LJAQhJ3CH~Ts6DbNFeM$;J>(tm%EN&-Ci9~j?VT^1w^@q^ zQLK$>wl%J$H5y-tJO?wJZ@6_yxt86}@8&XFd~}QT{Q7DOzNod8`?^CES?u*p@Rd95 z`!el$g9=ai^RH4vwz6vRt>XQ5r1GX@GWpIlEHN9Eqz>h?ehl0PeiFBKS_fI=OX>f6 zi|FO=C}6njy*39EZ;7y-fC#RmT6a9k3(h&bv{;}hL#X{8hayk}amy!7*Y8wi>$)aG z-dUzgMD19N2tEBY3ZbRV4(Kw)pS(MDC&BaWU_GRcub| z!!e`^T-w0jD}|u-Q7##%8J?bx`xWGJOnPIJ{3)T<-0Q8CU;WU_oUlJ}fWh#^DU{uQ z1t@W_b)0_GxLBA}X5)bq@J1;DhSXM@eyEACsw|k*12E&=;26 z5!l8eZ6(8XR{M^@$6ia@bEq~2NL3KH9^jN|La&zsvg#8s*PacyJ^s+-`r@Km_&P7N z3=CELvU+8rQ7Pg(7T(&>6gL4h;~WuKmOVI{_vj|eU8w!*h01j-2;wa zvBZ-5i1?6qp&-vZ;<5_w+ekaeQ9blKGX56_BN@nSv-@PieOXX-<_rYajNE~d$#O7h zQ|%|j8+Z*qE~IGSB=5>3khIFZQk%DWe|w_y@8=0m%+LFDKNL)OXS7~~Oc8#)TlSK& z36_Oh+6c8B4q49_;kD`HwrOg^Q-dYLIJxYI85bdQkIuh+GpfWEwmemFdvyC+!>{Lk zPwI}i9?><`Pe*Jz-&3o!X5zbhXZMwplpjZo+hMyQn6yDtxQ+q8X*3k7{~jC8Yqudk zh-}nw{31~;`fGvvRWe`EnkovaA0*zl}1~M^BJ`XM<-`4z;^C?}* z4qV_na;ugTkK{ZpIQT^h$o)0}e8PNY>%hcjU0W^91B-oH;T(;$4qQD2e4JTABgS@N z06x24kRD*0j@nplo!-8_z~uBcv(2G_>b?6t$$SJIflb6MKaVb`-xXmVi8^{sjIsHB z$CT-Mt0pmatatAQ%2w*O=wW?r|Df`{erXNtaCr5fM3Gez(ST+2@AYrW zc{d*16TJWd=igG=DB7ASPt4bLTa{<1~%3z zHzbGRp}zP|0sG`Os}|;l3M_aZ6@YI-8DG^$@RKXQFt*Wdj#wVEH5%$R^JK&EgP*iG ztIe++_q@Mm9?}dHsN&g;T)B#-tho;rJ)1KdTuaceonxKlh(yl|BM%(h%)0~s_Y;In zC3*eRqQH=O>4rG*r)%HQ!5u4S!zVK$f#Vn|CtT?f^7>bRB3Cz#RgT*7WlCMMbizq& z97usR){Tn_%voGHa1futJC2k6E$xJWzy{4Wx8>Z)FvkOYi@fv^+4Exi&`LOp)&K6> zm~tuk&Tl`^n1ZxZ7RO$@VzG(#YTio0n79kL=W2>V%$K}=suEnBm?t*85yV|qV%%Q# zWdZO{HxXr4pV+u|rxR=rfr3-GH&OcqBw{`c9X5*^HE+Q2?|2KLwdAPF<{=_aT&BdG zZJF~wL{UliAzEF5><$sTa{`%F}K_0t`vURhCYBjVLb9$6K;YkHL5 zL?_Oe6hd!vu#F^kReh{$C}Nk#qx5=wKd1*5O6W@Sl24*Vs@&*F>RRKsKw+hLp4+U< z)!YR9x(|M;SSLDja>sY3D7;kf*?vX!@tGB$lLFzGo~f3;ieQ48o`C*~@N#`vZC4v< zP_pW*O%DBogeo3Yg0vDgi#kzzTWj4Z*(jR?OW)$s(f#DgTVIwui+heNRIrAvNz~H~ zQu(GS?@u$x1bd7kr_a(zUS`D8QH7?xHY_DsF6Ollx&4)fK45qnSZun#p1o zW$c_lHTo>%!@-!f@{<^s`=1wVG87z4G{b5Sx5M2E>igUJIvzi`PlV5;p?_jB!NL$L zn72D4^FeiGOuICQOD(=pQRqPtWw*F1FY^H1Pg74KgQ1R%M+QmcEW|SB;q6pobV|exdMyxnF#YKX9x8x7^RauL{h#9Z2EuU4-x+G5&J*pvt9#t(VQ;Y)xh?xZ8KE; z2R^-<^Ar|)@!t)pb;z60L<&deBS{;-0a2MxgQwK*4Yc?rzeDV&cph*-c17tFJ52Yi z7tCC)7m(MJ4-g6R8sJUvsC{4DZJoA>@%89C-mz;US_8+&vQ1!(IEna;&0#VuN~T}l ze_!!*ko-)C)z{+usUT~jTUb+`6c#bdk^AHVSp#_YAo*CqgWFJR5E*X#2w}R1zb=VOQ%FU@3D^iP(L-7CaLDpask6=mjfQVT_zckY z#7P8XM^?16b!k;>cxCViVUgJ1wE~BsBPDOLeTShKjlBYHY` zjK6{9ogX{c2~!$QL}TC&_XDfKnJ85GIdQoj2tu;%1=6JvP(F<3io*5&1pk4KIT~nb zCT|0T5Qs4bF4^Gbm5^<81#jgVvJtpsjTL1BcOYSCu?27Gc#o+F*^y{x06giJa5IRT zr;F|fQd0qhfgP5!kl@4-AWFyri&xdQksaUC3c$z{h(4^nQ;7M8OaVBiXHyq0E(?QT#tDf}iD6o(X(9Y5@`pMkR=Blbr|?9OF8!Pl3Wuawb+jc9d@?$0w=x`X8iW8VV;l z`_W+0M5$aZ;Uc=8CL6%i2p@M#NPr*ldBbDpl`kXoT)WQru)9TZGtw+*@3Wc7EW%G> z6Ay88@XI&n0N8H0aEx&57(R)MtLNaRdf|4rZRW`hh$~-PDW&2}uHs9|ZHfBgM3l=lf^J^e4RXFODdw%UPuPiA; ze|o|wKn?JgAHUrH<55H+?X~xCEX>;kVpmawOZ|?_z}TJhmG^GgB~PqYII}(s@nMK* zt89sHUB&g*FOgPGz~sMVmfNGOGy2ij+8BN?8jX^Uh7Y+F*>kY0XmW-AuyPZE{Su@G3A`i7}UwM%-gi>F7T7A|mc~^th)QVrhBy%k-TR z=g(ySam*LH2K_%zNGNlYPz1r(3KdRJ@L=?N-_qeE77)f8+e&`~pHT-`~k$k2nKUn57E6sFdTxo>Lx zZW)IA+E-M0Mi;7CQV6{vXdXK&0+zOB4}QL9$-q=@0+oVch@O54qg;pUqMJHGiX^Gu zvh0^)CwzQ{_;U{Z#F4-&ar0zTM>&}C=n3Zwt;-H(0QZzyaSO#6lm%8PNY{`|(QW^? zDD!;?Vxmv)znmoXA>Edn|A9=TlDc-Ey z+8=Hy@6joC8n++5eU77}$N@=5IU%B%;0?hW+@$?q>9=z0kx1?(JR#9tp2jXg*UY<<^k`C^4lFXf6;tU zGU35xTvzSsJ2bh-9Lsps27uFzt3;=HIRZ9FI9bnk?@hSOzP;yu z$5bCXQs%YxnxyrHilYC=j*4D~XhP3y=kF6NWTktQKUuCCO3leUa}>ij5fL6WIvR^! zvM*B|#xt*dGpk)zRkPTZP;$;~!D~4n0sm*ikd8JCD5;vyLo#wSpldYjDCawp zPhcCPd^sJ43k7X;QF&+*UXuyK#_=)Df@|}Dp$<3C>h3mbaI2(3&C5{x>{^d?t*Zbt z|B}HHyfl(SR&SF3G3+PQX8DC`eI=pRaUgQQ&cZNy_a~U4x7IBt{+aC+!MCQ`>EV< z9F{*blhbURsrxQSTZJEfg>LlO)wLszYuiT_IqWbwgP`2Eg_ufRDd=}~%*9USn`>zu-n*__d#miB6w-0UZ{}5! zyov_7ug9l>+SZO(YmF;$pQc&1VUOhzY$(EtNWLSLHr3M_sXOeb`fEXOh+7 zF`(z^b@G_Y_^a`Qjt`91D-&nI)&s8^Nb)n7P>MG84EQ*_Rq zAB`K>hN4YjnVqdFpXB(a@(Nd!V}4Iof6TMq_;B&KqK*slP30GK2%q`V(=-Wb#pvSy z;xO!oiGSG`Wh~#Drh>?XQ`tl0cIV=+=9Zo3+-%1TuXSN_*n_HYbU1LB7N!RbHvvEC z8OZw;hXxOV2T$hH>g(k_Hxa4gXf0$gcAmyy0^)cUw1WbHZ0)!`n9vrSO152S0^E4X zMvR6lC5+;FX+E9-2f7h7lP{3pLv+DX5C5H6hPU89$pWhG#C*9JF9KqK$dCBrYtT^* z);dVuV^0w6B7aeka=a;aZIy5^AE$J;498$7cfJR^7>LZ&&}%c&w|h(-yL5b9B;w53 z5lzf=m*s4bRx*KA-7ZKh$B;vUpW8MA@!>gj4~>t4=OJ8z(_HTmZjG_sgNTwrZ2MD% z5iohDJ2ERybGRI=o!U>~Fo=WxBCr8-`U&OGGqPes_VKMA0Mr%oJxFmn91Tf^weDd( zLk`TYkpy#5*?V=*pW*iWim5;c=4V%Q&!*wjtFEsY-ybJ$g1<3bXOd_+3qmhnd6_a& zxp4MC{ywMF$8bqhg@=SBcZ8fJ_2GOS6}9@g$fp4a9|@$wTx4W<+>OUh#01c3c^J;a zv;C|$ds<20HwaG~!jEvi%&>yxF1o#*b^Gq*r!zjC$Q*w?)ZdPr<>WX{fj=hg8eC2m z|FoJL??DZiUKBhQ9}6h8E*+q`3qogseu5&h4peaNz}bU*u=fDuqsEQCSi>Rw-cik8 zIv9Tot~L8;wiwDO-2fq2kqHpf8+ejK^2Y`5*?#-Q{5v_EVE$Vil1=U%PNL{6pIFi% zuz>iivLo=)r%m&CWalEVM5p(FzxuyJL2_U=+~3#Rq8<02ia_j14nhv?Vry;+8aDz6 zg*Fk#=L`ivAHrKfa(jOcPL2;5eu#0-W0sSotUYtoX_LM^2?8SN1S8rYNh)fTDnWCM zqtt@4Ho3^*2=Bv6l)W2stN!9ApeDGEtk$uTInYZGHgckFwiVlsmkQIkv4(Ri&u|$= z^Q$++ecC#Vf097=mz&5oH^VGwA~NlF@8BY*Lk}|Ngji85w_yL(mX3fE;eVFI+|7p~it{(UJcaE(cv_e!2#N z0wZv6cDdA(dEW5up7!hRaJ=aONDn09sS_jvO8gUe7_aCSWVH?IUc&J%Th7y{cU1sw z{S&+*U(&BQ|9UXjsrxlPBJXXYmh#ynz=U~s$RHsU)1j4{`GDc6p}{U|4BAD=hL8y3 zfU`&D&*%JD|INz`G8Qbf0<}IEHKd-P=_n4&te@EY5pp&t5794LWXuZat=gG6U-_;o z1(m$J#@WrXS9wf=kmE64n*Ja(8EQLn)c^G;GjZ6LdBl?7p<2#F1w?~gy?=7vw8{_n z#(YxGglBdP%gDG#&2H#;CL0i(1yyH}uI%f1{zbJ^`7yc0V7KPJz(L=R+o*9G<2I|Z z2?MwCGrd2r)Vp4-yk;qf=+7dzI5ndt)zwn9rsYlaPvlxSNypR|pQP1n+4_aAH8D2U z?UfhQJ4);da}x+7)ovsxqn-sx6t4yt#d52_MSj4sMS!-f#Pv+$b#Uuqp{1i8{x$Wt z@#UIc`VCD{wWz!D{LI3siRp<^CaA>xgO3RFw^eXs+{Z1WjcbSQyj%z~IhEwPGL;BQ zDxwb}SYn6if*(q^64fH`ZnI~TF>WSIM5tF% z$0}yHZilJe0n2-?IRW8+01raH@Pv2vTerrZt`RoiSP#9`&xQ$q;{;{F(kbGTFKghz zsFHHHI9bl9AFJor*W2F{y7q;{=wxq++}4so3)agrc76RT?SYJ7-?ch-*R)c4 zH`6^o%&i<8?33JXt!lo*BX(?&3|@xTg3B31Uw{<(0vbVLZU!j+v?i#$xvAycUUM-# z1UM%_0uggB#Cs{4*(-J3Ee0&P!6ajVUa9{KtE>oIh8|4<(V6dohGI?c7xwZX_A zBKNP#w=O!8PogsvzqIvNgl*1d1UpztQj_w_B7}=$a5*mmagc3IZ#qsy@SO#QDuQ$u zEW>EAP>@YR=eGV}sTQqnaAugD*J|m@sBdKo4oUnAREfG`oQbN8w}|bN{AF|ty{+CH z^!duzA>~C+pg#;2?vX45;Y63sRbui4@V`{J1gpW#bJ%a_JQW&tx43R-oNs6pIbE;V z6|iwV8jC!-We5iBzz%HivYv$j^3$z(UiBid1{0lxKRgt}qr%{ni5!Q|E)evOz^ur- zGi>i&4eo=z%H-?2y9_=$H_A)+*d<3W@3Ik@JK7ApCo`3KYnb{K zMtw#muzm1vnAJFKWV*V=m_*k#Px>lHz5!+u$m@HlkX-FwIa;rk+)(!BgZ7a0jNMrg za3J!U2_fBj{1Nn7d#xM5TS3b^0X<#VrOvi}$_C1UYr zc5K_L^AjhZ@AR>sSJc$vK0m)S!V3KOrSei5@3sc7_EF%ADZGO#|qfL586Ok4cj!*x%FPZUb3fmH{SZ|xYv zKkQ}fwX`K|MeO+9sBNA4uB9X2pWpXLv=~ADt$?AB?jaTTwD_`xN6oH#z@hntzJlx# zUO?n+YJZnkc*}pCa!sz7vAzh7Yzz+I-JOrHSW5CWYgFfc!XJ0C+@2LHy0{TpTZKkv*G=mGrtJARpJK<>J~q z^ZLL3zZ50Y1J+Txk-m`!9j3Vm{SI$p&j zR7MZp%zppgQfNiH?Jj?>K}(JDfg8~Cq`H_me_pX0c$YG^(Q8jEI{m&?XxEbL>y^Bf zyo3F>D*xLYZN1p$h;l)yK$%i$4;)^a+l!v5MrW?H*N%y=w$v6`bR{>4|LiJ~=0I`_(+mIr diff --git a/tests/script/general/connection/test_old_data.sim b/tests/script/general/connection/test_old_data.sim deleted file mode 100644 index 83df850f0b..0000000000 --- a/tests/script/general/connection/test_old_data.sim +++ /dev/null @@ -1,32 +0,0 @@ -system sh/stop_dnodes.sh -system sh/mv_old_data.sh - -print ============== deploy - -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -print =============== step1 - -sql use test -sql select * from m1 - -print $rows points data are retrieved -if $rows != 7 then - return -1 -endi - -print =============== step 2 - -sql select * from t1 - -print $rows points data are retrieved -if $rows != 7 then - return -1 -endi - - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 78dec01a74..2ba337ddb5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -298,11 +298,11 @@ #./test.sh -f tsim/tag/delete.sim #./test.sh -f tsim/tag/double.sim #./test.sh -f tsim/tag/filter.sim -./test.sh -f tsim/tag/float.sim +#./test.sh -f tsim/tag/float.sim ./test.sh -f tsim/tag/int_binary.sim ./test.sh -f tsim/tag/int_float.sim ./test.sh -f tsim/tag/int.sim -./test.sh -f tsim/tag/set.sim +#./test.sh -f tsim/tag/set.sim ./test.sh -f tsim/tag/smallint.sim ./test.sh -f tsim/tag/tinyint.sim From 75aca0b0316bb7468bc521a0aa0ee367f0f744a1 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Jul 2022 13:53:23 +0800 Subject: [PATCH 39/65] fix(query): set correct fill output column index, fix some memory leak, and do some internal refactor, --- include/common/tcommon.h | 14 -------- include/common/tdatablock.h | 6 +++- include/libs/stream/tstream.h | 4 +-- source/common/src/tdatablock.c | 15 +++++++- source/dnode/vnode/src/tq/tqRead.c | 2 +- source/dnode/vnode/src/tsdb/tsdbRead.c | 15 ++++---- source/libs/executor/src/scanoperator.c | 4 +-- source/libs/executor/src/tfill.c | 46 ++++++++++++++----------- source/libs/function/src/udfd.c | 6 ++-- source/libs/stream/src/streamData.c | 2 +- source/libs/stream/src/streamDispatch.c | 2 +- source/libs/stream/src/streamExec.c | 8 ++--- 12 files changed, 65 insertions(+), 59 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index d8264ac5b5..005a4e9f57 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -162,7 +162,6 @@ typedef struct SQueryTableDataCond { int64_t endVersion; } SQueryTableDataCond; -void* blockDataDestroy(SSDataBlock* pBlock); int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock); void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock); @@ -170,19 +169,6 @@ int32_t tEncodeDataBlocks(void** buf, const SArray* blocks); void* tDecodeDataBlocks(const void* buf, SArray** blocks); void colDataDestroy(SColumnInfoData* pColData); -static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) { - int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock); - for (int32_t i = 0; i < numOfOutput; ++i) { - SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); - colDataDestroy(pColInfoData); - } - - taosArrayDestroy(pBlock->pDataBlock); - taosMemoryFreeClear(pBlock->pBlockAgg); -} - -static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); } - //====================================================================================================================== // the following structure shared by parser and executor typedef struct SColumn { diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index af333f72aa..a4f5904018 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -226,8 +226,12 @@ int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n); int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src); int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); -SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData); + SSDataBlock* createDataBlock(); +void* blockDataDestroy(SSDataBlock* pBlock); +void blockDataFreeRes(SSDataBlock* pBlock); +SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData); + int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData); SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index a08db7b8f8..071c539ff3 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -340,12 +340,12 @@ static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBloc if (pTask->sinkType == TASK_SINK__TABLE) { ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE); pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks); - taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); taosFreeQitem(pBlock); } else if (pTask->sinkType == TASK_SINK__SMA) { ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE); pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks); - taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); taosFreeQitem(pBlock); } else { ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 9f5a247d76..47cfa5d410 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1197,15 +1197,28 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) { return TSDB_CODE_SUCCESS; } +void blockDataFreeRes(SSDataBlock* pBlock) { + int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock); + for (int32_t i = 0; i < numOfOutput; ++i) { + SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); + colDataDestroy(pColInfoData); + } + + taosArrayDestroy(pBlock->pDataBlock); + taosMemoryFreeClear(pBlock->pBlockAgg); + memset(&pBlock->info, 0, sizeof(SDataBlockInfo)); +} + void* blockDataDestroy(SSDataBlock* pBlock) { if (pBlock == NULL) { return NULL; } - blockDestroyInner(pBlock); + blockDataFreeRes(pBlock); taosMemoryFreeClear(pBlock); return NULL; } + int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) { ASSERT(src != NULL); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 8753ecc47c..a7ad935caa 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -319,7 +319,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) { return 0; FAIL: - tDeleteSSDataBlock(pBlock); + blockDataFreeRes(pBlock); return -1; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 4aaa80d3ae..5e30fcd5b2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -209,10 +209,10 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) { p->iterInit = false; p->iiter.hasVal = false; if (p->iter.iter != NULL) { - tsdbTbDataIterDestroy(p->iter.iter); + p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter); } - taosArrayDestroy(p->delSkyline); + p->delSkyline = taosArrayDestroy(p->delSkyline); } } @@ -224,18 +224,15 @@ static void destroyBlockScanInfo(SHashObj* pTableMap) { p->iiter.hasVal = false; if (p->iter.iter != NULL) { - tsdbTbDataIterDestroy(p->iter.iter); - p->iter.iter = NULL; + p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter); } if (p->iiter.iter != NULL) { - tsdbTbDataIterDestroy(p->iiter.iter); - p->iiter.iter = NULL; + p->iiter.iter = tsdbTbDataIterDestroy(p->iiter.iter); } - taosArrayDestroy(p->delSkyline); - taosArrayDestroy(p->pBlockList); - p->delSkyline = NULL; + p->delSkyline = taosArrayDestroy(p->delSkyline); + p->pBlockList = taosArrayDestroy(p->pBlockList); } taosHashCleanup(pTableMap); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 701002d0e7..1d309931d6 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1193,8 +1193,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock } } - taosArrayDestroy(pBlock->pDataBlock); - ASSERT(pInfo->pRes->pDataBlock != NULL); // currently only the tbname pseudo column @@ -1202,12 +1200,14 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { + blockDataFreeRes((SSDataBlock*) pBlock); longjmp(pTaskInfo->env, code); } } doFilter(pInfo->pCondition, pInfo->pRes); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); + blockDataFreeRes((SSDataBlock*) pBlock); return 0; } diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 959c03a3b1..e0bdcfdc3a 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -71,13 +71,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* SPoint point1, point2, point; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); - // set the primary timestamp column value - int32_t index = pFillInfo->numOfCurrent; - SColumnInfoData* pCol0 = taosArrayGet(pBlock->pDataBlock, pFillInfo->tsSlotId); - char* val = colDataGetData(pCol0, index); - - // set the primary timestamp value - *(TSKEY*)val = pFillInfo->currentKey; +// set the primary timestamp column value + int32_t index = pFillInfo->numOfCurrent; // set the other values if (pFillInfo->type == TSDB_FILL_PREV) { @@ -92,7 +87,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol)); if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) { - colDataAppend(pDstColInfoData, index, (const char*)&ts, false); + colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false); } else { SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDstColInfoData, index, pKey); @@ -101,41 +96,51 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* } else if (pFillInfo->type == TSDB_FILL_NEXT) { SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev; // todo refactor: start from 0 not 1 - for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; if (TSDB_COL_IS_TAG(pCol->flag)) { continue; } - SGroupKeys* pKey = taosArrayGet(p, i); SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol)); - doSetVal(pDstColInfoData, index, pKey); + + if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) { + colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false); + } else { + SGroupKeys* pKey = taosArrayGet(p, i); + doSetVal(pDstColInfoData, index, pKey); + } } } else if (pFillInfo->type == TSDB_FILL_LINEAR) { // TODO : linear interpolation supports NULL value if (outOfBound) { setNullRow(pBlock, pFillInfo->currentKey, index); } else { - for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; if (TSDB_COL_IS_TAG(pCol->flag)) { continue; } - int32_t srcSlotId = GET_SRC_SLOT_ID(pCol); - int32_t dstSlotId = GET_DEST_SLOT_ID(pCol); SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); - int16_t type = pCol->pExpr->base.resSchema.type; + int16_t type = pDstCol->info.type; + if (type == TSDB_DATA_TYPE_TIMESTAMP) { + colDataAppend(pDstCol, index, (const char*)&pFillInfo->currentKey, false); + continue; + } + SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i); if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pKey->isNull) { colDataAppendNULL(pDstCol, index); continue; } - SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, 0); - int64_t prevTs = *(int64_t*)pKey1->pData; + SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, pFillInfo->tsSlotId); + + int64_t prevTs = *(int64_t*)pKey1->pData; + int32_t srcSlotId = GET_SRC_SLOT_ID(pCol); SColumnInfoData* pSrcCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId); char* data = colDataGetData(pSrcCol, pFillInfo->index); @@ -153,7 +158,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* } else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL setNullRow(pBlock, pFillInfo->currentKey, index); } else { // fill with user specified value for each column - for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; if (TSDB_COL_IS_TAG(pCol->flag) /* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) { continue; @@ -176,6 +181,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* colDataAppend(pDst, index, (char*)&v, false); } else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) { colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false); + } else { // varchar/nchar data + colDataAppendNULL(pDst, index); } } } @@ -234,8 +241,7 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t outputRows) { pFillInfo->numOfCurrent = 0; - // todo make sure the first column is always the primary timestamp column? - SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, 0); + SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->tsSlotId); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); bool ascFill = FILL_IS_ASC_FILL(pFillInfo); diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index a412b589a9..fd9b588d46 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -296,8 +296,8 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { switch (call->callType) { case TSDB_UDF_CALL_SCALA_PROC: { - tDeleteSSDataBlock(&call->block); - tDeleteSSDataBlock(&subRsp->resultData); + blockDataFreeRes(&call->block); + blockDataFreeRes(&subRsp->resultData); break; } case TSDB_UDF_CALL_AGG_INIT: { @@ -305,7 +305,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { break; } case TSDB_UDF_CALL_AGG_PROC: { - tDeleteSSDataBlock(&call->block); + blockDataFreeRes(&call->block); freeUdfInterBuf(&subRsp->resultBuf); break; } diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index 2b3307b7f5..8e16b23e56 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -116,7 +116,7 @@ void streamFreeQitem(SStreamQueueItem* data) { blockDataDestroy(((SStreamTrigger*)data)->pBlock); taosFreeQitem(data); } else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE) { - taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)blockDataFreeRes); taosFreeQitem(data); } else if (type == STREAM_INPUT__DATA_SUBMIT) { streamDataSubmitRefDec((SStreamDataSubmit*)data); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 05efce8bc2..e2faf28abe 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -313,7 +313,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL); return -1; } - taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); taosFreeQitem(pBlock); tmsgSendReq(pEpSet, &dispatchMsg); diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index d0d81e3343..023c092028 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -106,7 +106,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { qDebug("stream task %d exec end", pTask->taskId); if (pTask->taskStatus == TASK_STATUS__DROPPING) { - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); return NULL; } @@ -121,7 +121,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { qRes->blocks = pRes; if (streamTaskOutput(pTask, qRes) < 0) { /*streamQueueProcessFail(pTask->inputQueue);*/ - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); taosFreeQitem(qRes); return NULL; } @@ -155,7 +155,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { pRes = streamExecForQall(pTask, pRes); if (pRes == NULL) goto FAIL; - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); qDebug("stream exec, return result"); return 0; @@ -163,7 +163,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { continue; } else if (execStatus == TASK_EXEC_STATUS__EXECUTING) { ASSERT(taosArrayGetSize(pRes) == 0); - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); return 0; } else { ASSERT(0); From 4849b0cb78a17395a5443c5da5213b5ff48be374 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Thu, 14 Jul 2022 13:58:23 +0800 Subject: [PATCH 40/65] test: fix win test error --- cmake/cmake.options | 8 +++++++- include/os/osDef.h | 10 +++++++++- tests/pytest/util/dnodes.py | 24 ++++++++++++------------ tests/script/sh/exec.bat | 7 +++++-- tests/script/test-all.bat | 2 +- tests/script/wtest.bat | 3 ++- tests/system-test/test.py | 19 ++++++++++++++++++- 7 files changed, 54 insertions(+), 19 deletions(-) diff --git a/cmake/cmake.options b/cmake/cmake.options index e013ff7592..2acd46694b 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -79,10 +79,16 @@ ENDIF () option( BUILD_SANITIZER - "If build addr2line" + "If build sanitizer" OFF ) +option( + TDENGINE_3 + "TDengine 3.x" + ON + ) + option( BUILD_ADDR2LINE "If build addr2line" diff --git a/include/os/osDef.h b/include/os/osDef.h index 6f6199de7a..14f38eb7ff 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -22,7 +22,10 @@ extern "C" { #if defined(_TD_DARWIN_64) // specific +#ifndef __COMPAR_FN_T +#define __COMPAR_FN_T typedef int(*__compar_fn_t)(const void *, const void *); +#endif // for send function in tsocket.c #if defined(MSG_NOSIGNAL) @@ -41,7 +44,10 @@ extern "C" { #endif #if defined(_ALPINE) +#ifndef __COMPAR_FN_T +#define __COMPAR_FN_T typedef int(*__compar_fn_t)(const void *, const void *); +#endif void error (int, int, const char *); #ifndef PTHREAD_MUTEX_RECURSIVE_NP #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE @@ -54,7 +60,10 @@ extern "C" { char *stpncpy (char *dest, const char *src, size_t n); // specific +#ifndef __COMPAR_FN_T +#define __COMPAR_FN_T typedef int (*__compar_fn_t)(const void *, const void *); +#endif #define ssize_t int #define _SSIZE_T_ #define bzero(ptr, size) memset((ptr), 0, (size)) @@ -69,7 +78,6 @@ extern "C" { char * strsep(char **stringp, const char *delim); char * getpass(const char *prefix); char * strndup(const char *s, size_t n); - int gettimeofday(struct timeval *ptv, void *pTimeZone); // for send function in tsocket.c #define MSG_NOSIGNAL 0 diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index a38b14a52d..96723978ae 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -382,7 +382,7 @@ class TDDnode: if self.valgrind == 0: if platform.system().lower() == 'windows': - cmd = "mintty -h never -w hide %s -c %s" % ( + cmd = "mintty -h never %s -c %s" % ( binPath, self.cfgDir) else: cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( @@ -391,7 +391,7 @@ class TDDnode: valgrindCmdline = "valgrind --log-file=\"%s/../log/valgrind.log\" --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"%self.cfgDir if platform.system().lower() == 'windows': - cmd = "mintty -h never -w hide %s %s -c %s" % ( + cmd = "mintty -h never %s %s -c %s" % ( valgrindCmdline, binPath, self.cfgDir) else: cmd = "nohup %s %s -c %s 2>&1 & " % ( @@ -518,20 +518,20 @@ class TDDnode: if self.running != 0: if platform.system().lower() == 'windows': - os.system("wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId | xargs echo | awk '{print $2}' | xargs taskkill -f -pid"%self.index) + psCmd = "for /f %a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^'') do @(ps | grep %a | awk '{print $1}' | xargs kill -INT )" % (self.index) else: psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}'" % (toBeKilled,self.index) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") - - while(processID): - killCmd = "kill -INT %s > /dev/null 2>&1" % processID - os.system(killCmd) - time.sleep(1) - processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") - if self.valgrind: - time.sleep(2) + if self.valgrind: + time.sleep(2) self.running = 0 tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat index e4c998c25b..88dd43349e 100644 --- a/tests/script/sh/exec.bat +++ b/tests/script/sh/exec.bat @@ -77,7 +77,10 @@ goto :eof :check_offline sleep 1 for /f "tokens=2" %%C in ('wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ^| xargs echo') do ( - echo check taosd offline - goto :check_offline + for /f "tokens=1" %%D in ('ps ^| grep %%C') do ( + echo kill -INT %%D + echo check taosd offline %NODE_NAME% %%C %%D + goto :check_offline + ) ) goto :eof \ No newline at end of file diff --git a/tests/script/test-all.bat b/tests/script/test-all.bat index f771f8fcb6..056d989e6b 100644 --- a/tests/script/test-all.bat +++ b/tests/script/test-all.bat @@ -24,7 +24,7 @@ for /F "usebackq tokens=*" %%i in (!caseFile!) do ( ) ) ) -exit !exitNum! +exit /b !exitNum! :colorEcho set timeNow=%time% diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index e3bbff9db5..f674277df9 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -44,9 +44,10 @@ echo serverPort 7100 >> %TAOS_CFG% echo logDir %LOG_DIR% >> %TAOS_CFG% echo scriptDir %SCRIPT_DIR% >> %TAOS_CFG% echo numOfLogLines 100000000 >> %TAOS_CFG% -echo rpcDebugFlag 135 >> %TAOS_CFG% +echo rpcDebugFlag 143 >> %TAOS_CFG% echo tmrDebugFlag 131 >> %TAOS_CFG% echo cDebugFlag 135 >> %TAOS_CFG% +echo qDebugFlag 143 >> %TAOS_CFG% echo udebugFlag 135 >> %TAOS_CFG% echo wal 0 >> %TAOS_CFG% echo asyncLog 0 >> %TAOS_CFG% diff --git a/tests/system-test/test.py b/tests/system-test/test.py index fd0979745e..b893f7af64 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -37,12 +37,13 @@ def checkRunTimeError(): time.sleep(1) timeCount = timeCount + 1 print("checkRunTimeError",timeCount) - if (timeCount>900): + if (timeCount>600): print("stop the test.") os.system("TASKKILL /F /IM taosd.exe") os.system("TASKKILL /F /IM taos.exe") os.system("TASKKILL /F /IM tmq_sim.exe") os.system("TASKKILL /F /IM mintty.exe") + os.system("TASKKILL /F /IM python.exe") quit(0) hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library") if hwnd: @@ -228,6 +229,22 @@ if __name__ == "__main__": tdDnodes.deploy(1,updateCfgDict) tdDnodes.start(1) tdCases.logSql(logSql) + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + tdSql.init(conn.cursor()) + tdSql.execute("create qnode on dnode 1") + tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + tdSql.query("show local variables;") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "queryPolicy" : + if int(tdSql.queryResult[i][1]) == int(queryPolicy): + tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) + else : + tdLog.debug(tdSql.queryResult) + tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) else : tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums) From dc4e5e61c12f6e424cdf4274da2b29dc0e2f622f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 14:31:20 +0800 Subject: [PATCH 41/65] test: restore some 2.0 case --- tests/script/general/insert/testSuite.sim | 9 - tests/script/jenkins/basic.txt | 15 +- tests/script/tsim/insert/backquote.sim | 19 +- .../script/{general => tsim}/insert/basic.sim | 4 - tests/script/tsim/insert/basic0.sim | 18 -- tests/script/tsim/insert/basic1.sim | 19 +- tests/script/tsim/insert/commit-merge0.sim | 18 -- .../{general => tsim}/insert/insert_drop.sim | 14 +- tests/script/tsim/insert/null.sim | 164 ++++++++---------- .../insert/query_block1_file.sim | 7 +- .../insert/query_block1_memory.sim | 7 +- .../insert/query_block2_file.sim | 17 +- .../insert/query_block2_memory.sim | 7 +- .../insert/query_file_memory.sim | 16 +- .../insert/query_multi_file.sim | 16 +- tests/script/{general => tsim}/insert/tcp.sim | 5 +- 16 files changed, 97 insertions(+), 258 deletions(-) delete mode 100644 tests/script/general/insert/testSuite.sim rename tests/script/{general => tsim}/insert/basic.sim (93%) rename tests/script/{general => tsim}/insert/insert_drop.sim (89%) rename tests/script/{general => tsim}/insert/query_block1_file.sim (98%) rename tests/script/{general => tsim}/insert/query_block1_memory.sim (97%) rename tests/script/{general => tsim}/insert/query_block2_file.sim (94%) rename tests/script/{general => tsim}/insert/query_block2_memory.sim (97%) rename tests/script/{general => tsim}/insert/query_file_memory.sim (94%) rename tests/script/{general => tsim}/insert/query_multi_file.sim (76%) rename tests/script/{general => tsim}/insert/tcp.sim (91%) diff --git a/tests/script/general/insert/testSuite.sim b/tests/script/general/insert/testSuite.sim deleted file mode 100644 index da44167be5..0000000000 --- a/tests/script/general/insert/testSuite.sim +++ /dev/null @@ -1,9 +0,0 @@ -run general/insert/basic.sim -run general/insert/insert_drop.sim -run general/insert/query_block1_memory.sim -run general/insert/query_block2_memory.sim -run general/insert/query_block1_file.sim -run general/insert/query_block2_file.sim -run general/insert/query_file_memory.sim -run general/insert/query_multi_file.sim -run general/insert/tcp.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2ba337ddb5..f1264f3cb4 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -52,13 +52,22 @@ ./test.sh -f tsim/import/replica1.sim # ---- insert +./test.sh -f tsim/insert/backquote.sim +./test.sh -f tsim/insert/basic.sim ./test.sh -f tsim/insert/basic0.sim ./test.sh -f tsim/insert/basic1.sim -./test.sh -f tsim/insert/backquote.sim -./test.sh -f tsim/insert/null.sim -./test.sh -f tsim/insert/update0.sim ./test.sh -f tsim/insert/commit-merge0.sim +./test.sh -f tsim/insert/insert_drop.sim ./test.sh -f tsim/insert/insert_select.sim +./test.sh -f tsim/insert/null.sim +./test.sh -f tsim/insert/query_block1_file.sim +./test.sh -f tsim/insert/query_block1_memory.sim +./test.sh -f tsim/insert/query_block2_file.sim +./test.sh -f tsim/insert/query_block2_memory.sim +./test.sh -f tsim/insert/query_file_memory.sim +./test.sh -f tsim/insert/query_multi_file.sim +#./test.sh -f tsim/insert/tcp.sim +./test.sh -f tsim/insert/update0.sim # ---- parser ./test.sh -f tsim/parser/groupby-basic.sim diff --git a/tests/script/tsim/insert/backquote.sim b/tests/script/tsim/insert/backquote.sim index ba50e70afa..db2cddd2ca 100644 --- a/tests/script/tsim/insert/backquote.sim +++ b/tests/script/tsim/insert/backquote.sim @@ -1,9 +1,9 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 50 sql connect + print =============== create database sql create database `database` sql create database `DataBase` @@ -184,23 +184,6 @@ print =============== stop and restart taosd system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql show databases print rows: $rows print $data00 $data01 diff --git a/tests/script/general/insert/basic.sim b/tests/script/tsim/insert/basic.sim similarity index 93% rename from tests/script/general/insert/basic.sim rename to tests/script/tsim/insert/basic.sim index 88eb30a1ad..20b39c8f00 100644 --- a/tests/script/general/insert/basic.sim +++ b/tests/script/tsim/insert/basic.sim @@ -1,10 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim index 722bc0f907..b2fd7587da 100644 --- a/tests/script/tsim/insert/basic0.sim +++ b/tests/script/tsim/insert/basic0.sim @@ -283,30 +283,12 @@ endi # return -1 #endi -#=================================================================== #=================================================================== print =============== stop and restart taosd, then again do query above system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - print =============== query data from child table sql select * from ct1 print rows: $rows diff --git a/tests/script/tsim/insert/basic1.sim b/tests/script/tsim/insert/basic1.sim index d98407b380..cc7f22c007 100644 --- a/tests/script/tsim/insert/basic1.sim +++ b/tests/script/tsim/insert/basic1.sim @@ -1,9 +1,9 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 50 sql connect + print =============== create database sql create database d1 sql show databases @@ -78,23 +78,6 @@ print =============== stop and restart taosd system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - print =============== query data sql select * from c1 print rows: $rows diff --git a/tests/script/tsim/insert/commit-merge0.sim b/tests/script/tsim/insert/commit-merge0.sim index 56e818654f..5fe7cc57b3 100644 --- a/tests/script/tsim/insert/commit-merge0.sim +++ b/tests/script/tsim/insert/commit-merge0.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 50 sql connect print =============== create database @@ -64,23 +63,6 @@ reboot_and_check: system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - print =============== insert duplicated records to memory - loop $reboot_max - $reboot_cnt sql use db sql insert into ct1 values ('2022-05-01 18:30:27.001', 0.0); diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/tsim/insert/insert_drop.sim similarity index 89% rename from tests/script/general/insert/insert_drop.sim rename to tests/script/tsim/insert/insert_drop.sim index 8592637626..020fd367ae 100644 --- a/tests/script/general/insert/insert_drop.sim +++ b/tests/script/tsim/insert/insert_drop.sim @@ -1,10 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $tbNum = 10 @@ -19,7 +15,7 @@ $stb = stb sql drop database $db -x step1 step1: -sql create database $db ctime 30 +sql create database $db print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int) tags(t1 int) @@ -43,13 +39,9 @@ print ====== tables created print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sql reset query cache -sleep 1000 - sql use $db sql drop table tb5 $i = 0 @@ -69,13 +61,9 @@ endw print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sql reset query cache -sleep 1000 - sql use $db sql create table tb5 using $stb tags(5) diff --git a/tests/script/tsim/insert/null.sim b/tests/script/tsim/insert/null.sim index 98a494c960..1b7017038a 100644 --- a/tests/script/tsim/insert/null.sim +++ b/tests/script/tsim/insert/null.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 50 sql connect print =============== create database @@ -211,66 +210,48 @@ endi #=================================================================== #print =============== query data from stb -#sql select * from stb -#print ===> -#print ===> rows: $rows -#print ===> rows0: $data00 $data01 $data02 $data03 $data04 -#if $rows != 4 then -# return -1 -#endi +sql select * from stb +print ===> +print ===> rows: $rows +print ===> rows0: $data00 $data01 $data02 $data03 $data04 +if $rows != 12 then + return -1 +endi + #print =============== select count(*) from supter table -#sql select count(*) from stb -#print $data00 $data01 $data02 -#if $rows != 1 then -# return -1 -#endi -#if $data00 != 12 then -# return -1 -#endi +sql select count(*) from stb +print $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data00 != 12 then + return -1 +endi #print =============== select count(column) from supter table -#sql select count(ts), count(c1), count(c2), count(c3) from stb -#print $data00 $data01 $data02 $data03 -#if $data00 != 12 then -# return -1 -#endi -#if $data01 != 8 then -# return -1 -#endi -#if $data02 != 8 then -# return -1 -#endi -#if $data03 != 8 then -# return -1 -#endi +sql select count(ts), count(c1), count(c2), count(c3) from stb +print $data00 $data01 $data02 $data03 +if $data00 != 12 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data03 != 8 then + return -1 +endi -#=================================================================== #=================================================================== print =============== stop and restart taosd, then again do query above system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -print ===> waiting dnode ready -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi +#=================================================================== -#=================================================================== -#=================================================================== print =============== query data from child table sql select * from ct1 print ===> select * from ct1 @@ -292,15 +273,15 @@ endi if $data03 != 3.000000000 then return -1 endi -#if $data41 != -14 then -# return -1 -#endi -#if $data42 != -2.40000 then -# return -1 -#endi -#if $data43 != -3.400000000 then -# return -1 -#endi +if $data41 != 12 then + return -1 +endi +if $data42 != 2.20000 then + return -1 +endi +if $data43 != NULL then + return -1 +endi print =============== select count(*) from child table sql select count(*) from ct1 @@ -435,40 +416,39 @@ if $data92 != 3.600000000 then return -1 endi #=================================================================== -#=================================================================== -#print =============== query data from stb -#sql select * from stb -#print ===> -#print ===> rows: $rows -#print ===> rows0: $data00 $data01 $data02 $data03 $data04 -#if $rows != 4 then -# return -1 -#endi -#print =============== select count(*) from supter table -#sql select count(*) from stb -#print $data00 $data01 $data02 -#if $rows != 1 then -# return -1 -#endi -#if $data00 != 12 then -# return -1 -#endi +print =============== query data from stb +sql select * from stb +print ===> +print ===> rows: $rows +print ===> rows0: $data00 $data01 $data02 $data03 $data04 +if $rows != 12 then + return -1 +endi +print =============== select count(*) from supter table +sql select count(*) from stb +print $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data00 != 12 then + return -1 +endi -#print =============== select count(column) from supter table -#sql select count(ts), count(c1), count(c2), count(c3) from stb -#print $data00 $data01 $data02 $data03 -#if $data00 != 12 then -# return -1 -#endi -#if $data01 != 8 then -# return -1 -#endi -#if $data02 != 8 then -# return -1 -#endi -#if $data03 != 8 then -# return -1 -#endi +print =============== select count(column) from supter table +sql select count(ts), count(c1), count(c2), count(c3) from stb +print $data00 $data01 $data02 $data03 +if $data00 != 12 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data03 != 8 then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/insert/query_block1_file.sim b/tests/script/tsim/insert/query_block1_file.sim similarity index 98% rename from tests/script/general/insert/query_block1_file.sim rename to tests/script/tsim/insert/query_block1_file.sim index 636b9530f9..e4e8928bf8 100644 --- a/tests/script/general/insert/query_block1_file.sim +++ b/tests/script/tsim/insert/query_block1_file.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -190,7 +185,7 @@ clear: sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/tsim/insert/query_block1_memory.sim similarity index 97% rename from tests/script/general/insert/query_block1_memory.sim rename to tests/script/tsim/insert/query_block1_memory.sim index 823e466ee9..a8e1a0439c 100644 --- a/tests/script/general/insert/query_block1_memory.sim +++ b/tests/script/tsim/insert/query_block1_memory.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -175,7 +170,7 @@ clear: sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/query_block2_file.sim b/tests/script/tsim/insert/query_block2_file.sim similarity index 94% rename from tests/script/general/insert/query_block2_file.sim rename to tests/script/tsim/insert/query_block2_file.sim index 5b7438875e..5557621e0f 100644 --- a/tests/script/general/insert/query_block2_file.sim +++ b/tests/script/tsim/insert/query_block2_file.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -19,15 +14,7 @@ sql drop database -x step1 step1: sql create database $db sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 +sql create table $tb (ts timestamp, speed int) #commit to file will trigger if insert 82 rows $N = 82 @@ -204,7 +191,7 @@ clear: sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/query_block2_memory.sim b/tests/script/tsim/insert/query_block2_memory.sim similarity index 97% rename from tests/script/general/insert/query_block2_memory.sim rename to tests/script/tsim/insert/query_block2_memory.sim index fb41981c89..910207d13b 100644 --- a/tests/script/general/insert/query_block2_memory.sim +++ b/tests/script/tsim/insert/query_block2_memory.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -167,7 +162,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/query_file_memory.sim b/tests/script/tsim/insert/query_file_memory.sim similarity index 94% rename from tests/script/general/insert/query_file_memory.sim rename to tests/script/tsim/insert/query_file_memory.sim index f920c215c0..c0aafd2686 100644 --- a/tests/script/general/insert/query_file_memory.sim +++ b/tests/script/tsim/insert/query_file_memory.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -20,14 +15,7 @@ step1: sql create database $db sql use $db -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 +sql create table $tb (ts timestamp, speed int) #commit to file will trigger if insert 82 rows @@ -202,7 +190,7 @@ clear: sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/query_multi_file.sim b/tests/script/tsim/insert/query_multi_file.sim similarity index 76% rename from tests/script/general/insert/query_multi_file.sim rename to tests/script/tsim/insert/query_multi_file.sim index bbca53d309..f996317721 100644 --- a/tests/script/general/insert/query_multi_file.sim +++ b/tests/script/tsim/insert/query_multi_file.sim @@ -1,11 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -20,14 +15,7 @@ step1: sql create database $db sql use $db -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 +sql create table $tb (ts timestamp, speed int) $N = 20000 @@ -49,7 +37,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/general/insert/tcp.sim b/tests/script/tsim/insert/tcp.sim similarity index 91% rename from tests/script/general/insert/tcp.sim rename to tests/script/tsim/insert/tcp.sim index 002d84dcae..2dc720a0d4 100644 --- a/tests/script/general/insert/tcp.sim +++ b/tests/script/tsim/insert/tcp.sim @@ -1,10 +1,7 @@ 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 debugflag -v 131 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect sql create database d1; From 869f2729707b64404f3a915fad367eb4f6dfd321 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 14 Jul 2022 15:05:39 +0800 Subject: [PATCH 42/65] test: modify case --- tests/system-test/7-tmq/dataFromTsdbNWal.py | 19 +++++++++---------- tests/system-test/7-tmq/tmqCommon.py | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/system-test/7-tmq/dataFromTsdbNWal.py b/tests/system-test/7-tmq/dataFromTsdbNWal.py index a55fbbfd18..227ce9d5a5 100644 --- a/tests/system-test/7-tmq/dataFromTsdbNWal.py +++ b/tests/system-test/7-tmq/dataFromTsdbNWal.py @@ -38,9 +38,9 @@ class TDTestCase: 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], 'ctbPrefix': 'ctb', 'ctbStartIdx': 0, - 'ctbNum': 10, + 'ctbNum': 100, 'rowsPerTbl': 10000, - 'batchNum': 1000, + 'batchNum': 3000, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 'pollDelay': 10, 'showMsg': 1, @@ -64,9 +64,7 @@ class TDTestCase: ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) - tdLog.info("restart taosd to ensure that the data falls into the disk") - # tdDnodes.stop(1) - # tdDnodes.start(1) + tdLog.info("flush db to let data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) return @@ -85,7 +83,7 @@ class TDTestCase: 'ctbStartIdx': 0, 'ctbNum': 10, 'rowsPerTbl': 10000, - 'batchNum': 10, + 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 'pollDelay': 3, 'showMsg': 1, @@ -95,8 +93,6 @@ class TDTestCase: paraDict['vgroups'] = self.vgroups paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl - paraDict['batchNum'] = 100 - paraDict['startTs'] = paraDict['startTs'] + self.rowsPerTbl topicNameList = ['topic1'] expectRowsList = [] @@ -125,6 +121,8 @@ class TDTestCase: tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) # after start consume, continue insert some data + paraDict['batchNum'] = 100 + paraDict['startTs'] = paraDict['startTs'] + self.rowsPerTbl tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) @@ -137,11 +135,12 @@ class TDTestCase: expectRows = 1 resultList = tmqCom.selectConsumeResult(expectRows) + + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) if expectRowsList[0] != resultList[0]: - tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.exit("%d tmq consume rows error!"%consumerId) - tmqCom.checkFileContent(consumerId, queryString) + tmqCom.checkFileContent(consumerId, queryString) time.sleep(10) for i in range(len(topicNameList)): diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 98c9e37132..060e17c11f 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -444,6 +444,7 @@ class TMQCom: # skip first line for it is schema queryFile.readline() + lines = 0 while True: dst = queryFile.readline() From 7d1c2fdbe5e68dba9fa5567f1f0105862624d6b8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 15:16:09 +0800 Subject: [PATCH 43/65] test: restore some 2.0 case --- tests/script/jenkins/basic.txt | 24 ++++---- tests/script/tsim/compute/avg.sim | 18 +++--- tests/script/tsim/compute/bottom.sim | 26 ++++----- tests/script/tsim/compute/count.sim | 29 +++++----- tests/script/tsim/compute/diff.sim | 16 +++--- tests/script/tsim/compute/diff2.sim | 70 +++++++++++------------ tests/script/tsim/compute/first.sim | 28 +++++---- tests/script/tsim/compute/interval.sim | 32 +++++------ tests/script/tsim/compute/last.sim | 26 ++++----- tests/script/tsim/compute/last_row.sim | 5 +- tests/script/tsim/compute/leastsquare.sim | 14 ++--- tests/script/tsim/compute/max.sim | 28 +++++---- tests/script/tsim/compute/null.sim | 7 ++- 13 files changed, 155 insertions(+), 168 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index f1264f3cb4..1e3be5924b 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -236,23 +236,23 @@ ./test.sh -f tsim/compress/uncompress.sim # ---- compute -#./test.sh -f tsim/compute/avg.sim +./test.sh -f tsim/compute/avg.sim #./test.sh -f tsim/compute/block_dist.sim -#./test.sh -f tsim/compute/bottom.sim -#./test.sh -f tsim/compute/count.sim -#./test.sh -f tsim/compute/diff.sim -#./test.sh -f tsim/compute/diff2.sim -#./test.sh -f tsim/compute/first.sim -#./test.sh -f tsim/compute/interval.sim +./test.sh -f tsim/compute/bottom.sim +./test.sh -f tsim/compute/count.sim +./test.sh -f tsim/compute/diff.sim +./test.sh -f tsim/compute/diff2.sim +./test.sh -f tsim/compute/first.sim +./test.sh -f tsim/compute/interval.sim #./test.sh -f tsim/compute/last_row.sim -#./test.sh -f tsim/compute/last.sim -#./test.sh -f tsim/compute/leastsquare.sim -#./test.sh -f tsim/compute/max.sim -#./test.sh -f tsim/compute/min.sim +./test.sh -f tsim/compute/last.sim +./test.sh -f tsim/compute/leastsquare.sim +./test.sh -f tsim/compute/max.sim +./test.sh -f tsim/compute/min.sim #./test.sh -f tsim/compute/null.sim ./test.sh -f tsim/compute/percentile.sim ./test.sh -f tsim/compute/stddev.sim -#./test.sh -f tsim/compute/sum.sim +./test.sh -f tsim/compute/sum.sim ./test.sh -f tsim/compute/top.sim # ---- field diff --git a/tests/script/tsim/compute/avg.sim b/tests/script/tsim/compute/avg.sim index 2805b65fff..50a0aeffb0 100644 --- a/tests/script/tsim/compute/avg.sim +++ b/tests/script/tsim/compute/avg.sim @@ -69,13 +69,13 @@ endi print =============== step5 sql select avg(tbcol) as b from $tb interval(1m) print ===> $data01 -if $data11 != 1.000000000 then +if $data10 != 1.000000000 then return -1 endi sql select avg(tbcol) as b from $tb interval(1d) print ===> $data01 -if $data01 != 9.500000000 then +if $data00 != 9.500000000 then return -1 endi @@ -84,7 +84,7 @@ $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select avg(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data01 -if $data41 != 4.000000000 then +if $data40 != 4.000000000 then return -1 endi if $rows != 5 then @@ -123,14 +123,14 @@ endi print =============== step9 sql select avg(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1.000000000 then +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi sql select avg(tbcol) as b from $mt interval(1d) print ===> $data01 -if $data01 != 9.500000000 then +if $data00 != 9.500000000 then return -1 endi @@ -148,9 +148,9 @@ endi print =============== step11 $cc = 4 * 60000 $ms = 1601481600000 + $cc -sql select avg(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1.000000000 then +sql select avg(tbcol) as b from $mt where ts <= $ms partition by tgcol interval(1m) +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi if $rows != 50 then diff --git a/tests/script/tsim/compute/bottom.sim b/tests/script/tsim/compute/bottom.sim index cfac02d6d5..a17584734b 100644 --- a/tests/script/tsim/compute/bottom.sim +++ b/tests/script/tsim/compute/bottom.sim @@ -38,15 +38,13 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i sql select bottom(tbcol, 1) from $tb -print ===> $data01 -if $data01 != 0 then +print ===> $data00 +if $data00 != 0 then return -1 endi @@ -54,25 +52,25 @@ print =============== step3 $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select bottom(tbcol, 1) from $tb where ts > $ms -print ===> $data01 -if $data01 != 5 then +print ===> $data00 +if $data00 != 5 then return -1 endi print =============== step4 sql select bottom(tbcol, 1) as b from $tb -print ===> $data01 -if $data01 != 0 then +print ===> $data00 +if $data00 != 0 then return -1 endi print =============== step5 sql select bottom(tbcol, 2) as b from $tb -print ===> $data01 $data11 -if $data01 != 0 then +print ===> $data00 $data10 +if $data00 != 1 then return -1 endi -if $data11 != 1 then +if $data10 != 0 then return -1 endi @@ -80,11 +78,11 @@ print =============== step6 $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select bottom(tbcol, 2) as b from $tb where ts > $ms -print ===> $data01 $data11 -if $data01 != 5 then +print ===> $data00 $data10 +if $data00 != 6 then return -1 endi -if $data11 != 6 then +if $data10 != 5 then return -1 endi diff --git a/tests/script/tsim/compute/count.sim b/tests/script/tsim/compute/count.sim index 0a6ce93077..cf2ad933bc 100644 --- a/tests/script/tsim/compute/count.sim +++ b/tests/script/tsim/compute/count.sim @@ -38,13 +38,10 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i - sql select count(*) from $tb print ===> select count(*) from $tb => $data00 if $data00 != $rowNum then @@ -81,14 +78,14 @@ endi print =============== step5 sql select count(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 1 then +print ===> $data00 +if $data00 != 1 then return -1 endi sql select count(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != $rowNum then +print ===> $data00 +if $data00 != $rowNum then return -1 endi @@ -96,8 +93,8 @@ print =============== step6 $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select count(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data01 -if $data01 != 1 then +print ===> $data00 +if $data00 != 1 then return -1 endi if $rows != 5 then @@ -149,17 +146,17 @@ endi print =============== step9 sql select count(tbcol) as b from $mt interval(1m) -print ===> $data01 -if $data01 != 10 then +print ===> $data00 +if $data00 != 10 then return -1 endi -if $data11 != 10 then +if $data10 != 10 then return -1 endi sql select count(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 200 then +print ===> $data00 +if $data00 != 200 then return -1 endi @@ -177,9 +174,9 @@ endi print =============== step11 $cc = 4 * 60000 $ms = 1601481600000 + $cc -sql select count(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +sql select count(tbcol) as b from $mt where ts <= $ms partition by tgcol interval(1m) print ===> $data01 -if $data01 != 1 then +if $data00 != 1 then return -1 endi if $rows != 50 then diff --git a/tests/script/tsim/compute/diff.sim b/tests/script/tsim/compute/diff.sim index ba4b32ddbb..f11fc92b2b 100644 --- a/tests/script/tsim/compute/diff.sim +++ b/tests/script/tsim/compute/diff.sim @@ -44,8 +44,8 @@ $i = 1 $tb = $tbPrefix . $i sql select diff(tbcol) from $tb -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi @@ -53,23 +53,23 @@ print =============== step3 $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select diff(tbcol) from $tb where ts > $ms -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select diff(tbcol) from $tb where ts <= $ms -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi print =============== step4 sql select diff(tbcol) as b from $tb -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi diff --git a/tests/script/tsim/compute/diff2.sim b/tests/script/tsim/compute/diff2.sim index 08b52cb37b..021fcf6e8b 100644 --- a/tests/script/tsim/compute/diff2.sim +++ b/tests/script/tsim/compute/diff2.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start sql connect @@ -39,91 +40,90 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i sql select diff(c1) from $tb -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c2) from $tb -print ===> $data11 -if $data11 != 1.00000 then +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi sql select diff(c3) from $tb -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c4) from $tb -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c5) from $tb -print ===> $data11 -if $data11 != 0 then +print ===> $data10 +if $data10 != 0 then return -1 endi sql select diff(c6) from $tb -print ===> $data11 -if $data11 != 1.000000000 then +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi -sql_error select diff(c7) from $tb + +sql select diff(c7) from $tb sql_error select diff(c8) from $tb sql_error select diff(c9) from $tb sql_error select diff(ts) from $tb sql_error select diff(c1), diff(c2) from $tb -#sql_error select 2+diff(c1) from $tb -sql_error select diff(c1+2) from $tb + +sql select 2+diff(c1) from $tb +sql select diff(c1+2) from $tb sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) -sql_error select diff(c1) from $mt +sql select diff(c1) from $mt sql_error select diff(diff(c1)) from $tb sql_error select diff(c1) from m_di_tb1 where c2 like '2%' - print =============== step3 sql select diff(c1) from $tb where c1 > 5 -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c2) from $tb where c2 > 5 -print ===> $data11 -if $data11 != 1.00000 then +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi sql select diff(c3) from $tb where c3 > 5 -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c4) from $tb where c4 > 5 -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select diff(c5) from $tb where c5 > 5 -print ===> $data11 -if $data11 != 0 then +print ===> $data10 +if $data10 != 0 then return -1 endi sql select diff(c6) from $tb where c6 > 5 -print ===> $data11 -if $data11 != 1.000000000 then +print ===> $data10 +if $data10 != 1.000000000 then return -1 endi print =============== step4 sql select diff(c1) from $tb where c1 > 5 and c2 < $rowNum -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi @@ -131,8 +131,8 @@ sql select diff(c1) from $tb where c9 like '%9' and c1 <= 20 if $rows != 1 then return -1 endi -print ===> $data11 -if $data01 != 10 then +print ===> $data10 +if $data00 != 10 then return -1 endi diff --git a/tests/script/tsim/compute/first.sim b/tests/script/tsim/compute/first.sim index cf1160dbdb..f8efeee513 100644 --- a/tests/script/tsim/compute/first.sim +++ b/tests/script/tsim/compute/first.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i @@ -68,14 +66,14 @@ endi print =============== step5 sql select first(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 0 then +print ===> $data00 +if $data00 != 0 then return -1 endi sql select first(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 0 then +print ===> $data00 +if $data00 != 0 then return -1 endi @@ -83,8 +81,8 @@ print =============== step6 $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select first(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data01 -if $data41 != 4 then +print ===> $data00 +if $data40 != 4 then return -1 endi if $rows != 5 then @@ -124,14 +122,14 @@ endi print =============== step9 sql select first(tbcol) as b from $mt interval(1m) print select first(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select first(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 0 then +print ===> $data00 +if $data00 != 0 then return -1 endi @@ -149,9 +147,9 @@ endi print =============== step11 $cc = 4 * 60000 $ms = 1601481600000 + $cc -sql select first(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then +sql select first(tbcol) as b from $mt where ts <= $ms partition by tgcol interval(1m) +print ===> $data10 +if $data10 != 1 then return -1 endi print ===> $rows diff --git a/tests/script/tsim/compute/interval.sim b/tests/script/tsim/compute/interval.sim index a8539701c7..2e38990975 100644 --- a/tests/script/tsim/compute/interval.sim +++ b/tests/script/tsim/compute/interval.sim @@ -47,10 +47,10 @@ print ===> $rows if $rows < $rowNum then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi -if $data05 != 1 then +if $data04 != 1 then return -1 endi @@ -65,10 +65,10 @@ endi if $rows < 3 then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi -if $data05 != 1 then +if $data04 != 1 then return -1 endi @@ -87,10 +87,10 @@ endi if $rows > 22 then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi -if $data05 != 1 then +if $data04 != 1 then return -1 endi @@ -109,10 +109,10 @@ endi if $rows > 50 then return -1 endi -if $data21 != 1 then +if $data20 != 1 then return -1 endi -if $data25 != 1 then +if $data24 != 1 then return -1 endi @@ -125,10 +125,10 @@ endi if $rows > 22 then return -1 endi -if $data11 > 15 then +if $data10 > 15 then return -1 endi -if $data11 < 5 then +if $data10 < 5 then return -1 endi @@ -143,10 +143,10 @@ endi if $rows > 7 then return -1 endi -if $data11 > 15 then +if $data10 > 15 then return -1 endi -if $data11 < 5 then +if $data10 < 5 then return -1 endi @@ -165,10 +165,10 @@ endi if $rows > 22 then return -1 endi -if $data11 > 15 then +if $data10 > 15 then return -1 endi -if $data11 < 5 then +if $data10 < 5 then return -1 endi @@ -186,10 +186,10 @@ endi if $rows > 50 then return -1 endi -if $data11 > 15 then +if $data10 > 15 then return -1 endi -if $data11 < 5 then +if $data10 < 5 then return -1 endi diff --git a/tests/script/tsim/compute/last.sim b/tests/script/tsim/compute/last.sim index aa9b041ca9..ae6f016b08 100644 --- a/tests/script/tsim/compute/last.sim +++ b/tests/script/tsim/compute/last.sim @@ -69,14 +69,14 @@ endi print =============== step5 sql select last(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select last(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 19 then +print ===> $data00 +if $data00 != 19 then return -1 endi @@ -85,8 +85,8 @@ $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select last(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi if $rows != 5 then @@ -127,14 +127,14 @@ endi print =============== step9 sql select last(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select last(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 19 then +print ===> $data00 +if $data00 != 19 then return -1 endi @@ -153,9 +153,9 @@ print =============== step11 $cc = 4 * 60000 $ms = 1601481600000 + $cc -sql select last(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then +sql select last(tbcol) as b from $mt where ts <= $ms partition by tgcol interval(1m) +print ===> $data10 +if $data10 != 1 then return -1 endi print ===> $rows diff --git a/tests/script/tsim/compute/last_row.sim b/tests/script/tsim/compute/last_row.sim index 867f64fa2e..590fada86a 100644 --- a/tests/script/tsim/compute/last_row.sim +++ b/tests/script/tsim/compute/last_row.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i @@ -53,6 +51,7 @@ endi print =============== step3 $cc = 4 * 60000 $ms = 1601481600000 + $cc +print select last_row(tbcol) from $tb where ts <= $ms sql select last_row(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 4 then @@ -98,8 +97,6 @@ if $data00 != 4 then return -1 endi - - print =============== step10 sql select last_row(tbcol) as b from $mt group by tgcol print ===> $data00 diff --git a/tests/script/tsim/compute/leastsquare.sim b/tests/script/tsim/compute/leastsquare.sim index aa83a4e14e..59a5213620 100644 --- a/tests/script/tsim/compute/leastsquare.sim +++ b/tests/script/tsim/compute/leastsquare.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i @@ -65,21 +63,21 @@ endi print =============== step5 sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then return -1 endi sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then return -1 endi print =============== step6 sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then return -1 endi print ===> $rows diff --git a/tests/script/tsim/compute/max.sim b/tests/script/tsim/compute/max.sim index 1b3fac5820..7101359026 100644 --- a/tests/script/tsim/compute/max.sim +++ b/tests/script/tsim/compute/max.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i @@ -69,14 +67,14 @@ endi print =============== step5 sql select max(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select max(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 19 then +print ===> $data00 +if $data00 != 19 then return -1 endi @@ -85,8 +83,8 @@ $cc = 4 * 60000 $ms = 1601481600000 + $cc sql select max(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi if $rows != 5 then @@ -127,14 +125,14 @@ endi print =============== step9 sql select max(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then +print ===> $data10 +if $data10 != 1 then return -1 endi sql select max(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 19 then +print ===> $data00 +if $data00 != 19 then return -1 endi @@ -153,9 +151,9 @@ print =============== step11 $cc = 4 * 60000 $ms = 1601481600000 + $cc -sql select max(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then +sql select max(tbcol) as b from $mt where ts <= $ms partition by tgcol interval(1m) +print ===> $data10 +if $data10 != 1 then return -1 endi print ===> $rows diff --git a/tests/script/tsim/compute/null.sim b/tests/script/tsim/compute/null.sim index 30860da48b..b5647a1e34 100644 --- a/tests/script/tsim/compute/null.sim +++ b/tests/script/tsim/compute/null.sim @@ -100,9 +100,10 @@ if $rows != 1 then return -1 endi -sql_error select * from $tb where tbcol = NULL - -return +sql select * from $tb where tbcol = NULL +if $rows != 0 then + return -1 +endi print =============== step5 sql create table tt using $mt tags( NULL ) From 9b5f662275a28e9b05c1d19e0d767492cde3b72c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 15:16:18 +0800 Subject: [PATCH 44/65] test: restore some 2.0 case --- tests/script/tsim/cache/new_metrics.sim | 4 ---- tests/script/tsim/cache/restart_metrics.sim | 2 -- tests/script/tsim/cache/restart_table.sim | 2 -- tests/script/tsim/compress/commitlog.sim | 10 +--------- tests/script/tsim/compute/avg.sim | 2 -- tests/script/tsim/compute/block_dist.sim | 2 -- tests/script/tsim/compute/diff.sim | 2 -- tests/script/tsim/compute/last.sim | 2 -- tests/script/tsim/compute/min.sim | 2 -- tests/script/tsim/compute/percentile.sim | 2 -- tests/script/tsim/compute/stddev.sim | 2 -- tests/script/tsim/compute/sum.sim | 2 -- tests/script/tsim/compute/top.sim | 2 -- tests/script/tsim/tag/bigint.sim | 1 - tests/script/tsim/tag/binary.sim | 1 - tests/script/tsim/tag/bool.sim | 1 - tests/script/tsim/tag/double.sim | 1 - tests/script/tsim/tag/float.sim | 1 - tests/script/tsim/tag/int.sim | 1 - tests/script/tsim/tag/smallint.sim | 1 - tests/script/tsim/tag/tinyint.sim | 1 - tests/script/tsim/vector/metrics_field.sim | 2 -- tests/script/tsim/vector/metrics_mix.sim | 2 -- tests/script/tsim/vector/metrics_query.sim | 2 -- tests/script/tsim/vector/metrics_tag.sim | 2 -- tests/script/tsim/vector/metrics_time.sim | 2 -- tests/script/tsim/vector/multi.sim | 2 -- tests/script/tsim/vector/single.sim | 2 -- tests/script/tsim/vector/table_field.sim | 2 -- tests/script/tsim/vector/table_mix.sim | 2 -- tests/script/tsim/vector/table_query.sim | 2 -- tests/script/tsim/vector/table_time.sim | 2 -- 32 files changed, 1 insertion(+), 65 deletions(-) diff --git a/tests/script/tsim/cache/new_metrics.sim b/tests/script/tsim/cache/new_metrics.sim index af7db90070..82d7d43e0f 100644 --- a/tests/script/tsim/cache/new_metrics.sim +++ b/tests/script/tsim/cache/new_metrics.sim @@ -83,10 +83,6 @@ while $i < 10 $i = $i + 1 endw -print ==> sleep 1 seconds to renew cache -sql reset query cache -sleep 1000 - print =============== step5 sql select * from $tb order by ts desc print ===>rows $rows, data $data01 diff --git a/tests/script/tsim/cache/restart_metrics.sim b/tests/script/tsim/cache/restart_metrics.sim index e144a49bf7..e346357633 100644 --- a/tests/script/tsim/cache/restart_metrics.sim +++ b/tests/script/tsim/cache/restart_metrics.sim @@ -48,9 +48,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start print =============== step3 -print ==> sleep 1 seconds to renew cache sql reset query cache -sleep 1000 print =============== step4 sql create database $db diff --git a/tests/script/tsim/cache/restart_table.sim b/tests/script/tsim/cache/restart_table.sim index b450f6c654..d28ef51419 100644 --- a/tests/script/tsim/cache/restart_table.sim +++ b/tests/script/tsim/cache/restart_table.sim @@ -32,9 +32,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start print =============== step3 -print ==> sleep 1 seconds to renew cache sql reset query cache -sleep 1000 print =============== step4 sql create database $db diff --git a/tests/script/tsim/compress/commitlog.sim b/tests/script/tsim/compress/commitlog.sim index d90780bd6c..bc9c231a9e 100644 --- a/tests/script/tsim/compress/commitlog.sim +++ b/tests/script/tsim/compress/commitlog.sim @@ -57,15 +57,7 @@ $tb = $tbPrefix . $i sql create database $db sql use $db - -$x = 0 -step3: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) -x step3 +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) $count = 0 while $count < $N diff --git a/tests/script/tsim/compute/avg.sim b/tests/script/tsim/compute/avg.sim index 50a0aeffb0..c366de5f4c 100644 --- a/tests/script/tsim/compute/avg.sim +++ b/tests/script/tsim/compute/avg.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/block_dist.sim b/tests/script/tsim/compute/block_dist.sim index 201d222af7..1583e838c6 100644 --- a/tests/script/tsim/compute/block_dist.sim +++ b/tests/script/tsim/compute/block_dist.sim @@ -47,8 +47,6 @@ while $x < $rowNum $x = $x + 1 endw -sleep 100 - print =============== step2 $i = 0 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/diff.sim b/tests/script/tsim/compute/diff.sim index f11fc92b2b..6043f18b27 100644 --- a/tests/script/tsim/compute/diff.sim +++ b/tests/script/tsim/compute/diff.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/last.sim b/tests/script/tsim/compute/last.sim index ae6f016b08..6080a2fa97 100644 --- a/tests/script/tsim/compute/last.sim +++ b/tests/script/tsim/compute/last.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/min.sim b/tests/script/tsim/compute/min.sim index 33e9eb0f3e..1ffdf19ac2 100644 --- a/tests/script/tsim/compute/min.sim +++ b/tests/script/tsim/compute/min.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/percentile.sim b/tests/script/tsim/compute/percentile.sim index 5cba3ad856..93b4640442 100644 --- a/tests/script/tsim/compute/percentile.sim +++ b/tests/script/tsim/compute/percentile.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/stddev.sim b/tests/script/tsim/compute/stddev.sim index 7048399112..dbdcde9a16 100644 --- a/tests/script/tsim/compute/stddev.sim +++ b/tests/script/tsim/compute/stddev.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/sum.sim b/tests/script/tsim/compute/sum.sim index c53568f98f..950b861b4c 100644 --- a/tests/script/tsim/compute/sum.sim +++ b/tests/script/tsim/compute/sum.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/compute/top.sim b/tests/script/tsim/compute/top.sim index 9899a8a9ea..d10b3803e3 100644 --- a/tests/script/tsim/compute/top.sim +++ b/tests/script/tsim/compute/top.sim @@ -38,8 +38,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/tag/bigint.sim b/tests/script/tsim/tag/bigint.sim index 813387eb38..565688270c 100644 --- a/tests/script/tsim/tag/bigint.sim +++ b/tests/script/tsim/tag/bigint.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/binary.sim b/tests/script/tsim/tag/binary.sim index 6ede988954..f3f89d6659 100644 --- a/tests/script/tsim/tag/binary.sim +++ b/tests/script/tsim/tag/binary.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/bool.sim b/tests/script/tsim/tag/bool.sim index 356269e1e1..25c7b2d967 100644 --- a/tests/script/tsim/tag/bool.sim +++ b/tests/script/tsim/tag/bool.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/double.sim b/tests/script/tsim/tag/double.sim index fedc1c89ec..b8292b64e8 100644 --- a/tests/script/tsim/tag/double.sim +++ b/tests/script/tsim/tag/double.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/float.sim b/tests/script/tsim/tag/float.sim index 0ed12d2269..26a09e2973 100644 --- a/tests/script/tsim/tag/float.sim +++ b/tests/script/tsim/tag/float.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/int.sim b/tests/script/tsim/tag/int.sim index e561cde56a..13255eb2ba 100644 --- a/tests/script/tsim/tag/int.sim +++ b/tests/script/tsim/tag/int.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/smallint.sim b/tests/script/tsim/tag/smallint.sim index 47e28db46c..70c5ee0771 100644 --- a/tests/script/tsim/tag/smallint.sim +++ b/tests/script/tsim/tag/smallint.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/tag/tinyint.sim b/tests/script/tsim/tag/tinyint.sim index 0941c9cf18..b7f7616cf4 100644 --- a/tests/script/tsim/tag/tinyint.sim +++ b/tests/script/tsim/tag/tinyint.sim @@ -46,7 +46,6 @@ while $i < 10 endw print =============== step2 -sleep 100 sql select * from $tb if $rows != $rowNum then return -1 diff --git a/tests/script/tsim/vector/metrics_field.sim b/tests/script/tsim/vector/metrics_field.sim index 4d0f9e19fc..b75ba9cffe 100644 --- a/tests/script/tsim/vector/metrics_field.sim +++ b/tests/script/tsim/vector/metrics_field.sim @@ -41,8 +41,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/metrics_mix.sim b/tests/script/tsim/vector/metrics_mix.sim index fd36a62332..fa93f0b2e3 100644 --- a/tests/script/tsim/vector/metrics_mix.sim +++ b/tests/script/tsim/vector/metrics_mix.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/metrics_query.sim b/tests/script/tsim/vector/metrics_query.sim index 8a334acef2..5d433486e8 100644 --- a/tests/script/tsim/vector/metrics_query.sim +++ b/tests/script/tsim/vector/metrics_query.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/metrics_tag.sim b/tests/script/tsim/vector/metrics_tag.sim index 0b275336f9..c8380590d5 100644 --- a/tests/script/tsim/vector/metrics_tag.sim +++ b/tests/script/tsim/vector/metrics_tag.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/metrics_time.sim b/tests/script/tsim/vector/metrics_time.sim index bcd93cb582..efa1ae4c84 100644 --- a/tests/script/tsim/vector/metrics_time.sim +++ b/tests/script/tsim/vector/metrics_time.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/multi.sim b/tests/script/tsim/vector/multi.sim index dcedbe73c9..1b592cdd0a 100644 --- a/tests/script/tsim/vector/multi.sim +++ b/tests/script/tsim/vector/multi.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/single.sim b/tests/script/tsim/vector/single.sim index c9d794456c..4da7c78110 100644 --- a/tests/script/tsim/vector/single.sim +++ b/tests/script/tsim/vector/single.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/table_field.sim b/tests/script/tsim/vector/table_field.sim index 5ad60b2a35..d5bdad8be2 100644 --- a/tests/script/tsim/vector/table_field.sim +++ b/tests/script/tsim/vector/table_field.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/table_mix.sim b/tests/script/tsim/vector/table_mix.sim index 358d6cf87f..79ecb09d81 100644 --- a/tests/script/tsim/vector/table_mix.sim +++ b/tests/script/tsim/vector/table_mix.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/table_query.sim b/tests/script/tsim/vector/table_query.sim index 0e4562716e..d69d16eba5 100644 --- a/tests/script/tsim/vector/table_query.sim +++ b/tests/script/tsim/vector/table_query.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/tsim/vector/table_time.sim b/tests/script/tsim/vector/table_time.sim index 1e6bdb2cde..f16c95ad4a 100644 --- a/tests/script/tsim/vector/table_time.sim +++ b/tests/script/tsim/vector/table_time.sim @@ -37,8 +37,6 @@ while $i < $tbNum $i = $i + 1 endw -sleep 100 - print =============== step2 $i = 1 $tb = $tbPrefix . $i From 68ced4523ef2aa1e66af4e60af4f9f7d01a6ceb9 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 15:21:02 +0800 Subject: [PATCH 45/65] test: restore some 2.0 case --- tests/script/jenkins/basic.txt | 27 +++++++++++++++++++ .../{general => tsim}/table/autocreate.sim | 0 .../{general => tsim}/table/back_insert.sim | 0 .../script/{general => tsim}/table/basic2.sim | 0 .../script/{general => tsim}/table/basic3.sim | 0 .../script/{general => tsim}/table/bigint.sim | 0 .../script/{general => tsim}/table/binary.sim | 0 tests/script/{general => tsim}/table/bool.sim | 0 .../{general => tsim}/table/column2.sim | 0 .../{general => tsim}/table/column_name.sim | 0 .../{general => tsim}/table/column_num.sim | 0 .../{general => tsim}/table/column_value.sim | 0 .../{general => tsim}/table/createmulti.sim | 0 tests/script/{general => tsim}/table/date.sim | 0 .../{general => tsim}/table/db.table.sim | 0 .../{general => tsim}/table/delete_reuse1.sim | 0 .../{general => tsim}/table/delete_reuse2.sim | 0 .../table/delete_writing.sim | 0 .../{general => tsim}/table/describe.sim | 0 .../script/{general => tsim}/table/double.sim | 0 .../script/{general => tsim}/table/float.sim | 0 tests/script/{general => tsim}/table/int.sim | 0 .../script/{general => tsim}/table/limit.sim | 0 .../{general => tsim}/table/smallint.sim | 0 .../script/{general => tsim}/table/table.sim | 0 .../{general => tsim}/table/table_len.sim | 0 .../{general => tsim}/table/testSuite.sim | 0 .../{general => tsim}/table/tinyint.sim | 0 .../script/{general => tsim}/table/vgroup.sim | 0 29 files changed, 27 insertions(+) rename tests/script/{general => tsim}/table/autocreate.sim (100%) rename tests/script/{general => tsim}/table/back_insert.sim (100%) rename tests/script/{general => tsim}/table/basic2.sim (100%) rename tests/script/{general => tsim}/table/basic3.sim (100%) rename tests/script/{general => tsim}/table/bigint.sim (100%) rename tests/script/{general => tsim}/table/binary.sim (100%) rename tests/script/{general => tsim}/table/bool.sim (100%) rename tests/script/{general => tsim}/table/column2.sim (100%) rename tests/script/{general => tsim}/table/column_name.sim (100%) rename tests/script/{general => tsim}/table/column_num.sim (100%) rename tests/script/{general => tsim}/table/column_value.sim (100%) rename tests/script/{general => tsim}/table/createmulti.sim (100%) rename tests/script/{general => tsim}/table/date.sim (100%) rename tests/script/{general => tsim}/table/db.table.sim (100%) rename tests/script/{general => tsim}/table/delete_reuse1.sim (100%) rename tests/script/{general => tsim}/table/delete_reuse2.sim (100%) rename tests/script/{general => tsim}/table/delete_writing.sim (100%) rename tests/script/{general => tsim}/table/describe.sim (100%) rename tests/script/{general => tsim}/table/double.sim (100%) rename tests/script/{general => tsim}/table/float.sim (100%) rename tests/script/{general => tsim}/table/int.sim (100%) rename tests/script/{general => tsim}/table/limit.sim (100%) rename tests/script/{general => tsim}/table/smallint.sim (100%) rename tests/script/{general => tsim}/table/table.sim (100%) rename tests/script/{general => tsim}/table/table_len.sim (100%) rename tests/script/{general => tsim}/table/testSuite.sim (100%) rename tests/script/{general => tsim}/table/tinyint.sim (100%) rename tests/script/{general => tsim}/table/vgroup.sim (100%) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 7ab2c644ee..2c7170d40b 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -103,7 +103,34 @@ ./test.sh -f tsim/show/basic.sim # ---- table +# ./test.sh -f tsim/table/autocreate.sim ./test.sh -f tsim/table/basic1.sim +# ./test.sh -f tsim/table/basic2.sim +# ./test.sh -f tsim/table/basic3.sim +# ./test.sh -f tsim/table/bigint.sim +# ./test.sh -f tsim/table/binary.sim +# ./test.sh -f tsim/table/bool.sim +# ./test.sh -f tsim/table/column_name.sim +# ./test.sh -f tsim/table/column_num.sim +# ./test.sh -f tsim/table/column_value.sim +# ./test.sh -f tsim/table/column2.sim +# ./test.sh -f tsim/table/createmulti.sim +# ./test.sh -f tsim/table/date.sim +# ./test.sh -f tsim/table/db.table.sim +# ./test.sh -f tsim/table/delete_reuse1.sim +# ./test.sh -f tsim/table/delete_reuse2.sim +# ./test.sh -f tsim/table/delete_writing.sim +# ./test.sh -f tsim/table/describe.sim +# ./test.sh -f tsim/table/double.sim +# ./test.sh -f tsim/table/fill.sim +# ./test.sh -f tsim/table/float.sim +# ./test.sh -f tsim/table/int.sim +# ./test.sh -f tsim/table/limit.sim +# ./test.sh -f tsim/table/smallint.sim +# ./test.sh -f tsim/table/table_len.sim +# ./test.sh -f tsim/table/table.sim +# ./test.sh -f tsim/table/tinyint.sim +# ./test.sh -f tsim/table/vgroup.sim # ---- stream ./test.sh -f tsim/stream/basic0.sim diff --git a/tests/script/general/table/autocreate.sim b/tests/script/tsim/table/autocreate.sim similarity index 100% rename from tests/script/general/table/autocreate.sim rename to tests/script/tsim/table/autocreate.sim diff --git a/tests/script/general/table/back_insert.sim b/tests/script/tsim/table/back_insert.sim similarity index 100% rename from tests/script/general/table/back_insert.sim rename to tests/script/tsim/table/back_insert.sim diff --git a/tests/script/general/table/basic2.sim b/tests/script/tsim/table/basic2.sim similarity index 100% rename from tests/script/general/table/basic2.sim rename to tests/script/tsim/table/basic2.sim diff --git a/tests/script/general/table/basic3.sim b/tests/script/tsim/table/basic3.sim similarity index 100% rename from tests/script/general/table/basic3.sim rename to tests/script/tsim/table/basic3.sim diff --git a/tests/script/general/table/bigint.sim b/tests/script/tsim/table/bigint.sim similarity index 100% rename from tests/script/general/table/bigint.sim rename to tests/script/tsim/table/bigint.sim diff --git a/tests/script/general/table/binary.sim b/tests/script/tsim/table/binary.sim similarity index 100% rename from tests/script/general/table/binary.sim rename to tests/script/tsim/table/binary.sim diff --git a/tests/script/general/table/bool.sim b/tests/script/tsim/table/bool.sim similarity index 100% rename from tests/script/general/table/bool.sim rename to tests/script/tsim/table/bool.sim diff --git a/tests/script/general/table/column2.sim b/tests/script/tsim/table/column2.sim similarity index 100% rename from tests/script/general/table/column2.sim rename to tests/script/tsim/table/column2.sim diff --git a/tests/script/general/table/column_name.sim b/tests/script/tsim/table/column_name.sim similarity index 100% rename from tests/script/general/table/column_name.sim rename to tests/script/tsim/table/column_name.sim diff --git a/tests/script/general/table/column_num.sim b/tests/script/tsim/table/column_num.sim similarity index 100% rename from tests/script/general/table/column_num.sim rename to tests/script/tsim/table/column_num.sim diff --git a/tests/script/general/table/column_value.sim b/tests/script/tsim/table/column_value.sim similarity index 100% rename from tests/script/general/table/column_value.sim rename to tests/script/tsim/table/column_value.sim diff --git a/tests/script/general/table/createmulti.sim b/tests/script/tsim/table/createmulti.sim similarity index 100% rename from tests/script/general/table/createmulti.sim rename to tests/script/tsim/table/createmulti.sim diff --git a/tests/script/general/table/date.sim b/tests/script/tsim/table/date.sim similarity index 100% rename from tests/script/general/table/date.sim rename to tests/script/tsim/table/date.sim diff --git a/tests/script/general/table/db.table.sim b/tests/script/tsim/table/db.table.sim similarity index 100% rename from tests/script/general/table/db.table.sim rename to tests/script/tsim/table/db.table.sim diff --git a/tests/script/general/table/delete_reuse1.sim b/tests/script/tsim/table/delete_reuse1.sim similarity index 100% rename from tests/script/general/table/delete_reuse1.sim rename to tests/script/tsim/table/delete_reuse1.sim diff --git a/tests/script/general/table/delete_reuse2.sim b/tests/script/tsim/table/delete_reuse2.sim similarity index 100% rename from tests/script/general/table/delete_reuse2.sim rename to tests/script/tsim/table/delete_reuse2.sim diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/tsim/table/delete_writing.sim similarity index 100% rename from tests/script/general/table/delete_writing.sim rename to tests/script/tsim/table/delete_writing.sim diff --git a/tests/script/general/table/describe.sim b/tests/script/tsim/table/describe.sim similarity index 100% rename from tests/script/general/table/describe.sim rename to tests/script/tsim/table/describe.sim diff --git a/tests/script/general/table/double.sim b/tests/script/tsim/table/double.sim similarity index 100% rename from tests/script/general/table/double.sim rename to tests/script/tsim/table/double.sim diff --git a/tests/script/general/table/float.sim b/tests/script/tsim/table/float.sim similarity index 100% rename from tests/script/general/table/float.sim rename to tests/script/tsim/table/float.sim diff --git a/tests/script/general/table/int.sim b/tests/script/tsim/table/int.sim similarity index 100% rename from tests/script/general/table/int.sim rename to tests/script/tsim/table/int.sim diff --git a/tests/script/general/table/limit.sim b/tests/script/tsim/table/limit.sim similarity index 100% rename from tests/script/general/table/limit.sim rename to tests/script/tsim/table/limit.sim diff --git a/tests/script/general/table/smallint.sim b/tests/script/tsim/table/smallint.sim similarity index 100% rename from tests/script/general/table/smallint.sim rename to tests/script/tsim/table/smallint.sim diff --git a/tests/script/general/table/table.sim b/tests/script/tsim/table/table.sim similarity index 100% rename from tests/script/general/table/table.sim rename to tests/script/tsim/table/table.sim diff --git a/tests/script/general/table/table_len.sim b/tests/script/tsim/table/table_len.sim similarity index 100% rename from tests/script/general/table/table_len.sim rename to tests/script/tsim/table/table_len.sim diff --git a/tests/script/general/table/testSuite.sim b/tests/script/tsim/table/testSuite.sim similarity index 100% rename from tests/script/general/table/testSuite.sim rename to tests/script/tsim/table/testSuite.sim diff --git a/tests/script/general/table/tinyint.sim b/tests/script/tsim/table/tinyint.sim similarity index 100% rename from tests/script/general/table/tinyint.sim rename to tests/script/tsim/table/tinyint.sim diff --git a/tests/script/general/table/vgroup.sim b/tests/script/tsim/table/vgroup.sim similarity index 100% rename from tests/script/general/table/vgroup.sim rename to tests/script/tsim/table/vgroup.sim From bfb2900c19c7cafeb395a6b877843a460578ecd5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 15:24:48 +0800 Subject: [PATCH 46/65] test: restore some 2.0 case --- tests/script/tsim/table/autocreate.sim | 1 - tests/script/tsim/table/basic2.sim | 1 - tests/script/tsim/table/basic3.sim | 3 +-- tests/script/tsim/table/bigint.sim | 5 +---- tests/script/tsim/table/binary.sim | 5 +---- tests/script/tsim/table/bool.sim | 5 +---- tests/script/tsim/table/column2.sim | 5 +---- tests/script/tsim/table/column_name.sim | 5 +---- tests/script/tsim/table/column_num.sim | 5 +---- tests/script/tsim/table/column_value.sim | 5 +---- tests/script/tsim/table/createmulti.sim | 1 - tests/script/tsim/table/date.sim | 5 +---- tests/script/tsim/table/db.table.sim | 5 +---- tests/script/tsim/table/describe.sim | 5 +---- tests/script/tsim/table/double.sim | 5 +---- tests/script/tsim/table/float.sim | 5 +---- tests/script/tsim/table/int.sim | 5 +---- tests/script/tsim/table/limit.sim | 7 +----- tests/script/tsim/table/smallint.sim | 5 +---- tests/script/tsim/table/table.sim | 5 +---- tests/script/tsim/table/table_len.sim | 5 +---- tests/script/tsim/table/testSuite.sim | 27 ------------------------ tests/script/tsim/table/tinyint.sim | 5 +---- tests/script/tsim/table/vgroup.sim | 8 ++----- 24 files changed, 21 insertions(+), 112 deletions(-) delete mode 100644 tests/script/tsim/table/testSuite.sim diff --git a/tests/script/tsim/table/autocreate.sim b/tests/script/tsim/table/autocreate.sim index 404c714ab4..70d58483a2 100644 --- a/tests/script/tsim/table/autocreate.sim +++ b/tests/script/tsim/table/autocreate.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 2000 sql connect print =============== create database diff --git a/tests/script/tsim/table/basic2.sim b/tests/script/tsim/table/basic2.sim index 4286f9ee4a..737d5a3efe 100644 --- a/tests/script/tsim/table/basic2.sim +++ b/tests/script/tsim/table/basic2.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 2000 sql connect print =============== one table diff --git a/tests/script/tsim/table/basic3.sim b/tests/script/tsim/table/basic3.sim index 41c276ae98..21470affa8 100644 --- a/tests/script/tsim/table/basic3.sim +++ b/tests/script/tsim/table/basic3.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 2000 sql connect print =============== create database @@ -73,7 +72,7 @@ endi print =============== drop stable sql drop table db.st sql show db.stables -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/bigint.sim b/tests/script/tsim/table/bigint.sim index d75f406d77..4611db112f 100644 --- a/tests/script/tsim/table/bigint.sim +++ b/tests/script/tsim/table/bigint.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -66,7 +63,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/binary.sim b/tests/script/tsim/table/binary.sim index 47915530ef..a2cfc77796 100644 --- a/tests/script/tsim/table/binary.sim +++ b/tests/script/tsim/table/binary.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -56,7 +53,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/bool.sim b/tests/script/tsim/table/bool.sim index e49637448f..454bf47d33 100644 --- a/tests/script/tsim/table/bool.sim +++ b/tests/script/tsim/table/bool.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -85,7 +82,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/column2.sim b/tests/script/tsim/table/column2.sim index 441766f2d4..e540835c14 100644 --- a/tests/script/tsim/table/column2.sim +++ b/tests/script/tsim/table/column2.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print =============== step1 @@ -19,7 +16,7 @@ endi sql drop database db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/column_name.sim b/tests/script/tsim/table/column_name.sim index 47fcfab5a8..bad6c95bb1 100644 --- a/tests/script/tsim/table/column_name.sim +++ b/tests/script/tsim/table/column_name.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -79,7 +76,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/column_num.sim b/tests/script/tsim/table/column_num.sim index a18173bc8f..0a5d151adf 100644 --- a/tests/script/tsim/table/column_num.sim +++ b/tests/script/tsim/table/column_num.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -78,7 +75,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/column_value.sim b/tests/script/tsim/table/column_value.sim index 1edf8c2992..861e2f1a8d 100644 --- a/tests/script/tsim/table/column_value.sim +++ b/tests/script/tsim/table/column_value.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -68,7 +65,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/createmulti.sim b/tests/script/tsim/table/createmulti.sim index 0da1ce96a7..efdb276c94 100644 --- a/tests/script/tsim/table/createmulti.sim +++ b/tests/script/tsim/table/createmulti.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 sql connect print =============== create database diff --git a/tests/script/tsim/table/date.sim b/tests/script/tsim/table/date.sim index 23188e12e0..218049d329 100644 --- a/tests/script/tsim/table/date.sim +++ b/tests/script/tsim/table/date.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -83,7 +80,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/db.table.sim b/tests/script/tsim/table/db.table.sim index 906396402a..b5d8294b6e 100644 --- a/tests/script/tsim/table/db.table.sim +++ b/tests/script/tsim/table/db.table.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -40,7 +37,7 @@ sql drop table $table sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/describe.sim b/tests/script/tsim/table/describe.sim index e59371e530..28690e5794 100644 --- a/tests/script/tsim/table/describe.sim +++ b/tests/script/tsim/table/describe.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -42,7 +39,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/double.sim b/tests/script/tsim/table/double.sim index ab3f2428bd..08f0dc7663 100644 --- a/tests/script/tsim/table/double.sim +++ b/tests/script/tsim/table/double.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -91,7 +88,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/float.sim b/tests/script/tsim/table/float.sim index 2d0ea0e5ea..c53b4bb1a4 100644 --- a/tests/script/tsim/table/float.sim +++ b/tests/script/tsim/table/float.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -91,7 +88,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/int.sim b/tests/script/tsim/table/int.sim index f30b5b28f5..f84858c7d0 100644 --- a/tests/script/tsim/table/int.sim +++ b/tests/script/tsim/table/int.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -127,7 +124,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/limit.sim b/tests/script/tsim/table/limit.sim index dd38453d0c..0a07ee3efa 100644 --- a/tests/script/tsim/table/limit.sim +++ b/tests/script/tsim/table/limit.sim @@ -1,11 +1,6 @@ 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 129 -system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 8 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ============================ dnode1 start @@ -87,7 +82,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/smallint.sim b/tests/script/tsim/table/smallint.sim index f622ce7853..c81681c316 100644 --- a/tests/script/tsim/table/smallint.sim +++ b/tests/script/tsim/table/smallint.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -98,7 +95,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/table.sim b/tests/script/tsim/table/table.sim index c9806c40c6..6a706c979f 100644 --- a/tests/script/tsim/table/table.sim +++ b/tests/script/tsim/table/table.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect print ============================ dnode1 start @@ -217,7 +214,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/table_len.sim b/tests/script/tsim/table/table_len.sim index d95c9ab0aa..e48c5d419e 100644 --- a/tests/script/tsim/table/table_len.sim +++ b/tests/script/tsim/table/table_len.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -98,7 +95,7 @@ step8: sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/testSuite.sim b/tests/script/tsim/table/testSuite.sim deleted file mode 100644 index d6cc88b36a..0000000000 --- a/tests/script/tsim/table/testSuite.sim +++ /dev/null @@ -1,27 +0,0 @@ -run general/table/autocreate.sim -run general/table/basic1.sim -run general/table/basic2.sim -run general/table/basic3.sim -run general/table/bigint.sim -run general/table/binary.sim -run general/table/bool.sim -run general/table/column_name.sim -run general/table/column_num.sim -run general/table/column_value.sim -run general/table/column2.sim -run general/table/date.sim -run general/table/db.table.sim -run general/table/delete_reuse1.sim -run general/table/delete_reuse2.sim -run general/table/delete_writing.sim -run general/table/describe.sim -run general/table/double.sim -run general/table/fill.sim -run general/table/float.sim -run general/table/int.sim -run general/table/limit.sim -run general/table/smallint.sim -run general/table/table_len.sim -run general/table/table.sim -run general/table/tinyint.sim -run general/table/vgroup.sim diff --git a/tests/script/tsim/table/tinyint.sim b/tests/script/tsim/table/tinyint.sim index afa931fc79..089fab0bfa 100644 --- a/tests/script/tsim/table/tinyint.sim +++ b/tests/script/tsim/table/tinyint.sim @@ -1,9 +1,6 @@ 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/exec.sh -n dnode1 -s start - -sleep 2000 sql connect $i = 0 @@ -97,7 +94,7 @@ endi sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/table/vgroup.sim b/tests/script/tsim/table/vgroup.sim index d306a4731d..902415400e 100644 --- a/tests/script/tsim/table/vgroup.sim +++ b/tests/script/tsim/table/vgroup.sim @@ -1,12 +1,8 @@ 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 maxVgroupsPerDb -v 4 -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start - -sleep 2000 sql connect + print ============================ dnode1 start $i = 0 @@ -144,7 +140,7 @@ while $i < 5 $i = $i + 1 endw sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi From 9ea0ad57ec3d82bfbcaaac380f9d6454e5acdd0b Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 14 Jul 2022 15:32:21 +0800 Subject: [PATCH 47/65] refactor(stream): destroy stream task --- source/client/src/tmq.c | 2 +- source/dnode/mnode/impl/src/mndStream.c | 16 +++- source/dnode/vnode/src/tq/tq.c | 61 +++++++++------ source/dnode/vnode/src/tq/tqRead.c | 13 +++ source/dnode/vnode/src/tq/tqSink.c | 2 +- source/libs/executor/inc/executorimpl.h | 1 - source/libs/executor/src/executorMain.c | 9 +-- source/libs/executor/src/scanoperator.c | 43 +++++++--- source/libs/stream/src/streamExec.c | 100 ++++++++++++------------ source/libs/stream/src/streamTask.c | 2 +- 10 files changed, 152 insertions(+), 97 deletions(-) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index b0542e350f..0d9cd4bcff 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -343,7 +343,7 @@ tmq_list_t* tmq_list_new() { int32_t tmq_list_append(tmq_list_t* list, const char* src) { SArray* container = &list->container; - char* topic = strDupUnquo(src); + char* topic = strdup(src); if (taosArrayPush(container, &topic) == NULL) return -1; return 0; } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index c2125f75f8..5777df4fa6 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -235,7 +235,8 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64 } static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, SCMCreateStreamReq *pCreate) { - SNode *pAst = NULL; + SNode *pAst = NULL; + SQueryPlan *pPlan = NULL; mDebug("stream:%s to create", pCreate->name); memcpy(pObj->name, pCreate->name, TSDB_STREAM_FNAME_LEN); @@ -293,7 +294,6 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, goto FAIL; } - SQueryPlan *pPlan = NULL; SPlanContext cxt = { .pAstRoot = pAst, .topicQuery = false, @@ -317,6 +317,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, FAIL: if (pAst != NULL) nodesDestroyNode(pAst); + if (pPlan != NULL) qDestroyQueryPlan(pPlan); return 0; } @@ -541,7 +542,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { // build stream obj from request SStreamObj streamObj = {0}; if (mndBuildStreamObjFromCreateReq(pMnode, &streamObj, &createStreamReq) < 0) { - ASSERT(0); + /*ASSERT(0);*/ mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr()); goto _OVER; } @@ -689,7 +690,14 @@ int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST; return -1; } else { - // TODO drop all task on snode +#if 0 + if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { + mError("stream:%s, failed to drop task since %s", pStream->name, terrstr()); + sdbRelease(pMnode->pSdb, pStream); + sdbCancelFetch(pSdb, pIter); + return -1; + } +#endif if (mndPersistDropStreamLog(pMnode, pTrans, pStream) < 0) { sdbRelease(pSdb, pStream); sdbCancelFetch(pSdb, pIter); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index df80a4c218..3b6e9abc67 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -82,6 +82,13 @@ void tqClose(STQ* pTq) { if (pTq) { tqOffsetClose(pTq->pOffsetStore); taosHashCleanup(pTq->handles); + void* pIter = NULL; + while (1) { + pIter = taosHashIterate(pTq->pStreamTasks, pIter); + if (pIter == NULL) break; + SStreamTask* pTask = *(SStreamTask**)pIter; + tFreeSStreamTask(pTask); + } taosHashCleanup(pTq->pStreamTasks); taosHashCleanup(pTq->pushMgr); taosMemoryFree(pTq->path); @@ -608,7 +615,8 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { streamSetupTrigger(pTask); - tqInfo("deploy stream task id %d child id %d on vgId:%d", pTask->taskId, pTask->selfChildId, TD_VID(pTq->pVnode)); + tqInfo("deploy stream task on vg %d, task id %d, child id %d", TD_VID(pTq->pVnode), pTask->taskId, + pTask->selfChildId); taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)); @@ -634,9 +642,6 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) { pIter = taosHashIterate(pTq->pStreamTasks, pIter); if (pIter == NULL) break; SStreamTask* pTask = *(SStreamTask**)pIter; - if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { - continue; - } if (!pTask->isDataScan) continue; if (!failed) { @@ -665,11 +670,12 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRunReq* pReq = pMsg->pCont; int32_t taskId = pReq->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + if (pTask) { + streamProcessRunReq(pTask); return 0; + } else { + return -1; } - streamProcessRunReq(pTask); - return 0; } int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) { @@ -682,55 +688,62 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) { tDecodeStreamDispatchReq(&decoder, &req); int32_t taskId = req.taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + if (pTask) { + SRpcMsg rsp = { + .info = pMsg->info, + .code = 0, + }; + streamProcessDispatchReq(pTask, &req, &rsp); return 0; + } else { + return -1; } - SRpcMsg rsp = { - .info = pMsg->info, - .code = 0, - }; - streamProcessDispatchReq(pTask, &req, &rsp); - return 0; } int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverReq* pReq = pMsg->pCont; int32_t taskId = pReq->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + if (pTask) { + streamProcessRecoverReq(pTask, pReq, pMsg); return 0; + } else { + return -1; } - streamProcessRecoverReq(pTask, pReq, pMsg); - return 0; } int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); int32_t taskId = pRsp->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + if (pTask) { + streamProcessDispatchRsp(pTask, pRsp); return 0; + } else { + return -1; } - streamProcessDispatchRsp(pTask, pRsp); - return 0; } int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverRsp* pRsp = pMsg->pCont; int32_t taskId = pRsp->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + if (pTask) { + streamProcessRecoverRsp(pTask, pRsp); return 0; + } else { + return -1; } - streamProcessRecoverRsp(pTask, pRsp); - return 0; } int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) { SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t)); - atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING); + if (pTask) { + taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t)); + atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING); + } // todo // clear queue // push drop req into queue diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 8753ecc47c..dda306ccf8 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -98,8 +98,21 @@ STqReader* tqOpenReader(SVnode* pVnode) { void tqCloseReader(STqReader* pReader) { // close wal reader + if (pReader->pWalReader) { + walCloseReader(pReader->pWalReader); + } // free cached schema + if (pReader->pSchema) { + taosMemoryFree(pReader->pSchema); + } + if (pReader->pSchemaWrapper) { + tDeleteSSchemaWrapper(pReader->pSchemaWrapper); + } + if (pReader->pColIdList) { + taosArrayDestroy(pReader->pColIdList); + } // free hash + taosHashCleanup(pReader->tbIdHash); taosMemoryFree(pReader); } diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index dbbb2b2661..1980f826b0 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -146,7 +146,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo const STColumn* pColumn = &pTSchema->columns[k]; SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); if (colDataIsNull_s(pColData, j)) { - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k); + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k); } else { void* data = colDataGetData(pColData, j); tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 045b4379ca..24a2ad0558 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -147,7 +147,6 @@ typedef struct { SSDataBlock* pullOverBlk; // for streaming SWalFilterCond cond; int64_t lastScanUid; - SStreamQueue* inputQueue; } SStreamTaskInfo; typedef struct SExecTaskInfo { diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index 6381d20255..d910b8be34 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -44,13 +44,6 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, goto _error; } - if (model == OPTR_EXEC_MODEL_STREAM) { - (*pTask)->streamInfo.inputQueue = streamQueueOpen(); - if ((*pTask)->streamInfo.inputQueue == NULL) { - goto _error; - } - } - SDataSinkMgtCfg cfg = {.maxDataBlockNum = 1000, .maxDataBlockNumPerQuery = 100}; code = dsDataSinkMgtInit(&cfg); if (code != TSDB_CODE_SUCCESS) { @@ -259,12 +252,14 @@ int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) { } } +#if 0 int32_t qStreamInput(qTaskInfo_t tinfo, void* pItem) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); taosWriteQitem(pTaskInfo->streamInfo.inputQueue->queue, pItem); return 0; } +#endif void* qExtractReaderFromStreamScanner(void* scanner) { SStreamScanInfo* pInfo = scanner; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b14648991e..38ac6f942d 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -884,22 +884,22 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ return true; } -static STimeWindow getSlidingWindow(TSKEY* tsCol, SInterval* pInterval, SDataBlockInfo* pDataBlockInfo, int32_t* pRowIndex) { - SResultRowInfo dumyInfo; +static STimeWindow getSlidingWindow(TSKEY* tsCol, SInterval* pInterval, SDataBlockInfo* pDataBlockInfo, + int32_t* pRowIndex) { + SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; - STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[*pRowIndex], pInterval, - TSDB_ORDER_ASC); + STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC); STimeWindow endWin = win; STimeWindow preWin = win; while (1) { - (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, tsCol, *pRowIndex, endWin.ekey, - binarySearchForKey, NULL, TSDB_ORDER_ASC); + (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, tsCol, *pRowIndex, endWin.ekey, binarySearchForKey, NULL, + TSDB_ORDER_ASC); do { preWin = endWin; getNextTimeWindow(pInterval, &endWin, TSDB_ORDER_ASC); } while (tsCol[(*pRowIndex) - 1] >= endWin.skey); endWin = preWin; - if (win.ekey == endWin.ekey || (*pRowIndex) == pDataBlockInfo->rows ) { + if (win.ekey == endWin.ekey || (*pRowIndex) == pDataBlockInfo->rows) { win.ekey = endWin.ekey; return win; } @@ -933,7 +933,8 @@ static bool prepareDataScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32_t t pInfo->updateWin.ekey = tsCols[*pRowIndex - 1]; // win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[*pRowIndex], &pInfo->interval, TSDB_ORDER_ASC); // (*pRowIndex) += - // getNumOfRowsInTimeWindow(&pSDB->info, tsCols, *pRowIndex, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); + // getNumOfRowsInTimeWindow(&pSDB->info, tsCols, *pRowIndex, win.ekey, binarySearchForKey, NULL, + // TSDB_ORDER_ASC); } needRead = true; } else if (isStateWindow(pInfo)) { @@ -1447,6 +1448,28 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNo return NULL; } +static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) { + SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param; +#if 0 + if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) { + STableScanInfo* pTableScanInfo = pStreamScan->pTableScanOp->info; + destroyTableScanOperatorInfo(pTableScanInfo, 1); + } +#endif + if (pStreamScan->tqReader) { + tqCloseReader(pStreamScan->tqReader); + } + if (pStreamScan->pColMatchInfo) { + taosArrayDestroy(pStreamScan->pColMatchInfo); + } + blockDataDestroy(pStreamScan->pRes); + blockDataDestroy(pStreamScan->pUpdateRes); + blockDataDestroy(pStreamScan->pPullDataRes); + blockDataDestroy(pStreamScan->pDeleteDataRes); + taosArrayDestroy(pStreamScan->pBlockLists); + taosMemoryFree(pStreamScan); +} + SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup, uint64_t queryId, uint64_t taskId) { @@ -1561,8 +1584,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamScan, NULL, NULL, operatorDummyCloseFn, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamScan, NULL, NULL, destroyStreamScanOperatorInfo, + NULL, NULL, NULL); return pOperator; diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index d0d81e3343..635ae820fe 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -74,63 +74,62 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) } static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { + int32_t cnt = 0; + void* data = NULL; while (1) { - int32_t cnt = 0; - void* data = NULL; - while (1) { - SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputQueue); - if (qItem == NULL) { - qDebug("stream exec over, queue empty"); + SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputQueue); + if (qItem == NULL) { + qDebug("stream exec over, queue empty"); + break; + } + if (data == NULL) { + data = qItem; + streamQueueProcessSuccess(pTask->inputQueue); + continue; + } else { + if (streamAppendQueueItem(data, qItem) < 0) { + streamQueueProcessFail(pTask->inputQueue); break; - } - if (data == NULL) { - data = qItem; - streamQueueProcessSuccess(pTask->inputQueue); - continue; } else { - if (streamAppendQueueItem(data, qItem) < 0) { - streamQueueProcessFail(pTask->inputQueue); - break; - } else { - cnt++; - streamQueueProcessSuccess(pTask->inputQueue); - taosArrayDestroy(((SStreamDataBlock*)qItem)->blocks); - taosFreeQitem(qItem); - } + cnt++; + streamQueueProcessSuccess(pTask->inputQueue); + taosArrayDestroy(((SStreamDataBlock*)qItem)->blocks); + taosFreeQitem(qItem); } } - if (data == NULL) break; + } + if (pTask->taskStatus == TASK_STATUS__DROPPING) { + if (data) streamFreeQitem(data); + taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + return NULL; + } - qDebug("stream task %d exec begin, batch msg: %d", pTask->taskId, cnt); - streamTaskExecImpl(pTask, data, pRes); - qDebug("stream task %d exec end", pTask->taskId); + if (data == NULL) return pRes; - if (pTask->taskStatus == TASK_STATUS__DROPPING) { - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + qDebug("stream task %d exec begin, msg batch: %d", pTask->taskId, cnt); + streamTaskExecImpl(pTask, data, pRes); + qDebug("stream task %d exec end", pTask->taskId); + + if (taosArrayGetSize(pRes) != 0) { + SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); + if (qRes == NULL) { + streamQueueProcessFail(pTask->inputQueue); + taosArrayDestroy(pRes); return NULL; } - - if (taosArrayGetSize(pRes) != 0) { - SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); - if (qRes == NULL) { - streamQueueProcessFail(pTask->inputQueue); - taosArrayDestroy(pRes); - return NULL; - } - qRes->type = STREAM_INPUT__DATA_BLOCK; - qRes->blocks = pRes; - if (streamTaskOutput(pTask, qRes) < 0) { - /*streamQueueProcessFail(pTask->inputQueue);*/ - taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); - taosFreeQitem(qRes); - return NULL; - } - /*streamQueueProcessSuccess(pTask->inputQueue);*/ - pRes = taosArrayInit(0, sizeof(SSDataBlock)); + qRes->type = STREAM_INPUT__DATA_BLOCK; + qRes->blocks = pRes; + if (streamTaskOutput(pTask, qRes) < 0) { + /*streamQueueProcessFail(pTask->inputQueue);*/ + taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock); + taosFreeQitem(qRes); + return NULL; } - - streamFreeQitem(data); + /*streamQueueProcessSuccess(pTask->inputQueue);*/ + pRes = taosArrayInit(0, sizeof(SSDataBlock)); } + + streamFreeQitem(data); return pRes; } @@ -171,6 +170,11 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { } FAIL: if (pRes) taosArrayDestroy(pRes); - atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); - return -1; + if (pTask->taskStatus == TASK_STATUS__DROPPING) { + tFreeSStreamTask(pTask); + return 0; + } else { + atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); + return -1; + } } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 97aa182dc9..7488c009bd 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -163,6 +163,6 @@ void tFreeSStreamTask(SStreamTask* pTask) { streamQueueClose(pTask->inputQueue); streamQueueClose(pTask->outputQueue); if (pTask->exec.qmsg) taosMemoryFree(pTask->exec.qmsg); - qDestroyTask(pTask->exec.executor); + if (pTask->exec.executor) qDestroyTask(pTask->exec.executor); taosMemoryFree(pTask); } From 13230df94822b7da55387f889a694286f784cd2f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 15:51:59 +0800 Subject: [PATCH 48/65] test: restore some 2.0 case --- tests/script/jenkins/basic.txt | 47 +++++++++--------- tests/script/tsim/table/autocreate.sim | 2 +- tests/script/tsim/table/basic1.sim | 17 ------- tests/script/tsim/table/basic2.sim | 6 +-- tests/script/tsim/table/basic3.sim | 4 +- tests/script/tsim/table/createmulti.sim | 2 +- tests/script/tsim/table/date.sim | 16 +++--- tests/script/tsim/table/int.sim | 66 ++++++++++++------------- tests/script/tsim/table/limit.sim | 4 +- tests/script/tsim/table/smallint.sim | 50 +++++++++---------- tests/script/tsim/table/table.sim | 5 +- tests/script/tsim/table/tinyint.sim | 36 +++++++------- tests/script/tsim/table/vgroup.sim | 24 ++++----- 13 files changed, 126 insertions(+), 153 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2c7170d40b..4de8b3667d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -103,34 +103,33 @@ ./test.sh -f tsim/show/basic.sim # ---- table -# ./test.sh -f tsim/table/autocreate.sim +./test.sh -f tsim/table/autocreate.sim ./test.sh -f tsim/table/basic1.sim -# ./test.sh -f tsim/table/basic2.sim -# ./test.sh -f tsim/table/basic3.sim -# ./test.sh -f tsim/table/bigint.sim -# ./test.sh -f tsim/table/binary.sim -# ./test.sh -f tsim/table/bool.sim -# ./test.sh -f tsim/table/column_name.sim -# ./test.sh -f tsim/table/column_num.sim -# ./test.sh -f tsim/table/column_value.sim -# ./test.sh -f tsim/table/column2.sim -# ./test.sh -f tsim/table/createmulti.sim -# ./test.sh -f tsim/table/date.sim -# ./test.sh -f tsim/table/db.table.sim +./test.sh -f tsim/table/basic2.sim +./test.sh -f tsim/table/basic3.sim +./test.sh -f tsim/table/bigint.sim +./test.sh -f tsim/table/binary.sim +./test.sh -f tsim/table/bool.sim +./test.sh -f tsim/table/column_name.sim +./test.sh -f tsim/table/column_num.sim +./test.sh -f tsim/table/column_value.sim +./test.sh -f tsim/table/column2.sim +./test.sh -f tsim/table/createmulti.sim +./test.sh -f tsim/table/date.sim +./test.sh -f tsim/table/db.table.sim # ./test.sh -f tsim/table/delete_reuse1.sim # ./test.sh -f tsim/table/delete_reuse2.sim # ./test.sh -f tsim/table/delete_writing.sim -# ./test.sh -f tsim/table/describe.sim -# ./test.sh -f tsim/table/double.sim -# ./test.sh -f tsim/table/fill.sim -# ./test.sh -f tsim/table/float.sim -# ./test.sh -f tsim/table/int.sim -# ./test.sh -f tsim/table/limit.sim -# ./test.sh -f tsim/table/smallint.sim -# ./test.sh -f tsim/table/table_len.sim -# ./test.sh -f tsim/table/table.sim -# ./test.sh -f tsim/table/tinyint.sim -# ./test.sh -f tsim/table/vgroup.sim +./test.sh -f tsim/table/describe.sim +./test.sh -f tsim/table/double.sim +./test.sh -f tsim/table/float.sim +./test.sh -f tsim/table/int.sim +./test.sh -f tsim/table/limit.sim +./test.sh -f tsim/table/smallint.sim +./test.sh -f tsim/table/table_len.sim +./test.sh -f tsim/table/table.sim +./test.sh -f tsim/table/tinyint.sim +./test.sh -f tsim/table/vgroup.sim # ---- stream ./test.sh -f tsim/stream/basic0.sim diff --git a/tests/script/tsim/table/autocreate.sim b/tests/script/tsim/table/autocreate.sim index 70d58483a2..1267e33932 100644 --- a/tests/script/tsim/table/autocreate.sim +++ b/tests/script/tsim/table/autocreate.sim @@ -6,7 +6,7 @@ sql connect print =============== create database sql create database db sql show databases -if $rows != 1 then +if $rows != 3 then return -1 endi diff --git a/tests/script/tsim/table/basic1.sim b/tests/script/tsim/table/basic1.sim index 913ced74aa..6cb5bc54f7 100644 --- a/tests/script/tsim/table/basic1.sim +++ b/tests/script/tsim/table/basic1.sim @@ -213,23 +213,6 @@ endi system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - print =============== query data sql select * from c1 print rows: $rows diff --git a/tests/script/tsim/table/basic2.sim b/tests/script/tsim/table/basic2.sim index 737d5a3efe..297ae3d333 100644 --- a/tests/script/tsim/table/basic2.sim +++ b/tests/script/tsim/table/basic2.sim @@ -20,11 +20,11 @@ endi print =============== show sql show databases -if $data02 != 2 then +if $data22 != 2 then return -1 endi -if $data03 != 1 then +if $data24 != 1 then return -1 endi @@ -33,7 +33,7 @@ if $data00 != 2 then return -1 endi -if $data01 != 2 then +if $data01 != d1 then return -1 endi diff --git a/tests/script/tsim/table/basic3.sim b/tests/script/tsim/table/basic3.sim index 21470affa8..c9335b6d1b 100644 --- a/tests/script/tsim/table/basic3.sim +++ b/tests/script/tsim/table/basic3.sim @@ -6,7 +6,7 @@ sql connect print =============== create database sql create database db sql show databases -if $rows != 1 then +if $rows != 3 then return -1 endi @@ -72,7 +72,7 @@ endi print =============== drop stable sql drop table db.st sql show db.stables -if $rows != 2 then +if $rows != 0 then return -1 endi diff --git a/tests/script/tsim/table/createmulti.sim b/tests/script/tsim/table/createmulti.sim index efdb276c94..e204bd4f3d 100644 --- a/tests/script/tsim/table/createmulti.sim +++ b/tests/script/tsim/table/createmulti.sim @@ -6,7 +6,7 @@ sql connect print =============== create database sql create database db sql show databases -if $rows != 1 then +if $rows != 3 then return -1 endi diff --git a/tests/script/tsim/table/date.sim b/tests/script/tsim/table/date.sim index 218049d329..f2361cf4f5 100644 --- a/tests/script/tsim/table/date.sim +++ b/tests/script/tsim/table/date.sim @@ -24,18 +24,18 @@ if $data00 != @17-01-01 08:00:00.001@ then endi print =============== step2 -sql insert into $tb values ('2017-08-28 00:23:46.429+ 1a', 2) -#sql insert into $tb values ('2017-08-28 00:23:46cd .429', 2) +sql_error insert into $tb values ('2017-08-28 00:23:46.429+ 1a', 2) +sql_error insert into $tb values ('2017-08-28 00:23:46cd .429', 2) sql select ts from $tb -if $rows != 2 then +if $rows != 1 then return -1 endi print =============== step3 -#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) -#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) +sql_error insert into $tb values ('1970-01-01 08:00:00.000', 3) +sql_error insert into $tb values ('1970-01-01 08:00:00.000', 3) sql select ts from $tb -if $rows != 2 then +if $rows != 1 then return -1 endi @@ -54,7 +54,7 @@ print =============== step5 sql_error insert into $tb values ('9999-12-31 213:59:59.999', 13) sql select ts from $tb print $rows -if $rows != 8 then +if $rows != 7 then return -1 endi @@ -62,7 +62,7 @@ print =============== step6 sql_error insert into $tb values ('9999-12-99 23:59:59.999', 13) sql select ts from $tb -if $rows != 8 then +if $rows != 7 then return -1 endi diff --git a/tests/script/tsim/table/int.sim b/tests/script/tsim/table/int.sim index f84858c7d0..7e3cefc7ca 100644 --- a/tests/script/tsim/table/int.sim +++ b/tests/script/tsim/table/int.sim @@ -24,12 +24,10 @@ if $data01 != NULL then endi print =============== step2 -sql insert into $tb values (now+1m, -2147483648) -x step2 - return -1 -step2: -sql insert into $tb values (now+1m, NULL) +sql insert into $tb values (now+1m, -2147483648) +sql insert into $tb values (now+2m, NULL) sql select * from $tb order by ts desc -if $rows != 2 then +if $rows != 3 then return -1 endi if $data01 != NULL then @@ -37,9 +35,9 @@ if $data01 != NULL then endi print =============== step3 -sql insert into $tb values (now+2m, 2147483647) +sql insert into $tb values (now+3m, 2147483647) sql select * from $tb order by ts desc -if $rows != 3 then +if $rows != 4 then return -1 endi if $data01 != 2147483647 then @@ -47,12 +45,10 @@ if $data01 != 2147483647 then endi print =============== step4 -sql insert into $tb values (now+3m, 2147483648) -x step4 - return -1 -step4: -sql insert into $tb values (now+3m, NULL) +sql_error insert into $tb values (now+4m, 2147483648) +sql insert into $tb values (now+5m, NULL) sql select * from $tb order by ts desc -if $rows != 4 then +if $rows != 5 then return -1 endi if $data01 != NULL then @@ -60,10 +56,10 @@ if $data01 != NULL then endi print =============== step5 -sql_error insert into $tb values (now+4m, a2) -sql insert into $tb values (now+4m, 0) +sql_error insert into $tb values (now+6m, a2) +sql insert into $tb values (now+7m, 0) sql select * from $tb order by ts desc -if $rows != 5 then +if $rows != 6 then return -1 endi if $data01 != 0 then @@ -71,19 +67,8 @@ if $data01 != 0 then endi print =============== step6 -sql_error insert into $tb values (now+5m, 2a) -sql insert into $tb values (now+5m, 2) -sql select * from $tb order by ts desc -if $rows != 6 then - return -1 -endi -if $data01 != 2 then - return -1 -endi - -print =============== step7 -sql_error insert into $tb values (now+6m, 2a'1) -sql insert into $tb values (now+6m, 2) +sql_error insert into $tb values (now+8m, 2a) +sql insert into $tb values (now+9m, 2) sql select * from $tb order by ts desc if $rows != 7 then return -1 @@ -92,18 +77,19 @@ if $data01 != 2 then return -1 endi -print =============== step8 -sql insert into $tb values (now+8m, "NULL") +print =============== step7 +sql_error insert into $tb values (now+10m, 2a'1) +sql insert into $tb values (now+11m, 2) sql select * from $tb order by ts desc if $rows != 8 then return -1 endi -if $data01 != NULL then +if $data01 != 2 then return -1 endi -print =============== step9 -sql insert into $tb values (now+9m, 'NULL') +print =============== step8 +sql insert into $tb values (now+12m, "NULL") sql select * from $tb order by ts desc if $rows != 9 then return -1 @@ -112,12 +98,22 @@ if $data01 != NULL then return -1 endi -print =============== step10 -sql insert into $tb values (now+10m, -123) +print =============== step9 +sql insert into $tb values (now+13m, 'NULL') sql select * from $tb order by ts desc if $rows != 10 then return -1 endi +if $data01 != NULL then + return -1 +endi + +print =============== step10 +sql insert into $tb values (now+14m, -123) +sql select * from $tb order by ts desc +if $rows != 11 then + return -1 +endi if $data01 != -123 then return -1 endi diff --git a/tests/script/tsim/table/limit.sim b/tests/script/tsim/table/limit.sim index 0a07ee3efa..d20938367e 100644 --- a/tests/script/tsim/table/limit.sim +++ b/tests/script/tsim/table/limit.sim @@ -12,10 +12,10 @@ $db = $dbPrefix . $i $tb = $tbPrefix . $i print =================== step 0 -sql create database $db +sql create database $db vgroups 8 sql use $db sql show vgroups -if $rows != 0 then +if $rows != 8 then return -1 endi diff --git a/tests/script/tsim/table/smallint.sim b/tests/script/tsim/table/smallint.sim index c81681c316..87140c561a 100644 --- a/tests/script/tsim/table/smallint.sim +++ b/tests/script/tsim/table/smallint.sim @@ -25,12 +25,10 @@ if $data01 != NULL then endi print =============== step2 -sql insert into $tb values (now+1m, -32768) -x step2 - return -1 -step2: -sql insert into $tb values (now+1m, NULL) +sql insert into $tb values (now+1m, -32768) +sql insert into $tb values (now+2m, NULL) sql select * from $tb order by ts desc -if $rows != 2 then +if $rows != 3 then return -1 endi if $data01 != NULL then @@ -38,9 +36,9 @@ if $data01 != NULL then endi print =============== step3 -sql insert into $tb values (now+2m, 32767) +sql insert into $tb values (now+3m, 32767) sql select * from $tb order by ts desc -if $rows != 3 then +if $rows != 4 then return -1 endi if $data01 != 32767 then @@ -48,12 +46,12 @@ if $data01 != 32767 then endi print =============== step4 -sql insert into $tb values (now+3m, 32768) -x step4 +sql insert into $tb values (now+4m, 32768) -x step4 return -1 step4: -sql insert into $tb values (now+3m, NULL) +sql insert into $tb values (now+5m, NULL) sql select * from $tb order by ts desc -if $rows != 4 then +if $rows != 5 then return -1 endi if $data01 != NULL then @@ -61,10 +59,10 @@ if $data01 != NULL then endi print =============== step5 -sql_error insert into $tb values (now+4m, a2) -sql insert into $tb values (now+4m, 0) +sql_error insert into $tb values (now+6m, a2) +sql insert into $tb values (now+7m, 0) sql select * from $tb order by ts desc -if $rows != 5 then +if $rows != 6 then return -1 endi if $data01 != 0 then @@ -72,19 +70,8 @@ if $data01 != 0 then endi print =============== step6 -sql_error insert into $tb values (now+5m, 2a) -sql insert into $tb values (now+5m, 2) -sql select * from $tb order by ts desc -if $rows != 6 then - return -1 -endi -if $data01 != 2 then - return -1 -endi - -print =============== step7 -sql_error insert into $tb values (now+6m, 2a'1) -sql insert into $tb values (now+6m, 2) +sql_error insert into $tb values (now+8m, 2a) +sql insert into $tb values (now+9m, 2) sql select * from $tb order by ts desc if $rows != 7 then return -1 @@ -93,6 +80,17 @@ if $data01 != 2 then return -1 endi +print =============== step7 +sql_error insert into $tb values (now+10m, 2a'1) +sql insert into $tb values (now+11m, 2) +sql select * from $tb order by ts desc +if $rows != 8 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +return sql drop database $db sql show databases if $rows != 2 then diff --git a/tests/script/tsim/table/table.sim b/tests/script/tsim/table/table.sim index 6a706c979f..65774dd03c 100644 --- a/tests/script/tsim/table/table.sim +++ b/tests/script/tsim/table/table.sim @@ -197,16 +197,15 @@ if $data01 != 7 then endi print =============== step10 -$i = 1 $tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql_error create table $tb (ts timestamp, val tinyint, val2 tinyint) sql show tables if $rows != 7 then return -1 endi print =============== step11 -sql create table $tb (ts timestamp, val float, val2 double) +sql_error create table $tb (ts timestamp, val float, val2 double) sql show tables if $rows != 7 then return -1 diff --git a/tests/script/tsim/table/tinyint.sim b/tests/script/tsim/table/tinyint.sim index 089fab0bfa..4764600b5b 100644 --- a/tests/script/tsim/table/tinyint.sim +++ b/tests/script/tsim/table/tinyint.sim @@ -24,12 +24,10 @@ if $data01 != NULL then endi print =============== step2 -sql insert into $tb values (now+1m, -128) -x step2 - return -1 -step2: -sql insert into $tb values (now+1m, NULL) +sql insert into $tb values (now+1m, -128) +sql insert into $tb values (now+2m, NULL) sql select * from $tb order by ts desc -if $rows != 2 then +if $rows != 3 then return -1 endi if $data01 != NULL then @@ -37,9 +35,9 @@ if $data01 != NULL then endi print =============== step3 -sql insert into $tb values (now+2m, 127) +sql insert into $tb values (now+3m, 127) sql select * from $tb order by ts desc -if $rows != 3 then +if $rows != 4 then return -1 endi if $data01 != 127 then @@ -47,12 +45,12 @@ if $data01 != 127 then endi print =============== step4 -sql insert into $tb values (now+3m, 128) -x step4 +sql insert into $tb values (now+4m, 128) -x step4 return -1 step4: -sql insert into $tb values (now+3m, NULL) +sql insert into $tb values (now+5m, NULL) sql select * from $tb -if $rows != 4 then +if $rows != 5 then return -1 endi if $data01 != NULL then @@ -60,10 +58,10 @@ if $data01 != NULL then endi print =============== step5 -sql_error insert into $tb values (now+4m, a2) -sql insert into $tb values (now+4m, 0) +sql_error insert into $tb values (now+6m, a2) +sql insert into $tb values (now+7m, 0) sql select * from $tb order by ts desc -if $rows != 5 then +if $rows != 6 then return -1 endi if $data01 != 0 then @@ -71,10 +69,10 @@ if $data01 != 0 then endi print =============== step6 -sql_error insert into $tb values (now+5m, 2a) -sql insert into $tb values (now+5m, 2) +sql_error insert into $tb values (now+8m, 2a) +sql insert into $tb values (now+9m, 2) sql select * from $tb order by ts desc -if $rows != 6 then +if $rows != 7 then return -1 endi if $data01 != 2 then @@ -82,10 +80,10 @@ if $data01 != 2 then endi print =============== step7 -sql_error insert into $tb values (now+6m, 2a'1) -sql insert into $tb values (now+6m, 2) +sql_error insert into $tb values (now+10m, 2a'1) +sql insert into $tb values (now+11m, 2) sql select * from $tb order by ts desc -if $rows != 7 then +if $rows != 8 then return -1 endi if $data01 != 2 then diff --git a/tests/script/tsim/table/vgroup.sim b/tests/script/tsim/table/vgroup.sim index 902415400e..2925e9de4c 100644 --- a/tests/script/tsim/table/vgroup.sim +++ b/tests/script/tsim/table/vgroup.sim @@ -12,10 +12,10 @@ $db = $dbPrefix . $i $tb = $tbPrefix . $i print =================== step 1 -sql create database $db +sql create database $db vgroups 4 sql use $db sql show vgroups -if $rows != 0 then +if $rows != 4 then return -1 endi @@ -24,7 +24,7 @@ sql create table table2 (ts timestamp, speed int) sql create table table3 (ts timestamp, speed int) sql create table table4 (ts timestamp, speed int) sql show vgroups -if $rows != 1 then +if $rows != 4 then return -1 endi @@ -33,7 +33,7 @@ sql create table table6 (ts timestamp, speed int) sql create table table7 (ts timestamp, speed int) sql create table table8 (ts timestamp, speed int) sql show vgroups -if $rows != 2 then +if $rows != 4 then return -1 endi @@ -42,7 +42,7 @@ sql create table table10 (ts timestamp, speed int) sql create table table11 (ts timestamp, speed int) sql create table table12 (ts timestamp, speed int) sql show vgroups -if $rows != 3 then +if $rows != 4 then return -1 endi @@ -54,7 +54,7 @@ endi sql drop table table13 sql show vgroups -if $rows != 3 then +if $rows != 4 then return -1 endi @@ -68,10 +68,10 @@ print =================== step 2 $i = 1 $db = $dbPrefix . $i -sql create database $db +sql create database $db vgroups 2 sql use $db sql show vgroups -if $rows != 0 then +if $rows != 2 then return -1 endi @@ -84,13 +84,13 @@ $db = $dbPrefix . $i sql use $db sql create table table2 (ts timestamp, speed int) sql show vgroups -if $rows != 1 then +if $rows != 2 then return -1 endi sql drop table table2 sql show vgroups -if $rows != 0 then +if $rows != 2 then return -1 endi @@ -100,7 +100,7 @@ sql create table table3 (ts timestamp, speed int) sql create table table4 (ts timestamp, speed int) sql drop table table1 sql show vgroups -if $rows != 1 then +if $rows != 2 then return -1 endi @@ -129,7 +129,7 @@ sql create database $db sql use $db sql show databases -if $rows != 5 then +if $rows != 7 then return -1 endi From ddb39a8dc236284ae9d26a46a26aac34c3825369 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 14 Jul 2022 16:06:28 +0800 Subject: [PATCH 49/65] fix: some problems of planner --- include/libs/nodes/plannodes.h | 7 ++- source/libs/command/src/explain.c | 20 +++---- source/libs/executor/src/cachescanoperator.c | 8 +-- source/libs/executor/src/executorimpl.c | 8 +-- source/libs/function/src/builtinsimpl.c | 53 +++++++++---------- source/libs/nodes/src/nodesCodeFuncs.c | 38 +++++++++++-- source/libs/planner/src/planPhysiCreater.c | 23 ++++++-- source/libs/planner/src/planSpliter.c | 3 ++ source/libs/planner/test/planBasicTest.cpp | 2 + source/libs/planner/test/planSubqueryTest.cpp | 2 + 10 files changed, 109 insertions(+), 55 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6a865b4e2a..b807aeca22 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -275,7 +275,12 @@ typedef struct SScanPhysiNode { typedef SScanPhysiNode STagScanPhysiNode; typedef SScanPhysiNode SBlockDistScanPhysiNode; -typedef SScanPhysiNode SLastRowScanPhysiNode; + +typedef struct SLastRowScanPhysiNode { + SScanPhysiNode scan; + SNodeList* pGroupTags; + bool groupSort; +} SLastRowScanPhysiNode; typedef struct SSystemTableScanPhysiNode { SScanPhysiNode scan; diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index fde53b7064..3fa419e220 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -206,7 +206,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo } case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: { SLastRowScanPhysiNode *lastRowPhysiNode = (SLastRowScanPhysiNode *)pNode; - pPhysiChildren = lastRowPhysiNode->node.pChildren; + pPhysiChildren = lastRowPhysiNode->scan.node.pChildren; break; } case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: { @@ -1209,19 +1209,19 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: { SLastRowScanPhysiNode *pLastRowNode = (SLastRowScanPhysiNode *)pNode; - EXPLAIN_ROW_NEW(level, EXPLAIN_LASTROW_SCAN_FORMAT, pLastRowNode->tableName.tname); + EXPLAIN_ROW_NEW(level, EXPLAIN_LASTROW_SCAN_FORMAT, pLastRowNode->scan.tableName.tname); EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); if (pResNode->pExecInfo) { QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); } - EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, pLastRowNode->pScanCols->length); + EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, pLastRowNode->scan.pScanCols->length); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); - if (pLastRowNode->pScanPseudoCols) { - EXPLAIN_ROW_APPEND(EXPLAIN_PSEUDO_COLUMNS_FORMAT, pLastRowNode->pScanPseudoCols->length); + if (pLastRowNode->scan.pScanPseudoCols) { + EXPLAIN_ROW_APPEND(EXPLAIN_PSEUDO_COLUMNS_FORMAT, pLastRowNode->scan.pScanPseudoCols->length); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); } - EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->node.pOutputDataBlockDesc->totalRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->scan.node.pOutputDataBlockDesc->totalRowSize); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); EXPLAIN_ROW_END(); @@ -1230,15 +1230,15 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i if (verbose) { EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, - nodesGetOutputNumFromSlotList(pLastRowNode->node.pOutputDataBlockDesc->pSlots)); + nodesGetOutputNumFromSlotList(pLastRowNode->scan.node.pOutputDataBlockDesc->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); - EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->scan.node.pOutputDataBlockDesc->outputRowSize); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - if (pLastRowNode->node.pConditions) { + if (pLastRowNode->scan.node.pConditions) { EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); - QRY_ERR_RET(nodesNodeToSQL(pLastRowNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, + QRY_ERR_RET(nodesNodeToSQL(pLastRowNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 0f6817cd6b..9034397d0f 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -40,10 +40,10 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead pInfo->pTableList = pTableList; pInfo->readHandle = *readHandle; - pInfo->pRes = createResDataBlock(pScanNode->node.pOutputDataBlockDesc); + pInfo->pRes = createResDataBlock(pScanNode->scan.node.pOutputDataBlockDesc); int32_t numOfCols = 0; - pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfCols, + pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pScanNode->scan.node.pOutputDataBlockDesc, &numOfCols, COL_MATCH_FROM_COL_ID); int32_t code = extractTargetSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds); if (code != TSDB_CODE_SUCCESS) { @@ -53,10 +53,10 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead tsdbLastRowReaderOpen(readHandle->vnode, LASTROW_RETRIEVE_TYPE_SINGLE, pTableList, taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); - if (pScanNode->pScanPseudoCols != NULL) { + if (pScanNode->scan.pScanPseudoCols != NULL) { SExprSupp* pPseudoExpr = &pInfo->pseudoExprSup; - pPseudoExpr->pExprInfo = createExprInfo(pScanNode->pScanPseudoCols, NULL, &pPseudoExpr->numOfExprs); + pPseudoExpr->pExprInfo = createExprInfo(pScanNode->scan.pScanPseudoCols, NULL, &pPseudoExpr->numOfExprs); pPseudoExpr->pCtx = createSqlFunctionCtx(pPseudoExpr->pExprInfo, pPseudoExpr->numOfExprs, &pPseudoExpr->rowEntryInfoOffset); } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 674bbfef0b..851e3bc5bf 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4444,21 +4444,21 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo // return NULL; // } - int32_t code = extractTableSchemaInfo(pHandle, pScanNode->uid, pTaskInfo); + int32_t code = extractTableSchemaInfo(pHandle, pScanNode->scan.uid, pTaskInfo); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = code; return NULL; } pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo)); - if (pScanNode->tableType == TSDB_SUPER_TABLE) { - code = vnodeGetAllTableList(pHandle->vnode, pScanNode->uid, pTableListInfo->pTableList); + if (pScanNode->scan.tableType == TSDB_SUPER_TABLE) { + code = vnodeGetAllTableList(pHandle->vnode, pScanNode->scan.uid, pTableListInfo->pTableList); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = terrno; return NULL; } } else { // Create one table group. - STableKeyInfo info = {.lastKey = 0, .uid = pScanNode->uid, .groupId = 0}; + STableKeyInfo info = {.lastKey = 0, .uid = pScanNode->scan.uid, .groupId = 0}; taosArrayPush(pTableListInfo->pTableList, &info); } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index e622c0c1af..320474ffb3 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -80,7 +80,7 @@ typedef struct STopBotRes { } STopBotRes; typedef struct SFirstLastRes { - bool hasResult; + bool hasResult; // used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So, // this attribute is required bool isNull; @@ -402,7 +402,6 @@ typedef struct SGroupKeyInfo { (x) += step; \ } while (0) - #define STATE_COMP(_op, _lval, _param) STATE_COMP_IMPL(_op, _lval, GET_STATE_VAL(_param)) #define GET_STATE_VAL(param) ((param.nType == TSDB_DATA_TYPE_BIGINT) ? (param.i) : (param.d)) @@ -986,8 +985,8 @@ int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SAvgRes* pInputInfo = (SAvgRes*)varDataVal(data); avgTransferInfo(pInputInfo, pInfo); } @@ -2559,8 +2558,8 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SAPercentileInfo* pInputInfo = (SAPercentileInfo*)varDataVal(data); apercentileTransferInfo(pInputInfo, pInfo); } @@ -2925,8 +2924,8 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer int32_t start = pInput->startRowIndex; int32_t numOfElems = 0; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SFirstLastRes* pInputInfo = (SFirstLastRes*)varDataVal(data); firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery); if (!numOfElems) { @@ -2951,7 +2950,7 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0; SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); - colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull||pResInfo->isNullRes); + colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull || pResInfo->isNullRes); // handle selectivity STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); @@ -3754,8 +3753,8 @@ int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data); spreadTransferInfo(pInputInfo, pInfo); } @@ -3926,8 +3925,8 @@ int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SElapsedInfo* pInputInfo = (SElapsedInfo*)varDataVal(data); elapsedTransferInfo(pInputInfo, pInfo); } @@ -4191,13 +4190,9 @@ static int32_t histogramFunctionImpl(SqlFunctionCtx* pCtx, bool isPartial) { return TSDB_CODE_SUCCESS; } -int32_t histogramFunction(SqlFunctionCtx* pCtx) { - return histogramFunctionImpl(pCtx, false); -} +int32_t histogramFunction(SqlFunctionCtx* pCtx) { return histogramFunctionImpl(pCtx, false); } -int32_t histogramFunctionPartial(SqlFunctionCtx* pCtx) { - return histogramFunctionImpl(pCtx, true); -} +int32_t histogramFunctionPartial(SqlFunctionCtx* pCtx) { return histogramFunctionImpl(pCtx, true); } static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutput) { pOutput->normalized = pInput->normalized; @@ -4219,8 +4214,8 @@ int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SHistoFuncInfo* pInputInfo = (SHistoFuncInfo*)varDataVal(data); histogramTransferInfo(pInputInfo, pInfo); } @@ -4267,9 +4262,9 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getHistogramInfoSize(); - char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getHistogramInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); @@ -4440,8 +4435,8 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for(int32_t i = start; i < start + pInput->numOfRows; ++i) { - char* data = colDataGetData(pCol, i); + for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + char* data = colDataGetData(pCol, i); SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data); hllTransferInfo(pInputInfo, pInfo); } @@ -5998,7 +5993,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; - int32_t type = pInputCol->info.type; + int32_t type = pInputCol->info.type; int32_t bytes = pInputCol->info.bytes; pInfo->bytes = bytes; @@ -6010,7 +6005,6 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = getRowPTs(pInput->pPTS, i); if (pResInfo->numOfRes == 0 || pInfo->ts < cts) { - if (colDataIsNull_s(pInputCol, i)) { pInfo->isNull = true; } else { @@ -6023,7 +6017,6 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { } pInfo->ts = cts; - pInfo->hasResult = true; pResInfo->numOfRes = 1; if (pCtx->subsidiaries.num > 0) { @@ -6034,6 +6027,8 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); } } + + pInfo->hasResult = true; } } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 75f9cd7b48..2d24b01ca1 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1468,9 +1468,36 @@ static int32_t jsonToPhysiScanNode(const SJson* pJson, void* pObj) { return code; } -static int32_t physiTagScanNodeToJson(const void* pObj, SJson* pJson) { return physiScanNodeToJson(pObj, pJson); } +static const char* jkLastRowScanPhysiPlanGroupTags = "GroupTags"; +static const char* jkLastRowScanPhysiPlanGroupSort = "GroupSort"; -static int32_t jsonToPhysiTagScanNode(const SJson* pJson, void* pObj) { return jsonToPhysiScanNode(pJson, pObj); } +static int32_t physiLastRowScanNodeToJson(const void* pObj, SJson* pJson) { + const SLastRowScanPhysiNode* pNode = (const SLastRowScanPhysiNode*)pObj; + + int32_t code = physiScanNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = nodeListToJson(pJson, jkLastRowScanPhysiPlanGroupTags, pNode->pGroupTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkLastRowScanPhysiPlanGroupSort, pNode->groupSort); + } + + return code; +} + +static int32_t jsonToPhysiLastRowScanNode(const SJson* pJson, void* pObj) { + SLastRowScanPhysiNode* pNode = (SLastRowScanPhysiNode*)pObj; + + int32_t code = jsonToPhysiScanNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkLastRowScanPhysiPlanGroupTags, &pNode->pGroupTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkLastRowScanPhysiPlanGroupSort, &pNode->groupSort); + } + + return code; +} static const char* jkTableScanPhysiPlanScanCount = "ScanCount"; static const char* jkTableScanPhysiPlanReverseScanCount = "ReverseScanCount"; @@ -4315,8 +4342,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return logicPlanToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + return physiScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: - return physiTagScanNodeToJson(pObj, pJson); + return physiLastRowScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: @@ -4461,8 +4489,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToLogicPlan(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + return jsonToPhysiScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: - return jsonToPhysiTagScanNode(pJson, pObj); + + return jsonToPhysiLastRowScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 8c9c06be35..c4cc31c535 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -481,8 +481,6 @@ static ENodeType getScanOperatorType(EScanType scanType) { return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN; case SCAN_TYPE_BLOCK_INFO: return QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN; - case SCAN_TYPE_LAST_ROW: - return QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN; default: break; } @@ -502,6 +500,24 @@ static int32_t createSimpleScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSub return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, pScan, pPhyNode); } +static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, + SPhysiNode** pPhyNode) { + SLastRowScanPhysiNode* pScan = + (SLastRowScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN); + if (NULL == pScan) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pScan->pGroupTags = nodesCloneList(pScanLogicNode->pGroupTags); + if (NULL != pScanLogicNode->pGroupTags && NULL == pScan->pGroupTags) { + nodesDestroyNode((SNode*)pScan); + return TSDB_CODE_OUT_OF_MEMORY; + } + pScan->groupSort = pScanLogicNode->groupSort; + + return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); +} + static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, @@ -583,8 +599,9 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, switch (pScanLogicNode->scanType) { case SCAN_TYPE_TAG: case SCAN_TYPE_BLOCK_INFO: - case SCAN_TYPE_LAST_ROW: return createSimpleScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); + case SCAN_TYPE_LAST_ROW: + return createLastRowScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_TABLE: return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_SYSTEM_TABLE: diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 7b9d553501..871bcf015b 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -364,6 +364,8 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic pMergeWindow->node.pTargets = NULL; SNodeList* pChildren = pMergeWindow->node.pChildren; pMergeWindow->node.pChildren = NULL; + SNode* pConditions = pMergeWindow->node.pConditions; + pMergeWindow->node.pConditions = NULL; int32_t code = TSDB_CODE_SUCCESS; SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow); @@ -373,6 +375,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic if (TSDB_CODE_SUCCESS == code) { pMergeWindow->node.pTargets = pTargets; + pMergeWindow->node.pConditions = pConditions; pPartWin->node.pChildren = pChildren; splSetParent((SLogicNode*)pPartWin); code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs); diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 0d6bab145a..8482698cd3 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -108,6 +108,8 @@ TEST_F(PlanBasicTest, lastRowFunc) { run("SELECT LAST_ROW(c1) FROM st1"); + run("SELECT LAST_ROW(c1) FROM st1 PARTITION BY TBNAME"); + run("SELECT LAST_ROW(c1), SUM(c3) FROM t1"); } diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 4d4f780473..2ba3794d5c 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -36,6 +36,8 @@ TEST_F(PlanSubqeuryTest, basic) { run("SELECT * FROM (SELECT NOW() FROM t1)"); run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"); + + run("SELECT * FROM (SELECT AVG(c1) a FROM st1 INTERVAL(10s)) WHERE a > 1"); } TEST_F(PlanSubqeuryTest, doubleGroupBy) { From 024c42eafdd8ac264d45b970e5fd12983d2dbdfd Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 14 Jul 2022 16:06:30 +0800 Subject: [PATCH 50/65] test:add test case for tmq --- tests/system-test/7-tmq/tmqCommon.py | 6 +- tests/system-test/7-tmq/tmqDelete-1ctb.py | 275 ++++++++++++++++++++++ tests/system-test/7-tmq/tmqUpdate-1ctb.py | 12 +- 3 files changed, 286 insertions(+), 7 deletions(-) create mode 100644 tests/system-test/7-tmq/tmqDelete-1ctb.py diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 060e17c11f..151558a33a 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -428,7 +428,7 @@ class TMQCom: pThread.start() return pThread - def checkFileContent(self, consumerId, queryString): + def checkFileContent(self, consumerId, queryString, skipRowsOfCons=0): buildPath = tdCom.getBuildPath() cfgPath = tdCom.getClientCfgPath() dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) @@ -445,6 +445,10 @@ class TMQCom: # skip first line for it is schema queryFile.readline() + # skip offset for consumer + for i in range(0,skipRowsOfCons): + consumeFile.readline() + lines = 0 while True: dst = queryFile.readline() diff --git a/tests/system-test/7-tmq/tmqDelete-1ctb.py b/tests/system-test/7-tmq/tmqDelete-1ctb.py new file mode 100644 index 0000000000..c5f7510a07 --- /dev/null +++ b/tests/system-test/7-tmq/tmqDelete-1ctb.py @@ -0,0 +1,275 @@ + +import taos +import sys +import time +import socket +import os +import threading +from enum import Enum + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.snapshot = 0 + self.vgroups = 4 + self.ctbNum = 1 + self.rowsPerTbl = 10000 + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + + def prepareTestEnv(self): + tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 100000, + 'batchNum': 1200, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 3, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdLog.info("create stb") + tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) + tdLog.info("create ctb") + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], + ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data") + tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], + ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", + # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + + # tdLog.info("restart taosd to ensure that the data falls into the disk") + # tdSql.query("flush database %s"%(paraDict['dbName'])) + return + + def delData(self,tsql,dbName,ctbPrefix,ctbNum,startTs=0,endTs=0,ctbStartIdx=0): + tdLog.debug("start to del data ............") + for i in range(ctbNum): + sql = "delete from %s.%s%d where _c0 >= %d and _c0 <= %d "%(dbName,ctbPrefix,i+ctbStartIdx,startTs,endTs) + tsql.execute(sql) + + tdLog.debug("del data ............ [OK]") + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 100000, + 'batchNum': 3000, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'endTs': 0, + 'pollDelay': 5, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + paraDict['snapshot'] = self.snapshot + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + # del some data + rowsOfDelete = int(paraDict["rowsPerTbl"] / 4) + paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicFromStb1, queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + consumerId = 0 + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) + topicList = topicFromStb1 + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:true,\ + auto.commit.interval.ms:1000,\ + auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + tdLog.info("insert process end, and start to check consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + tdSql.query(queryString) + totalRowsInserted = tdSql.getRows() + + tdLog.info("act consume rows: %d, expect consume rows: %d, act insert rows: %d"%(totalConsumeRows, expectrowcnt, totalRowsInserted)) + if totalConsumeRows != expectrowcnt: + tdLog.exit("tmq consume rows error!") + + tmqCom.checkFileContent(consumerId, queryString, rowsOfDelete) + + tdSql.query("drop topic %s"%topicFromStb1) + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self): + tdLog.printNoPrefix("======== test case 2: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 5000, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 5, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + + paraDict['snapshot'] = self.snapshot + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tdLog.info("restart taosd to ensure that the data falls into the disk") + tdSql.query("flush database %s"%(paraDict['dbName'])) + + # update to 1/4 rows and insert 3/4 new rows + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) + # paraDict['rowsPerTbl'] = self.rowsPerTbl + tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], + ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + # tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], + # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + + # del some data + rowsOfDelete = int(self.rowsPerTbl / 4 ) + paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 + self.delData(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"], + startTs=paraDict["startTs"], endTs=paraDict["endTs"],ctbStartIdx=paraDict['ctbStartIdx']) + + tmqCom.initConsumerTable() + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicFromStb1, queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + consumerId = 1 + + if self.snapshot == 0: + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) + elif self.snapshot == 1: + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4 - 1/4)) + + topicList = topicFromStb1 + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:true,\ + auto.commit.interval.ms:1000,\ + auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + tdSql.query(queryString) + totalRowsInserted = tdSql.getRows() + + tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt)) + + if totalConsumeRows != expectrowcnt: + tdLog.exit("tmq consume rows error!") + + # tmqCom.checkFileContent(consumerId, queryString) + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def run(self): + tdSql.prepare() + self.prepareTestEnv() + tdLog.printNoPrefix("=============================================") + tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") + self.tmqCase1() + self.tmqCase2() + + self.prepareTestEnv() + tdLog.printNoPrefix("====================================================================") + tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") + self.snapshot = 1 + self.tmqCase1() + self.tmqCase2() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqUpdate-1ctb.py b/tests/system-test/7-tmq/tmqUpdate-1ctb.py index 8513092be9..de11f0f9ab 100644 --- a/tests/system-test/7-tmq/tmqUpdate-1ctb.py +++ b/tests/system-test/7-tmq/tmqUpdate-1ctb.py @@ -235,18 +235,18 @@ class TDTestCase: def run(self): tdSql.prepare() - # self.prepareTestEnv() - # tdLog.printNoPrefix("=============================================") - # tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") - # self.tmqCase1() - # self.tmqCase2() + self.prepareTestEnv() + tdLog.printNoPrefix("=============================================") + tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") + self.tmqCase1() + self.tmqCase2() self.prepareTestEnv() tdLog.printNoPrefix("====================================================================") tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") self.snapshot = 1 self.tmqCase1() - # self.tmqCase2() + self.tmqCase2() def stop(self): From 2076a00b7a848022f77e4af09cc87ef3adae1d36 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 16:01:01 +0800 Subject: [PATCH 51/65] test: restore some 2.0 case --- tests/script/general/db/alter_option.sim | 263 ------------------ tests/script/general/db/back_insert.sim | 9 - tests/script/jenkins/basic.txt | 24 ++ tests/script/tsim/db/alter_option.sim | 55 +--- .../{general => tsim}/db/alter_tables_d2.sim | 0 .../{general => tsim}/db/alter_tables_v1.sim | 0 .../{general => tsim}/db/alter_tables_v4.sim | 0 .../{general => tsim}/db/alter_vgroups.sim | 0 tests/script/tsim/db/back_insert.sim | 2 + tests/script/{general => tsim}/db/basic4.sim | 0 tests/script/{general => tsim}/db/basic5.sim | 0 .../db/delete.sim => tsim/db/delete2.sim} | 0 .../{general => tsim}/db/delete_reuse1.sim | 0 .../{general => tsim}/db/delete_reuse2.sim | 0 .../db/delete_reusevnode.sim | 0 .../db/delete_reusevnode2.sim | 0 .../{general => tsim}/db/delete_writing1.sim | 0 .../{general => tsim}/db/delete_writing2.sim | 0 .../{general => tsim}/db/dropdnodes.sim | 0 .../{general/db/backup => tsim/db}/keep.sim | 0 tests/script/{general => tsim}/db/len.sim | 0 .../{general => tsim}/db/nosuchfile.sim | 0 tests/script/{general => tsim}/db/repeat.sim | 0 .../{general => tsim}/db/show_create_db.sim | 0 .../db/show_create_table.sim | 0 tests/script/{general => tsim}/db/tables.sim | 0 .../script/{general => tsim}/db/testSuite.sim | 0 tests/script/{general => tsim}/db/topic1.sim | 0 tests/script/{general => tsim}/db/topic2.sim | 0 tests/script/{general => tsim}/db/vnodes.sim | 0 30 files changed, 39 insertions(+), 314 deletions(-) delete mode 100644 tests/script/general/db/alter_option.sim delete mode 100644 tests/script/general/db/back_insert.sim rename tests/script/{general => tsim}/db/alter_tables_d2.sim (100%) rename tests/script/{general => tsim}/db/alter_tables_v1.sim (100%) rename tests/script/{general => tsim}/db/alter_tables_v4.sim (100%) rename tests/script/{general => tsim}/db/alter_vgroups.sim (100%) rename tests/script/{general => tsim}/db/basic4.sim (100%) rename tests/script/{general => tsim}/db/basic5.sim (100%) rename tests/script/{general/db/delete.sim => tsim/db/delete2.sim} (100%) rename tests/script/{general => tsim}/db/delete_reuse1.sim (100%) rename tests/script/{general => tsim}/db/delete_reuse2.sim (100%) rename tests/script/{general => tsim}/db/delete_reusevnode.sim (100%) rename tests/script/{general => tsim}/db/delete_reusevnode2.sim (100%) rename tests/script/{general => tsim}/db/delete_writing1.sim (100%) rename tests/script/{general => tsim}/db/delete_writing2.sim (100%) rename tests/script/{general => tsim}/db/dropdnodes.sim (100%) rename tests/script/{general/db/backup => tsim/db}/keep.sim (100%) rename tests/script/{general => tsim}/db/len.sim (100%) rename tests/script/{general => tsim}/db/nosuchfile.sim (100%) rename tests/script/{general => tsim}/db/repeat.sim (100%) rename tests/script/{general => tsim}/db/show_create_db.sim (100%) rename tests/script/{general => tsim}/db/show_create_table.sim (100%) rename tests/script/{general => tsim}/db/tables.sim (100%) rename tests/script/{general => tsim}/db/testSuite.sim (100%) rename tests/script/{general => tsim}/db/topic1.sim (100%) rename tests/script/{general => tsim}/db/topic2.sim (100%) rename tests/script/{general => tsim}/db/vnodes.sim (100%) diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim deleted file mode 100644 index 89a32b5a5c..0000000000 --- a/tests/script/general/db/alter_option.sim +++ /dev/null @@ -1,263 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 - -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect - -print ============= create database -sql create database db cache 2 blocks 4 duration 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 -sql show databases -if $data00 != db then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 0 then - return -1 -endi -if $data04 != 1 then - return -1 -endi -if $data06 != 10 then - return -1 -endi -if $data07 != 20,20,20 then - return -1 -endi -if $data08 != 2 then - return -1 -endi -if $data09 != 4 then - return -1 -endi - -print ============== step name -sql_error alter database db name d1 -sql_error alter database db name d2 - -print ============== step ntables -sql_error alter database db ntables -1 -sql_error alter database db ntables 0 -sql_error alter database db ntables 1 -sql_error alter database db ntables 10 - -print ============== step vgroups -sql_error alter database db vgroups -1 -sql_error alter database db vgroups 0 -sql_error alter database db vgroups 1 -sql_error alter database db vgroups 10 - -print ============== step replica -sql_error alter database db replica 2 -sql_error alter database db replica 3 -sql_error alter database db replica 0 - -sql alter database db replica 1 -sql show databases -print replica $data4_db -if $data4_db != 1 then - return -1 -endi - -print ============== step quorum -sql show databases -print quorum $data5_db -if $data5_db != 1 then - return -1 -endi - -sql alter database db quorum 1 -sql show databases -print quorum $data5_db -if $data5_db != 1 then - return -1 -endi - -sql_error alter database db quorum 2 - -sql_error alter database db quorum 3 - -sql_error alter database db quorum 0 -sql_error alter database db quorum 4 -sql_error alter database db quorum 5 -sql_error alter database db quorum -1 - -print ============== step duration -sql_error alter database db duration 0 -sql_error alter database db duration 1 -sql_error alter database db duration 2 -sql_error alter database db duration 10 -sql_error alter database db duration 50 -sql_error alter database db duration 100 - -print ============== step keep -sql show databases -print keep $data7_db -if $data7_db != 20,20,20 then - return -1 -endi - -sql alter database db keep 20 -sql show databases -print keep $data7_db -if $data7_db != 20,20,20 then - return -1 -endi - -sql alter database db keep 30 -sql show databases -print keep $data7_db -if $data7_db != 30,30,30 then - return -1 -endi - -sql alter database db keep 40 -sql show databases -print keep $data7_db -if $data7_db != 40,40,40 then - return -1 -endi - -sql alter database db keep 40,50 -sql alter database db keep 30,31 -sql alter database db keep 20 -sql_error alter database db keep 10.0 -sql_error alter database db keep 9 -sql_error alter database db keep 1 -sql_error alter database db keep 0 -sql_error alter database db keep -1 -sql_error alter database db keep 365001 - -print ============== step cache -sql_error alter database db cache 60 -sql_error alter database db cache 50 -sql_error alter database db cache 20 -sql_error alter database db cache 3 -sql_error alter database db cache 129 -sql_error alter database db cache 300 -sql_error alter database db cache 0 -sql_error alter database db cache -1 - -print ============== step blocks -sql show databases -print blocks $data9_db -if $data9_db != 4 then - return -1 -endi - -sql alter database db blocks 10 -sql show databases -print blocks $data9_db -if $data9_db != 10 then - return -1 -endi - -sql alter database db blocks 20 -sql show databases -print blocks $data9_db -if $data9_db != 20 then - return -1 -endi - -sql alter database db blocks 30 -sql show databases -print blocks $data9_db -if $data9_db != 30 then - return -1 -endi - -sql alter database db blocks 40 -sql alter database db blocks 30 -sql alter database db blocks 20 -sql alter database db blocks 10 -sql_error alter database db blocks 2 -sql_error alter database db blocks 1 -sql_error alter database db blocks 0 -sql_error alter database db blocks -1 -sql_error alter database db blocks 10001 - -print ============== step minrows -sql_error alter database db minrows 1 -sql_error alter database db minrows 100 -sql_error alter database db minrows 1000 - -print ============== step maxrows -sql_error alter database db maxrows 1 -sql_error alter database db maxrows 100 -sql_error alter database db maxrows 1000 - -print ============== step wallevel -sql show databases -print wallevel $data12_db -if $data12_db != 1 then - return -1 -endi - -sql_error alter database db wal 1 - - -sql_error alter database db wal 1 -sql_error alter database db wal 2 -sql_error alter database db wal 1 -sql_error alter database db wal 2 -sql_error alter database db wal 0 -sql_error alter database db wal 3 -sql_error alter database db wal 4 -sql_error alter database db wal -1 -sql_error alter database db wal 1000 - -print ============== step fsync -sql_error alter database db fsync 0 -sql_error alter database db fsync 1 -sql_error alter database db fsync 3600 -sql_error alter database db fsync 18000 -sql_error alter database db fsync 180000 -sql_error alter database db fsync 180001 -sql_error alter database db fsync -1 - -print ============== step comp -sql show databases -print comp $data14_db -if $data14_db != 2 then - return -1 -endi - -sql alter database db comp 1 -sql show databases -print comp $data14_db -if $data14_db != 1 then - return -1 -endi - -sql alter database db comp 2 -sql show databases -print comp $data14_db -if $data14_db != 2 then - return -1 -endi - -sql alter database db comp 0 -sql show databases -print comp $data14_db -if $data14_db != 0 then - return -1 -endi - -sql_error alter database db comp 3 -sql_error alter database db comp 4 -sql_error alter database db comp 5 -sql_error alter database db comp -1 - - -print ============== step precision -sql_error alter database db prec 'us' - -print ============== step status -sql_error alter database db status 'delete' - -system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/back_insert.sim b/tests/script/general/db/back_insert.sim deleted file mode 100644 index 642df63ff2..0000000000 --- a/tests/script/general/db/back_insert.sim +++ /dev/null @@ -1,9 +0,0 @@ -sql connect -$x = 1 -begin: - sql reset query cache - sleep 1000 - sql insert into db.tb values(now, $x ) -x begin - #print ===> insert successed $x - $x = $x + 1 -goto begin \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 4de8b3667d..4c77051426 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -11,17 +11,41 @@ ./test.sh -f tsim/db/alter_option.sim # ./test.sh -f tsim/db/alter_replica_13.sim # ./test.sh -f tsim/db/alter_replica_31.sim +#./test.sh -f tsim/db/alter_tables_d2.sim +#./test.sh -f tsim/db/alter_tables_v1.sim +#./test.sh -f tsim/db/alter_tables_v4.sim +#./test.sh -f tsim/db/alter_vgroups.sim ./test.sh -f tsim/db/basic1.sim ./test.sh -f tsim/db/basic2.sim ./test.sh -f tsim/db/basic3.sim +#./test.sh -f tsim/db/basic4.sim +#./test.sh -f tsim/db/basic5.sim ./test.sh -f tsim/db/basic6.sim ./test.sh -f tsim/db/basic7.sim #./test.sh -f tsim/db/commit.sim ./test.sh -f tsim/db/create_all_options.sim #./test.sh -f tsim/db/delete_part.sim +#./test.sh -f tsim/db/delete_reuse1.sim +#./test.sh -f tsim/db/delete_reuse2.sim +#./test.sh -f tsim/db/delete_reusevnode.sim +#./test.sh -f tsim/db/delete_reusevnode2.sim +#./test.sh -f tsim/db/delete_writing1.sim +#./test.sh -f tsim/db/delete_writing2.sim #./test.sh -f tsim/db/delete.sim +#./test.sh -f tsim/db/delete2.sim +#./test.sh -f tsim/db/dropvnodes.sim ./test.sh -f tsim/db/error1.sim +#./test.sh -f tsim/db/keep.sim +#./test.sh -f tsim/db/len.sim +#./test.sh -f tsim/db/nosuchfile.sim +#./test.sh -f tsim/db/repeat.sim +#./test.sh -f tsim/db/show_create_db.sim +#./test.sh -f tsim/db/show_create_table.sim +#./test.sh -f tsim/db/tables.sim ./test.sh -f tsim/db/taosdlog.sim +#./test.sh -f tsim/db/topic1.sim +#./test.sh -f tsim/db/topic2.sim +#./test.sh -f tsim/db/vnodes.sim # ---- dnode # ./test.sh -f tsim/dnode/balance_replica1.sim diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index f24e32279d..1eb4e36da6 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -6,64 +6,36 @@ system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect sql create dnode $hostname port 7200 sql create dnode $hostname port 7300 -$loop_cnt = 0 -check_dnode_ready_1: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then print ====> dnode not ready! return -1 endi sql show dnodes -print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data20 $data21 $data22 $data23 $data24 $data25 -if $data00 != 1 then +if $rows != 3 then return -1 endi -system_content printf %OS% -if $system_content == Windows_NT then - system_content printf %COMPUTERNAME%:7100 - if $data01 != $system_content then - return -1 - endi -else - if $data01 != localhost:7100 then - return -1 - endi +if $data(1)[4] != ready then + goto step1 endi -if $data04 != ready then - goto check_dnode_ready_1 +if $data(2)[4] != ready then + goto step1 endi -if $data14 != ready then - goto check_dnode_ready_1 -endi -if $data24 != ready then - goto check_dnode_ready_1 +if $data(3)[4] != ready then + goto step1 endi + print ============= create database #database_option: { # | BUFFER value [3~16384, default: 96] @@ -137,7 +109,6 @@ if $data17_db != ns then # precision return -1 endi -sleep 3000 #sql show db.vgroups #if $data[0][4] == leader then # if $data[0][6] != follower then diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/tsim/db/alter_tables_d2.sim similarity index 100% rename from tests/script/general/db/alter_tables_d2.sim rename to tests/script/tsim/db/alter_tables_d2.sim diff --git a/tests/script/general/db/alter_tables_v1.sim b/tests/script/tsim/db/alter_tables_v1.sim similarity index 100% rename from tests/script/general/db/alter_tables_v1.sim rename to tests/script/tsim/db/alter_tables_v1.sim diff --git a/tests/script/general/db/alter_tables_v4.sim b/tests/script/tsim/db/alter_tables_v4.sim similarity index 100% rename from tests/script/general/db/alter_tables_v4.sim rename to tests/script/tsim/db/alter_tables_v4.sim diff --git a/tests/script/general/db/alter_vgroups.sim b/tests/script/tsim/db/alter_vgroups.sim similarity index 100% rename from tests/script/general/db/alter_vgroups.sim rename to tests/script/tsim/db/alter_vgroups.sim diff --git a/tests/script/tsim/db/back_insert.sim b/tests/script/tsim/db/back_insert.sim index 43831cca95..642df63ff2 100644 --- a/tests/script/tsim/db/back_insert.sim +++ b/tests/script/tsim/db/back_insert.sim @@ -1,6 +1,8 @@ sql connect $x = 1 begin: + sql reset query cache + sleep 1000 sql insert into db.tb values(now, $x ) -x begin #print ===> insert successed $x $x = $x + 1 diff --git a/tests/script/general/db/basic4.sim b/tests/script/tsim/db/basic4.sim similarity index 100% rename from tests/script/general/db/basic4.sim rename to tests/script/tsim/db/basic4.sim diff --git a/tests/script/general/db/basic5.sim b/tests/script/tsim/db/basic5.sim similarity index 100% rename from tests/script/general/db/basic5.sim rename to tests/script/tsim/db/basic5.sim diff --git a/tests/script/general/db/delete.sim b/tests/script/tsim/db/delete2.sim similarity index 100% rename from tests/script/general/db/delete.sim rename to tests/script/tsim/db/delete2.sim diff --git a/tests/script/general/db/delete_reuse1.sim b/tests/script/tsim/db/delete_reuse1.sim similarity index 100% rename from tests/script/general/db/delete_reuse1.sim rename to tests/script/tsim/db/delete_reuse1.sim diff --git a/tests/script/general/db/delete_reuse2.sim b/tests/script/tsim/db/delete_reuse2.sim similarity index 100% rename from tests/script/general/db/delete_reuse2.sim rename to tests/script/tsim/db/delete_reuse2.sim diff --git a/tests/script/general/db/delete_reusevnode.sim b/tests/script/tsim/db/delete_reusevnode.sim similarity index 100% rename from tests/script/general/db/delete_reusevnode.sim rename to tests/script/tsim/db/delete_reusevnode.sim diff --git a/tests/script/general/db/delete_reusevnode2.sim b/tests/script/tsim/db/delete_reusevnode2.sim similarity index 100% rename from tests/script/general/db/delete_reusevnode2.sim rename to tests/script/tsim/db/delete_reusevnode2.sim diff --git a/tests/script/general/db/delete_writing1.sim b/tests/script/tsim/db/delete_writing1.sim similarity index 100% rename from tests/script/general/db/delete_writing1.sim rename to tests/script/tsim/db/delete_writing1.sim diff --git a/tests/script/general/db/delete_writing2.sim b/tests/script/tsim/db/delete_writing2.sim similarity index 100% rename from tests/script/general/db/delete_writing2.sim rename to tests/script/tsim/db/delete_writing2.sim diff --git a/tests/script/general/db/dropdnodes.sim b/tests/script/tsim/db/dropdnodes.sim similarity index 100% rename from tests/script/general/db/dropdnodes.sim rename to tests/script/tsim/db/dropdnodes.sim diff --git a/tests/script/general/db/backup/keep.sim b/tests/script/tsim/db/keep.sim similarity index 100% rename from tests/script/general/db/backup/keep.sim rename to tests/script/tsim/db/keep.sim diff --git a/tests/script/general/db/len.sim b/tests/script/tsim/db/len.sim similarity index 100% rename from tests/script/general/db/len.sim rename to tests/script/tsim/db/len.sim diff --git a/tests/script/general/db/nosuchfile.sim b/tests/script/tsim/db/nosuchfile.sim similarity index 100% rename from tests/script/general/db/nosuchfile.sim rename to tests/script/tsim/db/nosuchfile.sim diff --git a/tests/script/general/db/repeat.sim b/tests/script/tsim/db/repeat.sim similarity index 100% rename from tests/script/general/db/repeat.sim rename to tests/script/tsim/db/repeat.sim diff --git a/tests/script/general/db/show_create_db.sim b/tests/script/tsim/db/show_create_db.sim similarity index 100% rename from tests/script/general/db/show_create_db.sim rename to tests/script/tsim/db/show_create_db.sim diff --git a/tests/script/general/db/show_create_table.sim b/tests/script/tsim/db/show_create_table.sim similarity index 100% rename from tests/script/general/db/show_create_table.sim rename to tests/script/tsim/db/show_create_table.sim diff --git a/tests/script/general/db/tables.sim b/tests/script/tsim/db/tables.sim similarity index 100% rename from tests/script/general/db/tables.sim rename to tests/script/tsim/db/tables.sim diff --git a/tests/script/general/db/testSuite.sim b/tests/script/tsim/db/testSuite.sim similarity index 100% rename from tests/script/general/db/testSuite.sim rename to tests/script/tsim/db/testSuite.sim diff --git a/tests/script/general/db/topic1.sim b/tests/script/tsim/db/topic1.sim similarity index 100% rename from tests/script/general/db/topic1.sim rename to tests/script/tsim/db/topic1.sim diff --git a/tests/script/general/db/topic2.sim b/tests/script/tsim/db/topic2.sim similarity index 100% rename from tests/script/general/db/topic2.sim rename to tests/script/tsim/db/topic2.sim diff --git a/tests/script/general/db/vnodes.sim b/tests/script/tsim/db/vnodes.sim similarity index 100% rename from tests/script/general/db/vnodes.sim rename to tests/script/tsim/db/vnodes.sim From 1c261c319b80ea69fe6601827efde6b80e65476b Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 14 Jul 2022 16:09:25 +0800 Subject: [PATCH 52/65] test: add test case for tmq into ci --- tests/system-test/fulltest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 2c116113bc..8bafe3c966 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -180,6 +180,7 @@ python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py #python3 ./test.py -f 7-tmq/tmqDnodeRestart.py #python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb.py +#python3 ./test.py -f 7-tmq/tmqDelete-1ctb.py #------------querPolicy 2----------- From a0466d780237e68af1e2f1c8aeb4eee7bfaf10b0 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 14 Jul 2022 16:12:57 +0800 Subject: [PATCH 53/65] fix(sma): double free --- source/dnode/vnode/src/sma/smaEnv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 2cf4fd51a9..e75d3b4e5d 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -214,7 +214,6 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS } pRSmaStat->refId = refId; - // init hash RSMA_INFO_HASH(pRSmaStat) = taosHashInit( RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); @@ -256,6 +255,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { // step 2: destroy the rsma info and associated fetch tasks // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. +#if 0 if (taosHashGetSize(RSMA_INFO_HASH(pStat)) > 0) { void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL); while (infoHash) { @@ -264,6 +264,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash); } } +#endif taosHashCleanup(RSMA_INFO_HASH(pStat)); // step 3: wait all triggered fetch tasks finished @@ -382,4 +383,4 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { tdUnLockSma(pSma); return TSDB_CODE_SUCCESS; -}; \ No newline at end of file +}; From c0639d3dc4f0b19820821af66e5617b66a0e4558 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 14 Jul 2022 16:24:12 +0800 Subject: [PATCH 54/65] fix(query): double free --- source/libs/executor/src/timewindowoperator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 74b5a3dab2..22c09de64f 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1340,13 +1340,13 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, void* key = taosHashGetKey(pIte, &keyLen); uint64_t groupId = *(uint64_t*)key; ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))); - TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); + TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); STimeWindow win; win.skey = ts; win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - SWinRes winRe = { - .ts = win.skey, - .groupId = groupId, + SWinRes winRe = { + .ts = win.skey, + .groupId = groupId, }; void* chIds = taosHashGet(pPullDataMap, &winRe, sizeof(SWinRes)); if (isCloseWindow(&win, pSup)) { @@ -1537,7 +1537,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { for (int32_t i = 0; i < size; i++) { SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, i); destroyStreamFinalIntervalOperatorInfo(pChildOp->info, numOfOutput); - taosMemoryFreeClear(pChildOp->info); + /*taosMemoryFreeClear(pChildOp->info);*/ taosMemoryFreeClear(pChildOp); } } From a15bd187bfb6bff0ce7defc0473bf043de8cc85b Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 14 Jul 2022 16:24:16 +0800 Subject: [PATCH 55/65] fix:error in json tag --- source/libs/scalar/src/sclvector.c | 3 ++- tests/system-test/2-query/json_tag.py | 25 ++++++++----------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 39b2f04f3e..76de4da4fd 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -1477,7 +1477,8 @@ void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, pOut->numOfRows = pLeft->numOfRows; - if (IS_HELPER_NULL(pRight->columnData, 0)) { +// if (IS_HELPER_NULL(pRight->columnData, 0)) { + if(colDataIsNull_s(pRight->columnData, 0)){ for (int32_t i = 0; i < pOut->numOfRows; ++i) { colDataAppend(pOutputCol, i, NULL, true); } diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 70aca9fd93..b817b1afb4 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -197,7 +197,7 @@ class TDTestCase: tdSql.checkData(0, 0, "true") # test select json tag->'key', value is null tdSql.query("select jtag->'tag1' from jsons1_4") - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, "null") # test select json tag->'key', value is double tdSql.query("select jtag->'tag1' from jsons1_5") tdSql.checkData(0, 0, "1.232000000") @@ -394,16 +394,15 @@ class TDTestCase: # test distinct tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')") tdSql.query("select distinct jtag->'tag1' from jsons1") - tdSql.checkRows(7) - # tdSql.query("select distinct jtag from jsons1") - # tdSql.checkRows(9) + tdSql.checkRows(8) + tdSql.error("select distinct jtag from jsons1") #test dumplicate key with normal colomn tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")") tdSql.query("select * from jsons1 where jtag->'datastr' match '是' and datastr match 'js'") tdSql.checkRows(1) - # tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'") - # tdSql.checkRows(1) + tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_15'") + tdSql.checkRows(1) # test join tdSql.execute("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") @@ -477,15 +476,10 @@ class TDTestCase: tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") tdSql.checkRows(11) tdSql.checkData(0, 1, None) - #tdSql.checkData(2, 0, 24) - #tdSql.checkData(3, 0, 3) - #tdSql.checkData(3, 1, "false") - #tdSql.checkData(8, 0, 2) - #tdSql.checkData(10, 1, '"femail"') # test having - # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1") - # tdSql.checkRows(3) + tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1") + tdSql.checkRows(3) # subquery with json tag tdSql.query("select * from (select jtag, dataint from jsons1) order by dataint") @@ -495,10 +489,7 @@ class TDTestCase: tdSql.error("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)") tdSql.error("select t->'tag1' from (select jtag->'tag1' as t, dataint from jsons1)") - # tdSql.query("select ts,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)") - # tdSql.checkRows(11) - # tdSql.checkData(1, 1, "jsons1_1") - # tdSql.checkData(1, 2, '"femail"') + tdSql.error("select ts,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)") # union all tdSql.query("select jtag->'tag1' from jsons1 union all select jtag->'tag2' from jsons2") From e711f560275b8645da3156d5ae08f9fed44fd5fc Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 14 Jul 2022 16:33:11 +0800 Subject: [PATCH 56/65] fix:remove code for resolve the core of amotic_load_n --- source/dnode/mnode/sdb/inc/sdb.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index be56d901de..1294f0cff3 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -163,7 +163,6 @@ typedef struct SSdbRow { ESdbType type; ESdbStatus status; int32_t refCount; - int64_t forAlign; char pObj[]; } SSdbRow; From c56f481476486ea6fa33fa16a04f8091cc00bc45 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Thu, 14 Jul 2022 16:38:10 +0800 Subject: [PATCH 57/65] test: option taosbenchmark error --- cmake/cmake.options | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/cmake.options b/cmake/cmake.options index 2acd46694b..5d99b2214a 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -83,12 +83,6 @@ option( OFF ) -option( - TDENGINE_3 - "TDengine 3.x" - ON - ) - option( BUILD_ADDR2LINE "If build addr2line" From 03712489f5b5711a8b827cf3bb7410a0d69e08e2 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Thu, 14 Jul 2022 14:24:39 +0800 Subject: [PATCH 58/65] ci(stream): stream intervl offset --- tests/script/tsim/stream/sliding.sim | 126 +++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/tests/script/tsim/stream/sliding.sim b/tests/script/tsim/stream/sliding.sim index 44f96cbefa..1ffca2a67b 100644 --- a/tests/script/tsim/stream/sliding.sim +++ b/tests/script/tsim/stream/sliding.sim @@ -239,5 +239,131 @@ if $data32 != 6 then goto loop0 endi +print step 4 + +sql create database test1 vgroups 1 +sql use test1 +sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +sql create stream streams11 trigger at_once into streamt as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s, 5s); +sql create stream streams12 trigger at_once into streamt2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s, 5s); + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t1 values(1648791223001,2,2,3,1.1); +sql insert into t1 values(1648791233002,3,2,3,2.1); +sql insert into t1 values(1648791243003,4,2,3,3.1); +sql insert into t1 values(1648791213004,4,2,3,4.1); + +sql insert into t2 values(1648791213000,1,2,3,1.0); +sql insert into t2 values(1648791223001,2,2,3,1.1); +sql insert into t2 values(1648791233002,3,2,3,2.1); +sql insert into t2 values(1648791243003,4,2,3,3.1); +sql insert into t2 values(1648791213004,4,2,3,4.1); + +$loop_count = 0 + +loop1: +sleep 300 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt + +# row 0 +if $data01 != 2 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 5 then + print =====data02=$data02 + goto loop1 +endi + +# row 1 +if $data11 != 1 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop1 +endi + +# row 2 +if $data21 != 1 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 3 then + print =====data22=$data22 + goto loop1 +endi + +# row 3 +if $data31 != 1 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 4 then + print =====data32=$data32 + goto loop1 +endi + +print step 5 + +sql select * from streamt2 + +# row 0 +if $data01 != 4 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 10 then + print =====data02=$data02 + goto loop1 +endi + +# row 1 +if $data11 != 2 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 4 then + print =====data12=$data12 + goto loop1 +endi + +# row 2 +if $data21 != 2 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 6 then + print =====data22=$data22 + goto loop1 +endi + +# row 3 +if $data31 != 2 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 8 then + print =====data32=$data32 + goto loop1 +endi system sh/stop_dnodes.sh \ No newline at end of file From 5a5ae23ddf44f2dd5cca4873116111d66793cb80 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 14 Jul 2022 16:58:54 +0800 Subject: [PATCH 59/65] fix: some problems of planner --- source/libs/parser/src/parInsert.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index f986d24a7e..f7d56261ae 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1167,6 +1167,13 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, TSKEY tsKey = TD_ROW_KEY(row); checkTimestamp(pDataBlocks, (const char*)&tsKey); } + + if (i < spd->numOfBound - 1) { + NEXT_VALID_TOKEN(pCxt->pSql, sToken); + if (TK_NK_COMMA != sToken.type) { + return buildSyntaxErrMsg(&pCxt->msg, ", expected", sToken.z); + } + } } if (!isParseBindParam) { From f0b8386b63bc4971b56eaabb6c34cad6290b9e72 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 17:00:46 +0800 Subject: [PATCH 60/65] refactor: adjust the name of stream automatically created by sma --- source/dnode/mnode/impl/inc/mndInt.h | 2 +- source/dnode/mnode/impl/src/mndMain.c | 2 +- source/dnode/mnode/impl/src/mndSma.c | 36 ++++++++++++++++++++------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index b94c60c4ab..9f168e2c83 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -125,7 +125,7 @@ typedef struct SMnode { } SMnode; void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp); -int64_t mndGenerateUid(char *name, int32_t len); +int64_t mndGenerateUid(const char *name, int32_t len); int32_t mndAcquireRpcRef(SMnode *pMnode); void mndReleaseRpcRef(SMnode *pMnode); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index df8dc42d17..29e68ce4e8 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -624,7 +624,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { } // Note: uid 0 is reserved -int64_t mndGenerateUid(char *name, int32_t len) { +int64_t mndGenerateUid(const char *name, int32_t len) { int32_t hashval = MurmurHash3_32(name, len); do { int64_t us = taosGetTimestampUs(); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index c040f0d05b..88629ebc69 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -479,7 +479,8 @@ static void mndDestroySmaObj(SSmaObj *pSmaObj) { } } -static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) { +static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb, + const char *streamName) { SSmaObj smaObj = {0}; memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); memcpy(smaObj.stb, pStb->name, TSDB_TABLE_FNAME_LEN); @@ -520,12 +521,12 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea } SStreamObj streamObj = {0}; - tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN); + tstrncpy(streamObj.name, streamName, TSDB_STREAM_FNAME_LEN); tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN); tstrncpy(streamObj.targetDb, streamObj.sourceDb, TSDB_DB_FNAME_LEN); streamObj.createTime = taosGetTimestampMs(); streamObj.updateTime = streamObj.createTime; - streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name)); + streamObj.uid = mndGenerateUid(streamName, strlen(streamName)); streamObj.sourceDbUid = pDb->uid; streamObj.targetDbUid = pDb->uid; streamObj.version = 1; @@ -590,7 +591,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea if (pTrans == NULL) goto _OVER; mndTransSetDbName(pTrans, pDb->name, NULL); mndTransSetSerial(pTrans); - mDebug("trans:%d, used to create sma:%s", pTrans->id, pCreate->name); + mDebug("trans:%d, used to create sma:%s stream:%s", pTrans->id, pCreate->name, streamObj.name); if (mndSetCreateSmaRedoLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupRedoLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER; @@ -638,6 +639,14 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) { return 0; } +static void mndGetStreamNameFromSmaName(char *streamName, char *smaName) { + SName n; + tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + streamName[0] = '1'; + streamName[1] = '.'; + strcpy(streamName + 2, tNameGetTableName(&n)); +} + static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; @@ -663,9 +672,12 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) { goto _OVER; } - pStream = mndAcquireStream(pMnode, createReq.name); + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + mndGetStreamNameFromSmaName(streamName, createReq.name); + + pStream = mndAcquireStream(pMnode, streamName); if (pStream != NULL) { - mError("sma:%s, failed to create since stream:%s already exist", createReq.name, createReq.name); + mError("sma:%s, failed to create since stream:%s already exist", createReq.name, streamName); terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST; goto _OVER; } @@ -692,7 +704,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) { goto _OVER; } - code = mndCreateSma(pMnode, pReq, &createReq, pDb, pStb); + code = mndCreateSma(pMnode, pReq, &createReq, pDb, pStb, streamName); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; _OVER: @@ -789,7 +801,10 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p mDebug("trans:%d, used to drop sma:%s", pTrans->id, pSma->name); mndTransSetDbName(pTrans, pDb->name, NULL); - SStreamObj *pStream = mndAcquireStream(pMnode, pSma->name); + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + mndGetStreamNameFromSmaName(streamName, pSma->name); + + SStreamObj *pStream = mndAcquireStream(pMnode, streamName); if (pStream == NULL || pStream->smaId != pSma->uid) { sdbRelease(pMnode->pSdb, pStream); goto _OVER; @@ -838,7 +853,10 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId); if (pVgroup == NULL) goto _OVER; - SStreamObj *pStream = mndAcquireStream(pMnode, pSma->name); + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + mndGetStreamNameFromSmaName(streamName, pSma->name); + + SStreamObj *pStream = mndAcquireStream(pMnode, streamName); if (pStream != NULL && pStream->smaId == pSma->uid) { if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { mError("stream:%s, failed to drop task since %s", pStream->name, terrstr()); From dc4052bd7ba273380cb308990046444d9951d7c4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Jul 2022 17:04:22 +0800 Subject: [PATCH 61/65] fix(query): handle the grouped fill. --- source/libs/executor/inc/executorimpl.h | 1 + source/libs/executor/src/executorimpl.c | 54 +++++++++++-------------- source/libs/executor/src/tfill.c | 17 ++++---- source/libs/function/src/builtinsimpl.c | 5 +-- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 74bb80eed1..d5d52d41ac 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -561,6 +561,7 @@ typedef struct SFillOperatorInfo { SNode* pCondition; SArray* pColMatchColInfo; int32_t primaryTsCol; + uint64_t curGroupId; // current handled group id } SFillOperatorInfo; typedef struct SGroupbyOperatorInfo { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 674bbfef0b..29e2ffc956 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1637,8 +1637,6 @@ static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows, int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t capacity) { int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, pBlock, capacity - pBlock->info.rows); - pBlock->info.rows += numOfRows; - return pBlock->info.rows; } @@ -3344,14 +3342,15 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo* pInfo, SResult taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock); doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pResultInfo->capacity); + pInfo->curGroupId = pInfo->existNewGroupBlock->info.groupId; pInfo->existNewGroupBlock = NULL; - *newgroup = true; +// *newgroup = true; } static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo* pInfo, SResultInfo* pResultInfo, bool* newgroup, SExecTaskInfo* pTaskInfo) { if (taosFillHasMoreResults(pInfo->pFillInfo)) { - *newgroup = false; +// *newgroup = false; doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pResultInfo->capacity); if (pInfo->pRes->info.rows > pResultInfo->threshold || (!pInfo->multigroupResult)) { return; @@ -3373,10 +3372,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { blockDataCleanup(pResBlock); - // todo handle different group data interpolation - bool n = false; - bool* newgroup = &n; - doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, newgroup, pTaskInfo); + doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, NULL, pTaskInfo); if (pResBlock->info.rows > pResultInfo->threshold || (!pInfo->multigroupResult && pResBlock->info.rows > 0)) { return pResBlock; } @@ -3384,31 +3380,29 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { SOperatorInfo* pDownstream = pOperator->pDownstream[0]; while (1) { SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream); - if (*newgroup) { - assert(pBlock != NULL); - } + if (pBlock == NULL) { + if (pInfo->totalInputRows == 0) { + pOperator->status = OP_EXEC_DONE; + return NULL; + } - blockDataUpdateTsWindow(pBlock, pInfo->primaryTsCol); - - if (*newgroup && pInfo->totalInputRows > 0) { // there are already processed current group data block - pInfo->existNewGroupBlock = pBlock; - *newgroup = false; - - // Fill the previous group data block, before handle the data block of new group. - // Close the fill operation for previous group data block taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey); } else { - if (pBlock == NULL) { - if (pInfo->totalInputRows == 0) { - pOperator->status = OP_EXEC_DONE; - return NULL; - } + blockDataUpdateTsWindow(pBlock, pInfo->primaryTsCol); + + if (pInfo->curGroupId == 0 || pInfo->curGroupId == pBlock->info.groupId) { + pInfo->curGroupId = pBlock->info.groupId; // the first data block - taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey); - } else { pInfo->totalInputRows += pBlock->info.rows; + taosFillSetStartInfo(pInfo->pFillInfo, pBlock->info.rows, pBlock->info.window.ekey); taosFillSetInputDataBlock(pInfo->pFillInfo, pBlock); + } else if (pInfo->curGroupId != pBlock->info.groupId) { // the new group data block + pInfo->existNewGroupBlock = pBlock; + + // Fill the previous group data block, before handle the data block of new group. + // Close the fill operation for previous group data block + taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey); } } @@ -3419,17 +3413,17 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { if (pResBlock->info.rows > 0) { // 1. The result in current group not reach the threshold of output result, continue // 2. If multiple group results existing in one SSDataBlock is not allowed, return immediately - if (pResBlock->info.rows > pResultInfo->threshold || pBlock == NULL || (!pInfo->multigroupResult)) { + if (pResBlock->info.rows > pResultInfo->threshold || pBlock == NULL || pInfo->existNewGroupBlock != NULL) { return pResBlock; } - doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, newgroup, pTaskInfo); - if (pResBlock->info.rows > pOperator->resultInfo.threshold || pBlock == NULL) { + doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, NULL, pTaskInfo); + if (pResBlock->info.rows >= pOperator->resultInfo.threshold || pBlock == NULL) { return pResBlock; } } else if (pInfo->existNewGroupBlock) { // try next group assert(pBlock != NULL); - doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, newgroup, pTaskInfo); + doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, NULL, pTaskInfo); if (pResBlock->info.rows > pResultInfo->threshold) { return pResBlock; } diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index e0bdcfdc3a..550938140e 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -72,7 +72,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); // set the primary timestamp column value - int32_t index = pFillInfo->numOfCurrent; + int32_t index = pBlock->info.rows; // set the other values if (pFillInfo->type == TSDB_FILL_PREV) { @@ -191,6 +191,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* SInterval* pInterval = &pFillInfo->interval; pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision); + pBlock->info.rows += 1; pFillInfo->numOfCurrent++; } @@ -273,6 +274,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t } } else { assert(pFillInfo->currentKey == ts); + int32_t index = pBlock->info.rows; if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) { int32_t nextRowIndex = pFillInfo->index + 1; @@ -296,24 +298,24 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t if (i == 0 || (/*pCol->functionId != FUNCTION_COUNT &&*/ !colDataIsNull_s(pSrc, pFillInfo->index)) /*|| (pCol->functionId == FUNCTION_COUNT && GET_INT64_VAL(src) != 0)*/) { bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); - colDataAppend(pDst, pFillInfo->numOfCurrent, src, isNull); + colDataAppend(pDst, index, src, isNull); saveColData(pFillInfo->prev, i, src, isNull); } else { // i > 0 and data is null , do interpolation if (pFillInfo->type == TSDB_FILL_PREV) { SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i); - doSetVal(pDst, pFillInfo->numOfCurrent, pKey); + doSetVal(pDst, index, pKey); } else if (pFillInfo->type == TSDB_FILL_LINEAR) { bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); - colDataAppend(pDst, pFillInfo->numOfCurrent, src, isNull); + colDataAppend(pDst, index, src, isNull); saveColData(pFillInfo->prev, i, src, isNull); } else if (pFillInfo->type == TSDB_FILL_NULL) { - colDataAppendNULL(pDst, pFillInfo->numOfCurrent); + colDataAppendNULL(pDst, index); } else if (pFillInfo->type == TSDB_FILL_NEXT) { SGroupKeys* pKey = taosArrayGet(pFillInfo->next, i); - doSetVal(pDst, pFillInfo->numOfCurrent, pKey); + doSetVal(pDst, index, pKey); } else { SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; - colDataAppend(pDst, pFillInfo->numOfCurrent, (char*)&pVar->i, false); + colDataAppend(pDst, index, (char*)&pVar->i, false); } } } @@ -324,6 +326,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision); + pBlock->info.rows += 1; pFillInfo->index += 1; pFillInfo->numOfCurrent += 1; } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 97cb1f0ee1..45d9c93c3e 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -6032,9 +6032,6 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { } pInfo->ts = cts; - pInfo->hasResult = true; - pResInfo->numOfRes = 1; - if (pCtx->subsidiaries.num > 0) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (!pInfo->hasResult) { @@ -6043,6 +6040,8 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) { copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); } } + + pInfo->hasResult = true; } } From 0bb06920286ab2aabbad60f5d3f7bd2a80be0ede Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 16:24:22 +0800 Subject: [PATCH 62/65] test: restore some 2.0 case --- tests/script/general/parser/testSuite.sim | 68 ----------- tests/script/jenkins/basic.txt | 110 +++++++++++++++++- .../{general => tsim}/parser/README.txt | 0 .../script/{general => tsim}/parser/alter.sim | 0 .../{general => tsim}/parser/alter1.sim | 0 .../parser/alter__for_community_version.sim | 0 .../{general => tsim}/parser/alter_column.sim | 0 .../{general => tsim}/parser/alter_stable.sim | 0 .../parser/auto_create_tb.sim | 0 .../parser/auto_create_tb_drop_tb.sim | 0 .../{general => tsim}/parser/between_and.sim | 0 .../parser/binary_escapeCharacter.sim | 0 .../parser/col_arithmetic_operation.sim | 0 .../parser/col_arithmetic_query.sim | 0 .../{general => tsim}/parser/columnValue.sim | 0 .../parser/columnValue_bigint.sim | 0 .../parser/columnValue_bool.sim | 0 .../parser/columnValue_double.sim | 0 .../parser/columnValue_float.sim | 0 .../parser/columnValue_int.sim | 0 .../parser/columnValue_smallint.sim | 0 .../parser/columnValue_tinyint.sim | 0 .../parser/columnValue_unsign.sim | 0 .../{general => tsim}/parser/commit.sim | 0 .../{general => tsim}/parser/condition.sim | 0 .../parser/condition_query.sim | 0 .../{general => tsim}/parser/constCol.sim | 0 .../{general => tsim}/parser/create_db.sim | 0 .../create_db__for_community_version.sim | 0 .../{general => tsim}/parser/create_mt.sim | 0 .../{general => tsim}/parser/create_tb.sim | 0 .../parser/create_tb_with_tag_name.sim | 0 .../parser/dbtbnameValidate.sim | 0 .../{general => tsim}/parser/distinct.sim | 0 .../script/{general => tsim}/parser/fill.sim | 0 .../{general => tsim}/parser/fill_stb.sim | 0 .../{general => tsim}/parser/fill_us.sim | 0 .../{general => tsim}/parser/first_last.sim | 0 .../parser/first_last_query.sim | 0 .../{general => tsim}/parser/function.sim | 0 .../{general => tsim}/parser/gendata.sh | 0 .../{general => tsim}/parser/groupby.sim | 0 .../{general => tsim}/parser/having.sim | 0 .../{general => tsim}/parser/having_child.sim | 0 .../{general => tsim}/parser/import.sim | 0 .../parser/import_commit1.sim | 0 .../parser/import_commit2.sim | 0 .../parser/import_commit3.sim | 0 .../{general => tsim}/parser/import_file.sim | 0 .../parser/insert_multiTbl.sim | 0 .../{general => tsim}/parser/insert_tb.sim | 0 .../{general => tsim}/parser/interp.sim | 0 .../{general => tsim}/parser/interp_test.sim | 0 .../script/{general => tsim}/parser/join.sim | 0 .../parser/join_manyblocks.sim | 0 .../parser/join_multitables.sim | 0 .../parser/join_multivnode.sim | 0 .../{general => tsim}/parser/last_cache.sim | 0 .../parser/last_cache_query.sim | 0 .../{general => tsim}/parser/last_groupby.sim | 0 .../{general => tsim}/parser/lastrow.sim | 0 .../parser/lastrow_query.sim | 0 .../script/{general => tsim}/parser/like.sim | 0 .../script/{general => tsim}/parser/limit.sim | 0 .../{general => tsim}/parser/limit1.sim | 0 .../{general => tsim}/parser/limit1_stb.sim | 0 .../{general => tsim}/parser/limit1_tb.sim | 0 .../parser/limit1_tblocks100.sim | 0 .../{general => tsim}/parser/limit2.sim | 0 .../{general => tsim}/parser/limit2_query.sim | 0 .../parser/limit2_tblocks100.sim | 0 .../{general => tsim}/parser/limit_stb.sim | 0 .../{general => tsim}/parser/limit_tb.sim | 0 .../{general => tsim}/parser/line_insert.sim | 0 .../{general => tsim}/parser/mixed_blocks.sim | 0 .../script/{general => tsim}/parser/nchar.sim | 0 .../{general => tsim}/parser/nestquery.sim | 0 .../{general => tsim}/parser/null_char.sim | 0 .../{general => tsim}/parser/precision_ns.sim | 0 .../parser/projection_limit_offset.sim | 0 .../script/{general => tsim}/parser/regex.sim | 0 .../{general => tsim}/parser/repeatAlter.sim | 0 .../{general => tsim}/parser/selectResNum.sim | 0 .../parser/select_across_vnodes.sim | 0 .../parser/select_distinct_tag.sim | 0 .../parser/select_from_cache_disk.sim | 0 .../parser/select_with_tags.sim | 0 .../{general => tsim}/parser/set_tag_vals.sim | 0 .../parser/single_row_in_tb.sim | 0 .../parser/single_row_in_tb_query.sim | 0 .../{general => tsim}/parser/sliding.sim | 0 .../{general => tsim}/parser/slimit.sim | 0 .../{general => tsim}/parser/slimit1.sim | 0 .../parser/slimit1_query.sim | 0 .../parser/slimit_alter_tags.sim | 0 .../{general => tsim}/parser/slimit_query.sim | 0 .../{general => tsim}/parser/stableOp.sim | 0 .../parser/tags_dynamically_specifiy.sim | 0 .../{general => tsim}/parser/tags_filter.sim | 0 .../{general => tsim}/parser/tbnameIn.sim | 0 .../parser/tbnameIn_query.sim | 0 .../{general => tsim}/parser/timestamp.sim | 0 .../parser/timestamp_query.sim | 0 .../{general => tsim}/parser/top_groupby.sim | 0 .../{general => tsim}/parser/topbot.sim | 0 tests/script/{general => tsim}/parser/udf.sim | 0 .../{general => tsim}/parser/udf_dll.sim | 0 .../parser/udf_dll_stable.sim | 0 .../script/{general => tsim}/parser/union.sim | 0 .../script/{general => tsim}/parser/where.sim | 0 110 files changed, 108 insertions(+), 70 deletions(-) delete mode 100644 tests/script/general/parser/testSuite.sim rename tests/script/{general => tsim}/parser/README.txt (100%) rename tests/script/{general => tsim}/parser/alter.sim (100%) rename tests/script/{general => tsim}/parser/alter1.sim (100%) rename tests/script/{general => tsim}/parser/alter__for_community_version.sim (100%) rename tests/script/{general => tsim}/parser/alter_column.sim (100%) rename tests/script/{general => tsim}/parser/alter_stable.sim (100%) rename tests/script/{general => tsim}/parser/auto_create_tb.sim (100%) rename tests/script/{general => tsim}/parser/auto_create_tb_drop_tb.sim (100%) rename tests/script/{general => tsim}/parser/between_and.sim (100%) rename tests/script/{general => tsim}/parser/binary_escapeCharacter.sim (100%) rename tests/script/{general => tsim}/parser/col_arithmetic_operation.sim (100%) rename tests/script/{general => tsim}/parser/col_arithmetic_query.sim (100%) rename tests/script/{general => tsim}/parser/columnValue.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_bigint.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_bool.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_double.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_float.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_int.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_smallint.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_tinyint.sim (100%) rename tests/script/{general => tsim}/parser/columnValue_unsign.sim (100%) rename tests/script/{general => tsim}/parser/commit.sim (100%) rename tests/script/{general => tsim}/parser/condition.sim (100%) rename tests/script/{general => tsim}/parser/condition_query.sim (100%) rename tests/script/{general => tsim}/parser/constCol.sim (100%) rename tests/script/{general => tsim}/parser/create_db.sim (100%) rename tests/script/{general => tsim}/parser/create_db__for_community_version.sim (100%) rename tests/script/{general => tsim}/parser/create_mt.sim (100%) rename tests/script/{general => tsim}/parser/create_tb.sim (100%) rename tests/script/{general => tsim}/parser/create_tb_with_tag_name.sim (100%) rename tests/script/{general => tsim}/parser/dbtbnameValidate.sim (100%) rename tests/script/{general => tsim}/parser/distinct.sim (100%) rename tests/script/{general => tsim}/parser/fill.sim (100%) rename tests/script/{general => tsim}/parser/fill_stb.sim (100%) rename tests/script/{general => tsim}/parser/fill_us.sim (100%) rename tests/script/{general => tsim}/parser/first_last.sim (100%) rename tests/script/{general => tsim}/parser/first_last_query.sim (100%) rename tests/script/{general => tsim}/parser/function.sim (100%) rename tests/script/{general => tsim}/parser/gendata.sh (100%) rename tests/script/{general => tsim}/parser/groupby.sim (100%) rename tests/script/{general => tsim}/parser/having.sim (100%) rename tests/script/{general => tsim}/parser/having_child.sim (100%) rename tests/script/{general => tsim}/parser/import.sim (100%) rename tests/script/{general => tsim}/parser/import_commit1.sim (100%) rename tests/script/{general => tsim}/parser/import_commit2.sim (100%) rename tests/script/{general => tsim}/parser/import_commit3.sim (100%) rename tests/script/{general => tsim}/parser/import_file.sim (100%) rename tests/script/{general => tsim}/parser/insert_multiTbl.sim (100%) rename tests/script/{general => tsim}/parser/insert_tb.sim (100%) rename tests/script/{general => tsim}/parser/interp.sim (100%) rename tests/script/{general => tsim}/parser/interp_test.sim (100%) rename tests/script/{general => tsim}/parser/join.sim (100%) rename tests/script/{general => tsim}/parser/join_manyblocks.sim (100%) rename tests/script/{general => tsim}/parser/join_multitables.sim (100%) rename tests/script/{general => tsim}/parser/join_multivnode.sim (100%) rename tests/script/{general => tsim}/parser/last_cache.sim (100%) rename tests/script/{general => tsim}/parser/last_cache_query.sim (100%) rename tests/script/{general => tsim}/parser/last_groupby.sim (100%) rename tests/script/{general => tsim}/parser/lastrow.sim (100%) rename tests/script/{general => tsim}/parser/lastrow_query.sim (100%) rename tests/script/{general => tsim}/parser/like.sim (100%) rename tests/script/{general => tsim}/parser/limit.sim (100%) rename tests/script/{general => tsim}/parser/limit1.sim (100%) rename tests/script/{general => tsim}/parser/limit1_stb.sim (100%) rename tests/script/{general => tsim}/parser/limit1_tb.sim (100%) rename tests/script/{general => tsim}/parser/limit1_tblocks100.sim (100%) rename tests/script/{general => tsim}/parser/limit2.sim (100%) rename tests/script/{general => tsim}/parser/limit2_query.sim (100%) rename tests/script/{general => tsim}/parser/limit2_tblocks100.sim (100%) rename tests/script/{general => tsim}/parser/limit_stb.sim (100%) rename tests/script/{general => tsim}/parser/limit_tb.sim (100%) rename tests/script/{general => tsim}/parser/line_insert.sim (100%) rename tests/script/{general => tsim}/parser/mixed_blocks.sim (100%) rename tests/script/{general => tsim}/parser/nchar.sim (100%) rename tests/script/{general => tsim}/parser/nestquery.sim (100%) rename tests/script/{general => tsim}/parser/null_char.sim (100%) rename tests/script/{general => tsim}/parser/precision_ns.sim (100%) rename tests/script/{general => tsim}/parser/projection_limit_offset.sim (100%) rename tests/script/{general => tsim}/parser/regex.sim (100%) rename tests/script/{general => tsim}/parser/repeatAlter.sim (100%) rename tests/script/{general => tsim}/parser/selectResNum.sim (100%) rename tests/script/{general => tsim}/parser/select_across_vnodes.sim (100%) rename tests/script/{general => tsim}/parser/select_distinct_tag.sim (100%) rename tests/script/{general => tsim}/parser/select_from_cache_disk.sim (100%) rename tests/script/{general => tsim}/parser/select_with_tags.sim (100%) rename tests/script/{general => tsim}/parser/set_tag_vals.sim (100%) rename tests/script/{general => tsim}/parser/single_row_in_tb.sim (100%) rename tests/script/{general => tsim}/parser/single_row_in_tb_query.sim (100%) rename tests/script/{general => tsim}/parser/sliding.sim (100%) rename tests/script/{general => tsim}/parser/slimit.sim (100%) rename tests/script/{general => tsim}/parser/slimit1.sim (100%) rename tests/script/{general => tsim}/parser/slimit1_query.sim (100%) rename tests/script/{general => tsim}/parser/slimit_alter_tags.sim (100%) rename tests/script/{general => tsim}/parser/slimit_query.sim (100%) rename tests/script/{general => tsim}/parser/stableOp.sim (100%) rename tests/script/{general => tsim}/parser/tags_dynamically_specifiy.sim (100%) rename tests/script/{general => tsim}/parser/tags_filter.sim (100%) rename tests/script/{general => tsim}/parser/tbnameIn.sim (100%) rename tests/script/{general => tsim}/parser/tbnameIn_query.sim (100%) rename tests/script/{general => tsim}/parser/timestamp.sim (100%) rename tests/script/{general => tsim}/parser/timestamp_query.sim (100%) rename tests/script/{general => tsim}/parser/top_groupby.sim (100%) rename tests/script/{general => tsim}/parser/topbot.sim (100%) rename tests/script/{general => tsim}/parser/udf.sim (100%) rename tests/script/{general => tsim}/parser/udf_dll.sim (100%) rename tests/script/{general => tsim}/parser/udf_dll_stable.sim (100%) rename tests/script/{general => tsim}/parser/union.sim (100%) rename tests/script/{general => tsim}/parser/where.sim (100%) diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim deleted file mode 100644 index fcd9d49fe5..0000000000 --- a/tests/script/general/parser/testSuite.sim +++ /dev/null @@ -1,68 +0,0 @@ -run general/parser/alter.sim -run general/parser/alter1.sim -run general/parser/alter_stable.sim -run general/parser/auto_create_tb.sim -run general/parser/auto_create_tb_drop_tb.sim -run general/parser/col_arithmetic_operation.sim -run general/parser/columnValue.sim -run general/parser/commit.sim -run general/parser/create_db.sim -run general/parser/create_mt.sim -run general/parser/create_tb.sim -run general/parser/dbtbnameValidate.sim -run general/parser/fill.sim -run general/parser/fill_stb.sim -#run general/parser/fill_us.sim # -run general/parser/first_last.sim -run general/parser/import_commit1.sim -run general/parser/import_commit2.sim -run general/parser/import_commit3.sim -run general/parser/import_file.sim -run general/parser/insert_tb.sim -run general/parser/tags_dynamically_specifiy.sim -run general/parser/interp.sim -run general/parser/lastrow.sim -run general/parser/limit.sim -run general/parser/limit1.sim -run general/parser/limit1_tblocks100.sim -run general/parser/limit2.sim -run general/parser/mixed_blocks.sim -run general/parser/nchar.sim -run general/parser/null_char.sim -run general/parser/selectResNum.sim -run general/parser/select_across_vnodes.sim -run general/parser/select_from_cache_disk.sim -run general/parser/set_tag_vals.sim -run general/parser/single_row_in_tb.sim -run general/parser/slimit.sim -run general/parser/slimit1.sim -run general/parser/slimit_alter_tags.sim -run general/parser/tbnameIn.sim -run general/parser/join.sim -run general/parser/join_multivnode.sim -run general/parser/join_manyblocks.sim -run general/parser/projection_limit_offset.sim -run general/parser/select_with_tags.sim -run general/parser/select_distinct_tag.sim -run general/parser/groupby.sim -run general/parser/tags_filter.sim -run general/parser/topbot.sim -run general/parser/union.sim -run general/parser/constCol.sim -run general/parser/where.sim -run general/parser/timestamp.sim -run general/parser/sliding.sim -run general/parser/function.sim -run general/parser/stableOp.sim -run general/parser/having.sim -run general/parser/having_child.sim -run general/parser/slimit_alter_tags.sim -run general/parser/binary_escapeCharacter.sim -run general/parser/between_and.sim -run general/parser/last_cache.sim -run general/parser/slimit_alter_tags.sim -run general/parser/udf.sim -run general/parser/udf_dll.sim -run general/parser/udf_dll_stable.sim -run general/parser/nestquery.sim -run general/parser/precision_ns.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 4c77051426..6b3031c0e5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -94,8 +94,114 @@ ./test.sh -f tsim/insert/update0.sim # ---- parser -./test.sh -f tsim/parser/groupby-basic.sim +# ./test.sh -f tsim/parser/alter.sim +# ./test.sh -f tsim/parser/alter1.sim +## ./test.sh -f tsim/parser/alter__for_community_version.sim +## ./test.sh -f tsim/parser/alter_column.sim +# ./test.sh -f tsim/parser/alter_stable.sim +# ./test.sh -f tsim/parser/auto_create_tb.sim +# ./test.sh -f tsim/parser/auto_create_tb_drop_tb.sim +# ./test.sh -f tsim/parser/between_and.sim +# ./test.sh -f tsim/parser/binary_escapeCharacter.sim +# ./test.sh -f tsim/parser/col_arithmetic_operation.sim +## ./test.sh -f tsim/parser/col_arithmetic_query.sim +## ./test.sh -f tsim/parser/columnValue.sim +## ./test.sh -f tsim/parser/columnValue_bigint.sim +## ./test.sh -f tsim/parser/columnValue_bool.sim +## ./test.sh -f tsim/parser/columnValue_double.sim +## ./test.sh -f tsim/parser/columnValue_float.sim +## ./test.sh -f tsim/parser/columnValue_int.sim +## ./test.sh -f tsim/parser/columnValue_smallint.sim +## ./test.sh -f tsim/parser/columnValue_tinyint.sim +## ./test.sh -f tsim/parser/columnValue_unsign.sim +## ./test.sh -f tsim/parser/commit.sim +## ./test.sh -f tsim/parser/condition.sim +## ./test.sh -f tsim/parser/condition_query.sim +## ./test.sh -f tsim/parser/constCol.sim +# ./test.sh -f tsim/parser/create_db.sim +## ./test.sh -f tsim/parser/create_db__for_community_version.sim +# ./test.sh -f tsim/parser/create_mt.sim +# ./test.sh -f tsim/parser/create_tb.sim +## ./test.sh -f tsim/parser/create_tb_with_tag_name.sim +# ./test.sh -f tsim/parser/dbtbnameValidate.sim +##./test.sh -f tsim/parser/distinct.sim +# ./test.sh -f tsim/parser/fill.sim +# ./test.sh -f tsim/parser/fill_stb.sim +## ./test.sh -f tsim/parser/fill_us.sim +# ./test.sh -f tsim/parser/first_last.sim +## ./test.sh -f tsim/parser/first_last_query.sim ./test.sh -f tsim/parser/fourArithmetic-basic.sim +## ./test.sh -f tsim/parser/function.sim +./test.sh -f tsim/parser/groupby-basic.sim +# ./test.sh -f tsim/parser/groupby.sim +## ./test.sh -f tsim/parser/having.sim +# ./test.sh -f tsim/parser/having_child.sim +## ./test.sh -f tsim/parser/import.sim +# ./test.sh -f tsim/parser/import_commit1.sim +# ./test.sh -f tsim/parser/import_commit2.sim +# ./test.sh -f tsim/parser/import_commit3.sim +## ./test.sh -f tsim/parser/import_file.sim +## ./test.sh -f tsim/parser/insert_multiTbl.sim +# ./test.sh -f tsim/parser/insert_tb.sim +## ./test.sh -f tsim/parser/interp.sim +## ./test.sh -f tsim/parser/interp_test.sim +# ./test.sh -f tsim/parser/join.sim +# ./test.sh -f tsim/parser/join_manyblocks.sim +## ./test.sh -f tsim/parser/join_multitables.sim +# ./test.sh -f tsim/parser/join_multivnode.sim +# ./test.sh -f tsim/parser/last_cache.sim +## ./test.sh -f tsim/parser/last_cache_query.sim +## ./test.sh -f tsim/parser/last_groupby.sim +# ./test.sh -f tsim/parser/lastrow.sim +## ./test.sh -f tsim/parser/lastrow_query.sim +## ./test.sh -f tsim/parser/like.sim +# ./test.sh -f tsim/parser/limit.sim +# ./test.sh -f tsim/parser/limit1.sim +## ./test.sh -f tsim/parser/limit1_stb.sim +## ./test.sh -f tsim/parser/limit1_tb.sim +# ./test.sh -f tsim/parser/limit1_tblocks100.sim +## ./test.sh -f tsim/parser/limit2.sim +## ./test.sh -f tsim/parser/limit2_query.sim +## ./test.sh -f tsim/parser/limit2_tblocks100.sim +## ./test.sh -f tsim/parser/limit_stb.sim +## ./test.sh -f tsim/parser/limit_tb.sim +## ./test.sh -f tsim/parser/line_insert.sim +# ./test.sh -f tsim/parser/mixed_blocks.sim +# ./test.sh -f tsim/parser/nchar.sim +# ./test.sh -f tsim/parser/nestquery.sim +# ./test.sh -f tsim/parser/null_char.sim +## ./test.sh -f tsim/parser/precision_ns.sim +# ./test.sh -f tsim/parser/projection_limit_offset.sim +## ./test.sh -f tsim/parser/regex.sim +# ./test.sh -f tsim/parser/repeatAlter.sim +# ./test.sh -f tsim/parser/selectResNum.sim +# ./test.sh -f tsim/parser/select_across_vnodes.sim +# ./test.sh -f tsim/parser/select_distinct_tag.sim +# ./test.sh -f tsim/parser/select_from_cache_disk.sim +# ./test.sh -f tsim/parser/select_with_tags.sim +# ./test.sh -f tsim/parser/set_tag_vals.sim +# ./test.sh -f tsim/parser/single_row_in_tb.sim +## ./test.sh -f tsim/parser/single_row_in_tb_query.sim +# ./test.sh -f tsim/parser/sliding.sim +# ./test.sh -f tsim/parser/slimit.sim +# ./test.sh -f tsim/parser/slimit1.sim +## ./test.sh -f tsim/parser/slimit1_query.sim +# ./test.sh -f tsim/parser/slimit_alter_tags.sim +## ./test.sh -f tsim/parser/slimit_query.sim +# ./test.sh -f tsim/parser/stableOp.sim +# ./test.sh -f tsim/parser/tags_dynamically_specifiy.sim +# ./test.sh -f tsim/parser/tags_filter.sim +# ./test.sh -f tsim/parser/tbnameIn.sim +## ./test.sh -f tsim/parser/tbnameIn_query.sim +# ./test.sh -f tsim/parser/timestamp.sim +## ./test.sh -f tsim/parser/timestamp_query.sim +## ./test.sh -f tsim/parser/top_groupby.sim +# ./test.sh -f tsim/parser/topbot.sim +# ./test.sh -f tsim/parser/udf.sim +# ./test.sh -f tsim/parser/udf_dll.sim +# ./test.sh -f tsim/parser/udf_dll_stable.sim +# ./test.sh -f tsim/parser/union.sim +# ./test.sh -f tsim/parser/where.sim # ---- query ./test.sh -f tsim/query/interval.sim @@ -220,7 +326,7 @@ ./test.sh -f tsim/db/basic3.sim -m ./test.sh -f tsim/db/error1.sim -m ./test.sh -f tsim/insert/backquote.sim -m -./test.sh -f tsim/parser/fourArithmetic-basic.sim -m +# ./test.sh -f tsim/parser/fourArithmetic-basic.sim -m ./test.sh -f tsim/query/interval-offset.sim -m ./test.sh -f tsim/tmq/basic3.sim -m ./test.sh -f tsim/stable/vnode3.sim -m diff --git a/tests/script/general/parser/README.txt b/tests/script/tsim/parser/README.txt similarity index 100% rename from tests/script/general/parser/README.txt rename to tests/script/tsim/parser/README.txt diff --git a/tests/script/general/parser/alter.sim b/tests/script/tsim/parser/alter.sim similarity index 100% rename from tests/script/general/parser/alter.sim rename to tests/script/tsim/parser/alter.sim diff --git a/tests/script/general/parser/alter1.sim b/tests/script/tsim/parser/alter1.sim similarity index 100% rename from tests/script/general/parser/alter1.sim rename to tests/script/tsim/parser/alter1.sim diff --git a/tests/script/general/parser/alter__for_community_version.sim b/tests/script/tsim/parser/alter__for_community_version.sim similarity index 100% rename from tests/script/general/parser/alter__for_community_version.sim rename to tests/script/tsim/parser/alter__for_community_version.sim diff --git a/tests/script/general/parser/alter_column.sim b/tests/script/tsim/parser/alter_column.sim similarity index 100% rename from tests/script/general/parser/alter_column.sim rename to tests/script/tsim/parser/alter_column.sim diff --git a/tests/script/general/parser/alter_stable.sim b/tests/script/tsim/parser/alter_stable.sim similarity index 100% rename from tests/script/general/parser/alter_stable.sim rename to tests/script/tsim/parser/alter_stable.sim diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/tsim/parser/auto_create_tb.sim similarity index 100% rename from tests/script/general/parser/auto_create_tb.sim rename to tests/script/tsim/parser/auto_create_tb.sim diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/tsim/parser/auto_create_tb_drop_tb.sim similarity index 100% rename from tests/script/general/parser/auto_create_tb_drop_tb.sim rename to tests/script/tsim/parser/auto_create_tb_drop_tb.sim diff --git a/tests/script/general/parser/between_and.sim b/tests/script/tsim/parser/between_and.sim similarity index 100% rename from tests/script/general/parser/between_and.sim rename to tests/script/tsim/parser/between_and.sim diff --git a/tests/script/general/parser/binary_escapeCharacter.sim b/tests/script/tsim/parser/binary_escapeCharacter.sim similarity index 100% rename from tests/script/general/parser/binary_escapeCharacter.sim rename to tests/script/tsim/parser/binary_escapeCharacter.sim diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/tsim/parser/col_arithmetic_operation.sim similarity index 100% rename from tests/script/general/parser/col_arithmetic_operation.sim rename to tests/script/tsim/parser/col_arithmetic_operation.sim diff --git a/tests/script/general/parser/col_arithmetic_query.sim b/tests/script/tsim/parser/col_arithmetic_query.sim similarity index 100% rename from tests/script/general/parser/col_arithmetic_query.sim rename to tests/script/tsim/parser/col_arithmetic_query.sim diff --git a/tests/script/general/parser/columnValue.sim b/tests/script/tsim/parser/columnValue.sim similarity index 100% rename from tests/script/general/parser/columnValue.sim rename to tests/script/tsim/parser/columnValue.sim diff --git a/tests/script/general/parser/columnValue_bigint.sim b/tests/script/tsim/parser/columnValue_bigint.sim similarity index 100% rename from tests/script/general/parser/columnValue_bigint.sim rename to tests/script/tsim/parser/columnValue_bigint.sim diff --git a/tests/script/general/parser/columnValue_bool.sim b/tests/script/tsim/parser/columnValue_bool.sim similarity index 100% rename from tests/script/general/parser/columnValue_bool.sim rename to tests/script/tsim/parser/columnValue_bool.sim diff --git a/tests/script/general/parser/columnValue_double.sim b/tests/script/tsim/parser/columnValue_double.sim similarity index 100% rename from tests/script/general/parser/columnValue_double.sim rename to tests/script/tsim/parser/columnValue_double.sim diff --git a/tests/script/general/parser/columnValue_float.sim b/tests/script/tsim/parser/columnValue_float.sim similarity index 100% rename from tests/script/general/parser/columnValue_float.sim rename to tests/script/tsim/parser/columnValue_float.sim diff --git a/tests/script/general/parser/columnValue_int.sim b/tests/script/tsim/parser/columnValue_int.sim similarity index 100% rename from tests/script/general/parser/columnValue_int.sim rename to tests/script/tsim/parser/columnValue_int.sim diff --git a/tests/script/general/parser/columnValue_smallint.sim b/tests/script/tsim/parser/columnValue_smallint.sim similarity index 100% rename from tests/script/general/parser/columnValue_smallint.sim rename to tests/script/tsim/parser/columnValue_smallint.sim diff --git a/tests/script/general/parser/columnValue_tinyint.sim b/tests/script/tsim/parser/columnValue_tinyint.sim similarity index 100% rename from tests/script/general/parser/columnValue_tinyint.sim rename to tests/script/tsim/parser/columnValue_tinyint.sim diff --git a/tests/script/general/parser/columnValue_unsign.sim b/tests/script/tsim/parser/columnValue_unsign.sim similarity index 100% rename from tests/script/general/parser/columnValue_unsign.sim rename to tests/script/tsim/parser/columnValue_unsign.sim diff --git a/tests/script/general/parser/commit.sim b/tests/script/tsim/parser/commit.sim similarity index 100% rename from tests/script/general/parser/commit.sim rename to tests/script/tsim/parser/commit.sim diff --git a/tests/script/general/parser/condition.sim b/tests/script/tsim/parser/condition.sim similarity index 100% rename from tests/script/general/parser/condition.sim rename to tests/script/tsim/parser/condition.sim diff --git a/tests/script/general/parser/condition_query.sim b/tests/script/tsim/parser/condition_query.sim similarity index 100% rename from tests/script/general/parser/condition_query.sim rename to tests/script/tsim/parser/condition_query.sim diff --git a/tests/script/general/parser/constCol.sim b/tests/script/tsim/parser/constCol.sim similarity index 100% rename from tests/script/general/parser/constCol.sim rename to tests/script/tsim/parser/constCol.sim diff --git a/tests/script/general/parser/create_db.sim b/tests/script/tsim/parser/create_db.sim similarity index 100% rename from tests/script/general/parser/create_db.sim rename to tests/script/tsim/parser/create_db.sim diff --git a/tests/script/general/parser/create_db__for_community_version.sim b/tests/script/tsim/parser/create_db__for_community_version.sim similarity index 100% rename from tests/script/general/parser/create_db__for_community_version.sim rename to tests/script/tsim/parser/create_db__for_community_version.sim diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/tsim/parser/create_mt.sim similarity index 100% rename from tests/script/general/parser/create_mt.sim rename to tests/script/tsim/parser/create_mt.sim diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/tsim/parser/create_tb.sim similarity index 100% rename from tests/script/general/parser/create_tb.sim rename to tests/script/tsim/parser/create_tb.sim diff --git a/tests/script/general/parser/create_tb_with_tag_name.sim b/tests/script/tsim/parser/create_tb_with_tag_name.sim similarity index 100% rename from tests/script/general/parser/create_tb_with_tag_name.sim rename to tests/script/tsim/parser/create_tb_with_tag_name.sim diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/tsim/parser/dbtbnameValidate.sim similarity index 100% rename from tests/script/general/parser/dbtbnameValidate.sim rename to tests/script/tsim/parser/dbtbnameValidate.sim diff --git a/tests/script/general/parser/distinct.sim b/tests/script/tsim/parser/distinct.sim similarity index 100% rename from tests/script/general/parser/distinct.sim rename to tests/script/tsim/parser/distinct.sim diff --git a/tests/script/general/parser/fill.sim b/tests/script/tsim/parser/fill.sim similarity index 100% rename from tests/script/general/parser/fill.sim rename to tests/script/tsim/parser/fill.sim diff --git a/tests/script/general/parser/fill_stb.sim b/tests/script/tsim/parser/fill_stb.sim similarity index 100% rename from tests/script/general/parser/fill_stb.sim rename to tests/script/tsim/parser/fill_stb.sim diff --git a/tests/script/general/parser/fill_us.sim b/tests/script/tsim/parser/fill_us.sim similarity index 100% rename from tests/script/general/parser/fill_us.sim rename to tests/script/tsim/parser/fill_us.sim diff --git a/tests/script/general/parser/first_last.sim b/tests/script/tsim/parser/first_last.sim similarity index 100% rename from tests/script/general/parser/first_last.sim rename to tests/script/tsim/parser/first_last.sim diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/tsim/parser/first_last_query.sim similarity index 100% rename from tests/script/general/parser/first_last_query.sim rename to tests/script/tsim/parser/first_last_query.sim diff --git a/tests/script/general/parser/function.sim b/tests/script/tsim/parser/function.sim similarity index 100% rename from tests/script/general/parser/function.sim rename to tests/script/tsim/parser/function.sim diff --git a/tests/script/general/parser/gendata.sh b/tests/script/tsim/parser/gendata.sh similarity index 100% rename from tests/script/general/parser/gendata.sh rename to tests/script/tsim/parser/gendata.sh diff --git a/tests/script/general/parser/groupby.sim b/tests/script/tsim/parser/groupby.sim similarity index 100% rename from tests/script/general/parser/groupby.sim rename to tests/script/tsim/parser/groupby.sim diff --git a/tests/script/general/parser/having.sim b/tests/script/tsim/parser/having.sim similarity index 100% rename from tests/script/general/parser/having.sim rename to tests/script/tsim/parser/having.sim diff --git a/tests/script/general/parser/having_child.sim b/tests/script/tsim/parser/having_child.sim similarity index 100% rename from tests/script/general/parser/having_child.sim rename to tests/script/tsim/parser/having_child.sim diff --git a/tests/script/general/parser/import.sim b/tests/script/tsim/parser/import.sim similarity index 100% rename from tests/script/general/parser/import.sim rename to tests/script/tsim/parser/import.sim diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/tsim/parser/import_commit1.sim similarity index 100% rename from tests/script/general/parser/import_commit1.sim rename to tests/script/tsim/parser/import_commit1.sim diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/tsim/parser/import_commit2.sim similarity index 100% rename from tests/script/general/parser/import_commit2.sim rename to tests/script/tsim/parser/import_commit2.sim diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/tsim/parser/import_commit3.sim similarity index 100% rename from tests/script/general/parser/import_commit3.sim rename to tests/script/tsim/parser/import_commit3.sim diff --git a/tests/script/general/parser/import_file.sim b/tests/script/tsim/parser/import_file.sim similarity index 100% rename from tests/script/general/parser/import_file.sim rename to tests/script/tsim/parser/import_file.sim diff --git a/tests/script/general/parser/insert_multiTbl.sim b/tests/script/tsim/parser/insert_multiTbl.sim similarity index 100% rename from tests/script/general/parser/insert_multiTbl.sim rename to tests/script/tsim/parser/insert_multiTbl.sim diff --git a/tests/script/general/parser/insert_tb.sim b/tests/script/tsim/parser/insert_tb.sim similarity index 100% rename from tests/script/general/parser/insert_tb.sim rename to tests/script/tsim/parser/insert_tb.sim diff --git a/tests/script/general/parser/interp.sim b/tests/script/tsim/parser/interp.sim similarity index 100% rename from tests/script/general/parser/interp.sim rename to tests/script/tsim/parser/interp.sim diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/tsim/parser/interp_test.sim similarity index 100% rename from tests/script/general/parser/interp_test.sim rename to tests/script/tsim/parser/interp_test.sim diff --git a/tests/script/general/parser/join.sim b/tests/script/tsim/parser/join.sim similarity index 100% rename from tests/script/general/parser/join.sim rename to tests/script/tsim/parser/join.sim diff --git a/tests/script/general/parser/join_manyblocks.sim b/tests/script/tsim/parser/join_manyblocks.sim similarity index 100% rename from tests/script/general/parser/join_manyblocks.sim rename to tests/script/tsim/parser/join_manyblocks.sim diff --git a/tests/script/general/parser/join_multitables.sim b/tests/script/tsim/parser/join_multitables.sim similarity index 100% rename from tests/script/general/parser/join_multitables.sim rename to tests/script/tsim/parser/join_multitables.sim diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/tsim/parser/join_multivnode.sim similarity index 100% rename from tests/script/general/parser/join_multivnode.sim rename to tests/script/tsim/parser/join_multivnode.sim diff --git a/tests/script/general/parser/last_cache.sim b/tests/script/tsim/parser/last_cache.sim similarity index 100% rename from tests/script/general/parser/last_cache.sim rename to tests/script/tsim/parser/last_cache.sim diff --git a/tests/script/general/parser/last_cache_query.sim b/tests/script/tsim/parser/last_cache_query.sim similarity index 100% rename from tests/script/general/parser/last_cache_query.sim rename to tests/script/tsim/parser/last_cache_query.sim diff --git a/tests/script/general/parser/last_groupby.sim b/tests/script/tsim/parser/last_groupby.sim similarity index 100% rename from tests/script/general/parser/last_groupby.sim rename to tests/script/tsim/parser/last_groupby.sim diff --git a/tests/script/general/parser/lastrow.sim b/tests/script/tsim/parser/lastrow.sim similarity index 100% rename from tests/script/general/parser/lastrow.sim rename to tests/script/tsim/parser/lastrow.sim diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/tsim/parser/lastrow_query.sim similarity index 100% rename from tests/script/general/parser/lastrow_query.sim rename to tests/script/tsim/parser/lastrow_query.sim diff --git a/tests/script/general/parser/like.sim b/tests/script/tsim/parser/like.sim similarity index 100% rename from tests/script/general/parser/like.sim rename to tests/script/tsim/parser/like.sim diff --git a/tests/script/general/parser/limit.sim b/tests/script/tsim/parser/limit.sim similarity index 100% rename from tests/script/general/parser/limit.sim rename to tests/script/tsim/parser/limit.sim diff --git a/tests/script/general/parser/limit1.sim b/tests/script/tsim/parser/limit1.sim similarity index 100% rename from tests/script/general/parser/limit1.sim rename to tests/script/tsim/parser/limit1.sim diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/tsim/parser/limit1_stb.sim similarity index 100% rename from tests/script/general/parser/limit1_stb.sim rename to tests/script/tsim/parser/limit1_stb.sim diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/tsim/parser/limit1_tb.sim similarity index 100% rename from tests/script/general/parser/limit1_tb.sim rename to tests/script/tsim/parser/limit1_tb.sim diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/tsim/parser/limit1_tblocks100.sim similarity index 100% rename from tests/script/general/parser/limit1_tblocks100.sim rename to tests/script/tsim/parser/limit1_tblocks100.sim diff --git a/tests/script/general/parser/limit2.sim b/tests/script/tsim/parser/limit2.sim similarity index 100% rename from tests/script/general/parser/limit2.sim rename to tests/script/tsim/parser/limit2.sim diff --git a/tests/script/general/parser/limit2_query.sim b/tests/script/tsim/parser/limit2_query.sim similarity index 100% rename from tests/script/general/parser/limit2_query.sim rename to tests/script/tsim/parser/limit2_query.sim diff --git a/tests/script/general/parser/limit2_tblocks100.sim b/tests/script/tsim/parser/limit2_tblocks100.sim similarity index 100% rename from tests/script/general/parser/limit2_tblocks100.sim rename to tests/script/tsim/parser/limit2_tblocks100.sim diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/tsim/parser/limit_stb.sim similarity index 100% rename from tests/script/general/parser/limit_stb.sim rename to tests/script/tsim/parser/limit_stb.sim diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/tsim/parser/limit_tb.sim similarity index 100% rename from tests/script/general/parser/limit_tb.sim rename to tests/script/tsim/parser/limit_tb.sim diff --git a/tests/script/general/parser/line_insert.sim b/tests/script/tsim/parser/line_insert.sim similarity index 100% rename from tests/script/general/parser/line_insert.sim rename to tests/script/tsim/parser/line_insert.sim diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/tsim/parser/mixed_blocks.sim similarity index 100% rename from tests/script/general/parser/mixed_blocks.sim rename to tests/script/tsim/parser/mixed_blocks.sim diff --git a/tests/script/general/parser/nchar.sim b/tests/script/tsim/parser/nchar.sim similarity index 100% rename from tests/script/general/parser/nchar.sim rename to tests/script/tsim/parser/nchar.sim diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim similarity index 100% rename from tests/script/general/parser/nestquery.sim rename to tests/script/tsim/parser/nestquery.sim diff --git a/tests/script/general/parser/null_char.sim b/tests/script/tsim/parser/null_char.sim similarity index 100% rename from tests/script/general/parser/null_char.sim rename to tests/script/tsim/parser/null_char.sim diff --git a/tests/script/general/parser/precision_ns.sim b/tests/script/tsim/parser/precision_ns.sim similarity index 100% rename from tests/script/general/parser/precision_ns.sim rename to tests/script/tsim/parser/precision_ns.sim diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/tsim/parser/projection_limit_offset.sim similarity index 100% rename from tests/script/general/parser/projection_limit_offset.sim rename to tests/script/tsim/parser/projection_limit_offset.sim diff --git a/tests/script/general/parser/regex.sim b/tests/script/tsim/parser/regex.sim similarity index 100% rename from tests/script/general/parser/regex.sim rename to tests/script/tsim/parser/regex.sim diff --git a/tests/script/general/parser/repeatAlter.sim b/tests/script/tsim/parser/repeatAlter.sim similarity index 100% rename from tests/script/general/parser/repeatAlter.sim rename to tests/script/tsim/parser/repeatAlter.sim diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/tsim/parser/selectResNum.sim similarity index 100% rename from tests/script/general/parser/selectResNum.sim rename to tests/script/tsim/parser/selectResNum.sim diff --git a/tests/script/general/parser/select_across_vnodes.sim b/tests/script/tsim/parser/select_across_vnodes.sim similarity index 100% rename from tests/script/general/parser/select_across_vnodes.sim rename to tests/script/tsim/parser/select_across_vnodes.sim diff --git a/tests/script/general/parser/select_distinct_tag.sim b/tests/script/tsim/parser/select_distinct_tag.sim similarity index 100% rename from tests/script/general/parser/select_distinct_tag.sim rename to tests/script/tsim/parser/select_distinct_tag.sim diff --git a/tests/script/general/parser/select_from_cache_disk.sim b/tests/script/tsim/parser/select_from_cache_disk.sim similarity index 100% rename from tests/script/general/parser/select_from_cache_disk.sim rename to tests/script/tsim/parser/select_from_cache_disk.sim diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/tsim/parser/select_with_tags.sim similarity index 100% rename from tests/script/general/parser/select_with_tags.sim rename to tests/script/tsim/parser/select_with_tags.sim diff --git a/tests/script/general/parser/set_tag_vals.sim b/tests/script/tsim/parser/set_tag_vals.sim similarity index 100% rename from tests/script/general/parser/set_tag_vals.sim rename to tests/script/tsim/parser/set_tag_vals.sim diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/tsim/parser/single_row_in_tb.sim similarity index 100% rename from tests/script/general/parser/single_row_in_tb.sim rename to tests/script/tsim/parser/single_row_in_tb.sim diff --git a/tests/script/general/parser/single_row_in_tb_query.sim b/tests/script/tsim/parser/single_row_in_tb_query.sim similarity index 100% rename from tests/script/general/parser/single_row_in_tb_query.sim rename to tests/script/tsim/parser/single_row_in_tb_query.sim diff --git a/tests/script/general/parser/sliding.sim b/tests/script/tsim/parser/sliding.sim similarity index 100% rename from tests/script/general/parser/sliding.sim rename to tests/script/tsim/parser/sliding.sim diff --git a/tests/script/general/parser/slimit.sim b/tests/script/tsim/parser/slimit.sim similarity index 100% rename from tests/script/general/parser/slimit.sim rename to tests/script/tsim/parser/slimit.sim diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/tsim/parser/slimit1.sim similarity index 100% rename from tests/script/general/parser/slimit1.sim rename to tests/script/tsim/parser/slimit1.sim diff --git a/tests/script/general/parser/slimit1_query.sim b/tests/script/tsim/parser/slimit1_query.sim similarity index 100% rename from tests/script/general/parser/slimit1_query.sim rename to tests/script/tsim/parser/slimit1_query.sim diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/tsim/parser/slimit_alter_tags.sim similarity index 100% rename from tests/script/general/parser/slimit_alter_tags.sim rename to tests/script/tsim/parser/slimit_alter_tags.sim diff --git a/tests/script/general/parser/slimit_query.sim b/tests/script/tsim/parser/slimit_query.sim similarity index 100% rename from tests/script/general/parser/slimit_query.sim rename to tests/script/tsim/parser/slimit_query.sim diff --git a/tests/script/general/parser/stableOp.sim b/tests/script/tsim/parser/stableOp.sim similarity index 100% rename from tests/script/general/parser/stableOp.sim rename to tests/script/tsim/parser/stableOp.sim diff --git a/tests/script/general/parser/tags_dynamically_specifiy.sim b/tests/script/tsim/parser/tags_dynamically_specifiy.sim similarity index 100% rename from tests/script/general/parser/tags_dynamically_specifiy.sim rename to tests/script/tsim/parser/tags_dynamically_specifiy.sim diff --git a/tests/script/general/parser/tags_filter.sim b/tests/script/tsim/parser/tags_filter.sim similarity index 100% rename from tests/script/general/parser/tags_filter.sim rename to tests/script/tsim/parser/tags_filter.sim diff --git a/tests/script/general/parser/tbnameIn.sim b/tests/script/tsim/parser/tbnameIn.sim similarity index 100% rename from tests/script/general/parser/tbnameIn.sim rename to tests/script/tsim/parser/tbnameIn.sim diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/tsim/parser/tbnameIn_query.sim similarity index 100% rename from tests/script/general/parser/tbnameIn_query.sim rename to tests/script/tsim/parser/tbnameIn_query.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/tsim/parser/timestamp.sim similarity index 100% rename from tests/script/general/parser/timestamp.sim rename to tests/script/tsim/parser/timestamp.sim diff --git a/tests/script/general/parser/timestamp_query.sim b/tests/script/tsim/parser/timestamp_query.sim similarity index 100% rename from tests/script/general/parser/timestamp_query.sim rename to tests/script/tsim/parser/timestamp_query.sim diff --git a/tests/script/general/parser/top_groupby.sim b/tests/script/tsim/parser/top_groupby.sim similarity index 100% rename from tests/script/general/parser/top_groupby.sim rename to tests/script/tsim/parser/top_groupby.sim diff --git a/tests/script/general/parser/topbot.sim b/tests/script/tsim/parser/topbot.sim similarity index 100% rename from tests/script/general/parser/topbot.sim rename to tests/script/tsim/parser/topbot.sim diff --git a/tests/script/general/parser/udf.sim b/tests/script/tsim/parser/udf.sim similarity index 100% rename from tests/script/general/parser/udf.sim rename to tests/script/tsim/parser/udf.sim diff --git a/tests/script/general/parser/udf_dll.sim b/tests/script/tsim/parser/udf_dll.sim similarity index 100% rename from tests/script/general/parser/udf_dll.sim rename to tests/script/tsim/parser/udf_dll.sim diff --git a/tests/script/general/parser/udf_dll_stable.sim b/tests/script/tsim/parser/udf_dll_stable.sim similarity index 100% rename from tests/script/general/parser/udf_dll_stable.sim rename to tests/script/tsim/parser/udf_dll_stable.sim diff --git a/tests/script/general/parser/union.sim b/tests/script/tsim/parser/union.sim similarity index 100% rename from tests/script/general/parser/union.sim rename to tests/script/tsim/parser/union.sim diff --git a/tests/script/general/parser/where.sim b/tests/script/tsim/parser/where.sim similarity index 100% rename from tests/script/general/parser/where.sim rename to tests/script/tsim/parser/where.sim From 61eab5fc2183e98fb8163e6bad16f95e51242c85 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 14 Jul 2022 17:26:52 +0800 Subject: [PATCH 63/65] test: restore some 2.0 case --- tests/script/jenkins/basic.txt | 8 +++++++- tests/script/{ => tsim}/issue/TD-2677.sim | 0 tests/script/{ => tsim}/issue/TD-2680.sim | 0 tests/script/{ => tsim}/issue/TD-2713.sim | 0 tests/script/{ => tsim}/issue/TD-3300.sim | 0 5 files changed, 7 insertions(+), 1 deletion(-) rename tests/script/{ => tsim}/issue/TD-2677.sim (100%) rename tests/script/{ => tsim}/issue/TD-2680.sim (100%) rename tests/script/{ => tsim}/issue/TD-2713.sim (100%) rename tests/script/{ => tsim}/issue/TD-3300.sim (100%) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 6b3031c0e5..c2c102c241 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -374,7 +374,7 @@ # ---- alter ./test.sh -f tsim/alter/cached_schema_after_alter.sim ./test.sh -f tsim/alter/dnode.sim -#./test.sh -f tsim/alter/table.sim +./test.sh -f tsim/alter/table.sim # ---- cache ./test.sh -f tsim/cache/new_metrics.sim @@ -445,6 +445,12 @@ # ---- wal ./test.sh -f tsim/wal/kill.sim +# ---- issue +#./test.sh -f tsim/issue/TD-2677.sim +#./test.sh -f tsim/issue/TD-2680.sim +#./test.sh -f tsim/issue/TD-2713.sim +#./test.sh -f tsim/issue/TD-3300.sim + # ---- tag ./test.sh -f tsim/tag/3.sim ./test.sh -f tsim/tag/4.sim diff --git a/tests/script/issue/TD-2677.sim b/tests/script/tsim/issue/TD-2677.sim similarity index 100% rename from tests/script/issue/TD-2677.sim rename to tests/script/tsim/issue/TD-2677.sim diff --git a/tests/script/issue/TD-2680.sim b/tests/script/tsim/issue/TD-2680.sim similarity index 100% rename from tests/script/issue/TD-2680.sim rename to tests/script/tsim/issue/TD-2680.sim diff --git a/tests/script/issue/TD-2713.sim b/tests/script/tsim/issue/TD-2713.sim similarity index 100% rename from tests/script/issue/TD-2713.sim rename to tests/script/tsim/issue/TD-2713.sim diff --git a/tests/script/issue/TD-3300.sim b/tests/script/tsim/issue/TD-3300.sim similarity index 100% rename from tests/script/issue/TD-3300.sim rename to tests/script/tsim/issue/TD-3300.sim From 9847abf166ce71c600798fc90e28c6b5cb86a35d Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 14 Jul 2022 17:34:06 +0800 Subject: [PATCH 64/65] fix(sma): double free --- source/dnode/vnode/src/sma/smaRollup.c | 40 ++++++------------- source/libs/executor/src/scanoperator.c | 12 +++--- source/libs/executor/src/timewindowoperator.c | 1 - 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 06ffb639de..a6d56acbfb 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -30,7 +30,7 @@ typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo, - SReadHandle *handle, int8_t idx); + int8_t idx); static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *rsmaItem, STSchema *pTSchema, tb_uid_t suid, int8_t level); static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid); @@ -256,14 +256,20 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui } static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo, - SReadHandle *pReadHandle, int8_t idx) { + int8_t idx) { SRetention *pRetention = SMA_RETENTION(pSma); STsdbCfg *pTsdbCfg = SMA_TSDB_CFG(pSma); + SReadHandle handle = { + .meta = pSma->pVnode->pMeta, + .vnode = pSma->pVnode, + .initTqReader = 1, + }; + if (param->qmsg[idx]) { SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]); pItem->refId = RSMA_REF_ID(pStat); - pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], pReadHandle); + pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); if (!pItem->taskInfo) { terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; goto _err; @@ -299,10 +305,6 @@ _err: * @return int32_t */ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) { - SVnode *pVnode = pSma->pVnode; - SMeta *pMeta = pVnode->pMeta; - SMsgCb *pMsgCb = &pVnode->msgCb; - if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) { smaDebug("vgId:%d, no qmsg1/qmsg2 for rollup table %s %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; @@ -331,19 +333,6 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con return TSDB_CODE_FAILED; } - STqReader *pReader = tqOpenReader(pVnode); - if (!pReader) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - - SReadHandle handle = { - .tqReader = pReader, - .meta = pMeta, - .pMsgCb = pMsgCb, - .vnode = pVnode, - }; - STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), suid, -1); if (!pTSchema) { terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION; @@ -352,11 +341,11 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con pRSmaInfo->pTSchema = pTSchema; pRSmaInfo->suid = suid; - if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, &handle, 0) < 0) { + if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 0) < 0) { goto _err; } - if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, &handle, 1) < 0) { + if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 1) < 0) { goto _err; } @@ -369,7 +358,6 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con return TSDB_CODE_SUCCESS; _err: tdFreeRSmaInfo(pSma, pRSmaInfo); - taosMemoryFree(pReader); return TSDB_CODE_FAILED; } @@ -404,7 +392,7 @@ int32_t tdProcessRSmaCreate(SSma *pSma, SVCreateStbReq *pReq) { * @param pReq * @return int32_t */ -int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) { +int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) { SVnode *pVnode = pSma->pVnode; if (!VND_IS_RSMA(pVnode)) { smaTrace("vgId:%d, not create rsma for stable %s %" PRIi64 " since vnd is not rsma", TD_VID(pVnode), pReq->name, @@ -412,11 +400,9 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) { return TSDB_CODE_SUCCESS; } - - smaDebug("vgId:%d, drop rsma for table %" PRIi64 " succeed", TD_VID(pVnode), pReq->suid); return TSDB_CODE_SUCCESS; - } +} /** * @brief store suid/[uids], prefer to use array and then hash diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index aa84500fdc..0f44ac48a4 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -39,7 +39,7 @@ static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capac static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName); -static bool processBlockWithProbability(const SSampleExecInfo* pInfo); +static bool processBlockWithProbability(const SSampleExecInfo* pInfo); bool processBlockWithProbability(const SSampleExecInfo* pInfo) { #if 0 @@ -1178,10 +1178,9 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) { SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j); if (pResCol->info.colId == pColMatchInfo->colId) { - SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId); colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info); -// taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol); + // taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol); colExists = true; break; } @@ -1201,14 +1200,14 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { - blockDataFreeRes((SSDataBlock*) pBlock); + blockDataFreeRes((SSDataBlock*)pBlock); longjmp(pTaskInfo->env, code); } } doFilter(pInfo->pCondition, pInfo->pRes); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); - blockDataFreeRes((SSDataBlock*) pBlock); + blockDataFreeRes((SSDataBlock*)pBlock); return 0; } @@ -1444,7 +1443,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNo static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) { SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param; -#if 0 +#if 1 if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) { STableScanInfo* pTableScanInfo = pStreamScan->pTableScanOp->info; destroyTableScanOperatorInfo(pTableScanInfo, 1); @@ -1456,6 +1455,7 @@ static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) { if (pStreamScan->pColMatchInfo) { taosArrayDestroy(pStreamScan->pColMatchInfo); } + updateInfoDestroy(pStreamScan->pUpdateInfo); blockDataDestroy(pStreamScan->pRes); blockDataDestroy(pStreamScan->pUpdateRes); blockDataDestroy(pStreamScan->pPullDataRes); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 22c09de64f..acc56af5cd 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1537,7 +1537,6 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { for (int32_t i = 0; i < size; i++) { SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, i); destroyStreamFinalIntervalOperatorInfo(pChildOp->info, numOfOutput); - /*taosMemoryFreeClear(pChildOp->info);*/ taosMemoryFreeClear(pChildOp); } } From 41b259508613d9b7c71fd4d841ae51e18203c680 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 14 Jul 2022 17:36:46 +0800 Subject: [PATCH 65/65] fix(sma): fix case --- source/dnode/vnode/src/sma/smaEnv.c | 2 +- tests/script/tsim/sma/tsmaCreateInsertQuery.sim | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index e75d3b4e5d..4a7d4db874 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -255,7 +255,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { // step 2: destroy the rsma info and associated fetch tasks // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. -#if 0 +#if 1 if (taosHashGetSize(RSMA_INFO_HASH(pStat)) > 0) { void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL); while (infoHash) { diff --git a/tests/script/tsim/sma/tsmaCreateInsertQuery.sim b/tests/script/tsim/sma/tsmaCreateInsertQuery.sim index 6cca47423a..868207c80b 100644 --- a/tests/script/tsim/sma/tsmaCreateInsertQuery.sim +++ b/tests/script/tsim/sma/tsmaCreateInsertQuery.sim @@ -41,7 +41,8 @@ print =============== show streams ================================ sql show streams; print $data00 $data01 $data02 -if $data00 != d1 then +if $data00 != sma_index_name1 then + print $data00 return -1 endi