diff --git a/.gitignore b/.gitignore index 47eae4dc03e979cdfc23c71b98a44ee0c6b03812..67cc2929b45049b7bb7ccf377b02bdaad70c3315 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,27 @@ pysim/ # Doxygen Generated files html/ +/.vs +/CMakeFiles/3.10.2 +/CMakeCache.txt +/Makefile +/*.cmake +/deps +/src/cq/test/CMakeFiles/cqtest.dir/*.cmake +*.cmake +/src/cq/test/CMakeFiles/cqtest.dir/*.make +*.make +link.txt +*.internal +*.includecache +*.marks +Makefile +CMakeError.log +*.log +/CMakeFiles/CMakeRuleHashes.txt +/CMakeFiles/Makefile2 +/CMakeFiles/TargetDirectories.txt +/CMakeFiles/cmake.check_cache +/out/isenseconfig/WSL-Clang-Debug +/out/isenseconfig/WSL-GCC-Debug +/test/cfg diff --git a/.travis.yml b/.travis.yml index 9bc576dcf9de328032037162f0c882e7ccbf4057..877e717eafc9a386d6a77d788a34d4089a4488ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: - python3-pip - python3-setuptools - valgrind + - psmisc before_script: - cd ${TRAVIS_BUILD_DIR} @@ -89,6 +90,7 @@ matrix: esac - os: linux + dist: bionic language: c compiler: gcc env: COVERITY_SCAN=true @@ -124,6 +126,7 @@ matrix: branch_pattern: coverity_scan - os: linux + dist: bionic language: c compiler: gcc env: ENV_COVER=true @@ -142,6 +145,7 @@ matrix: - python3-pip - python3-setuptools - lcov + - psmisc before_script: - cd ${TRAVIS_BUILD_DIR} @@ -228,6 +232,7 @@ matrix: - make > /dev/null - os: linux + dist: bionic language: c compiler: clang env: DESC="linux/clang build" diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..4b54f10f2f69fe2fa62e59003d58a4ef9c53a41b --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,25 @@ +{ + "configurations": [ + { + "name": "WSL-GCC-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\build\\", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "/mnt/d/TDengine/TDengine/build", + "type": "PATH" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/client/inc/tscSecondaryMerge.h b/src/client/inc/tscSecondaryMerge.h index ad743eeea3d6a895728e98a9a3af1f23d46cf223..3b0e47f216dbe656600001da58a21ec9eee922f2 100644 --- a/src/client/inc/tscSecondaryMerge.h +++ b/src/client/inc/tscSecondaryMerge.h @@ -21,7 +21,7 @@ extern "C" { #endif #include "qextbuffer.h" -#include "qinterpolation.h" +#include "qfill.h" #include "taosmsg.h" #include "tlosertree.h" #include "tsclient.h" @@ -60,7 +60,7 @@ typedef struct SLocalReducer { char * prevRowOfInput; tFilePage * pResultBuf; int32_t nResultBufSize; - char * pBufForInterpo; // intermediate buffer for interpolation +// char * pBufForInterpo; // intermediate buffer for interpolation tFilePage * pTempBuffer; struct SQLFunctionCtx *pCtx; int32_t rowSize; // size of each intermediate result. @@ -68,9 +68,9 @@ typedef struct SLocalReducer { bool hasPrevRow; // cannot be released bool hasUnprocessedRow; tOrderDescriptor * pDesc; - SColumnModel * resColModel; + SColumnModel * resColModel; tExtMemBuffer ** pExtMemBuffer; // disk-based buffer - SInterpolationInfo interpolationInfo; // interpolation support structure + SFillInfo* pFillInfo; // interpolation support structure char * pFinalRes; // result data after interpo tFilePage * discardData; SResultInfo * pResInfo; diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index e6a37a274551cde9e1f24a90f57b47c281f33d3e..7cfa923f9eacd154ba3f2ec20c6433f3b3524cf4 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -30,10 +30,10 @@ extern "C" { #include "tsqlfunction.h" #include "tutil.h" +#include "qExecutor.h" #include "qsqlparser.h" #include "qsqltype.h" #include "qtsbuf.h" -#include "queryExecutor.h" // forward declaration struct SSqlInfo; @@ -210,7 +210,7 @@ typedef struct SQueryInfo { SLimitVal slimit; STagCond tagCond; SOrderVal order; - int16_t interpoType; // interpolate type + int16_t fillType; // interpolate type int16_t numOfTables; STableMetaInfo **pTableMetaInfo; struct STSBuf * tsBuf; @@ -226,11 +226,8 @@ typedef struct { int command; uint8_t msgType; - union { - bool existsCheck; // check if the table exists or not - bool autoCreated; // if the table is missing, on-the-fly create it. during getmeterMeta - int8_t dataSourceType; // load data from file or not - }; + bool autoCreated; // if the table is missing, on-the-fly create it. during getmeterMeta + int8_t dataSourceType; // load data from file or not union { int32_t count; @@ -263,7 +260,7 @@ typedef struct SResRec { typedef struct { int64_t numOfRows; // num of results in current retrieved int64_t numOfTotal; // num of total results - int64_t numOfTotalInCurrentClause; // num of total result in current subclause + int64_t numOfClauseTotal; // num of total result in current subclause char * pRsp; int32_t rspType; int32_t rspLen; diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 82b0f852ab5b9d615051c2b2589ab4efda8af1a5..26de2a51a84d8a94bebc4a69c4a2260eb3353692 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -147,7 +147,7 @@ static void tscAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows) { // local merge has handle this situation during super table non-projection query. if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE) { - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfClauseTotal += pRes->numOfRows; } (*pSql->fetchFp)(param, tres, numOfRows); diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index c6e8499426450cbb2046d69efb2876a85bdf9937..f3e24e43a9e2a27a30cec01fd2d5bcce75ce63b0 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -16,8 +16,8 @@ #include "os.h" #include "qast.h" #include "qextbuffer.h" +#include "qfill.h" #include "qhistogram.h" -#include "qinterpolation.h" #include "qpercentile.h" #include "qsyntaxtreefunction.h" #include "qtsbuf.h" @@ -3418,6 +3418,7 @@ static void spread_function(SQLFunctionCtx *pCtx) { int32_t numOfElems = pCtx->size; + // todo : opt with pre-calculated result // column missing cause the hasNull to be true if (usePreVal(pCtx)) { numOfElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; @@ -3446,13 +3447,13 @@ static void spread_function(SQLFunctionCtx *pCtx) { } } } else { - if (pInfo->min > pCtx->param[1].dKey) { - pInfo->min = pCtx->param[1].dKey; - } - - if (pInfo->max < pCtx->param[2].dKey) { - pInfo->max = pCtx->param[2].dKey; - } +// if (pInfo->min > pCtx->param[1].dKey) { +// pInfo->min = pCtx->param[1].dKey; +// } +// +// if (pInfo->max < pCtx->param[2].dKey) { +// pInfo->max = pCtx->param[2].dKey; +// } } void *pData = GET_INPUT_CHAR(pCtx); @@ -3866,16 +3867,16 @@ static void interp_function(SQLFunctionCtx *pCtx) { SInterpInfoDetail *pInfoDetail = interpInfo.pInterpDetail; /* set no output result */ - if (pInfoDetail->type == TSDB_INTERPO_NONE) { + if (pInfoDetail->type == TSDB_FILL_NONE) { pCtx->param[3].i64Key = 0; } else if (pInfoDetail->primaryCol == 1) { *(TSKEY *)pCtx->aOutputBuf = pInfoDetail->ts; } else { - if (pInfoDetail->type == TSDB_INTERPO_NULL) { + if (pInfoDetail->type == TSDB_FILL_NULL) { setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); - } else if (pInfoDetail->type == TSDB_INTERPO_SET_VALUE) { + } else if (pInfoDetail->type == TSDB_FILL_SET_VALUE) { tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType); - } else if (pInfoDetail->type == TSDB_INTERPO_PREV) { + } else if (pInfoDetail->type == TSDB_FILL_PREV) { char *data = pCtx->param[1].pz; char *pVal = data + TSDB_KEYSIZE; @@ -3886,7 +3887,7 @@ static void interp_function(SQLFunctionCtx *pCtx) { assignVal(pCtx->aOutputBuf, pVal, pCtx->outputBytes, pCtx->outputType); } - } else if (pInfoDetail->type == TSDB_INTERPO_LINEAR) { + } else if (pInfoDetail->type == TSDB_FILL_LINEAR) { char *data1 = pCtx->param[1].pz; char *data2 = pCtx->param[2].pz; diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 2da786d1d8f3a5ff8e4947c92afd340d2b6d55df..79fa1e28ccb4bdea9f82171e25579f7581fd60b2 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -56,7 +56,7 @@ static int32_t getToStringLength(const char *pData, int32_t length, int32_t type } break; case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_BIGINT: - len = sprintf(buf, "%" PRId64 "", *(int64_t *)pData); + len = sprintf(buf, "%" PRId64, *(int64_t *)pData); break; case TSDB_DATA_TYPE_BOOL: len = MAX_BOOL_TYPE_LENGTH; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 36b1ab59931851c2f2e1fc4a5f9bea89d3b1767a..62f27c0960de80f5dc025ed7f4df358491c8ff42 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -42,35 +42,35 @@ enum { static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows); static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) { - int32_t numType = isValidNumber(pToken); - if (TK_ILLEGAL == numType) { - return numType; - } +// int32_t numType = isValidNumber(pToken); +// if (TK_ILLEGAL == numType) { +// return numType; +// } int32_t radix = 10; - if (numType == TK_HEX) { + if (pToken->type == TK_HEX) { radix = 16; - } else if (numType == TK_OCT) { + } else if (pToken->type == TK_OCT) { radix = 8; - } else if (numType == TK_BIN) { + } else if (pToken->type == TK_BIN) { radix = 2; } errno = 0; *value = strtoll(pToken->z, endPtr, radix); - return numType; + return pToken->type; } static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) { - int32_t numType = isValidNumber(pToken); - if (TK_ILLEGAL == numType) { - return numType; - } +// int32_t numType = isValidNumber(pToken); +// if (TK_ILLEGAL == numType) { +// return numType; +// } errno = 0; *value = strtod(pToken->z, endPtr); - return numType; + return pToken->type; } int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) { @@ -927,6 +927,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { } } + // 3. calculate the actual data size of STagData + pCmd->payloadLen = sizeof(pTag->name) + sizeof(pTag->dataLen); + for (int32_t t = 0; t < numOfTags; ++t) { + pTag->dataLen += pTagSchema[t].bytes; + pCmd->payloadLen += pTagSchema[t].bytes; + } + pTag->dataLen = htonl(pTag->dataLen); + if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { return tscInvalidSQLErrMsg(pCmd->payload, "invalid table name", *sqlstr); } @@ -948,7 +956,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { } else { sql = sToken.z; } - code = tscGetTableMeta(pSql, pTableMetaInfo); + code = tscGetMeterMetaEx(pSql, pTableMetaInfo, false); if (pCmd->curSql == NULL) { assert(code == TSDB_CODE_ACTION_IN_PROGRESS); diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 2caa4ad4368ae5da637a93ab09881f26b84c5c95..5aaa53c549c06d1937c7a49bb2794838433790fc 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -447,7 +447,7 @@ static int insertStmtExecute(STscStmt* stmt) { SSqlRes *pRes = &pSql->res; pRes->numOfRows = 0; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pRes->qhandle = 0; diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 61fc1a19c8178459fb30d0cb7effe56db21c8e2b..74294d38e009a6b0c28991e00e032b7be3aba8ab 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -23,8 +23,6 @@ void tscSaveSlowQueryFp(void *handle, void *tmrId); void *tscSlowQueryConn = NULL; bool tscSlowQueryConnInitialized = false; -TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), - void *param, void **taos); void tscInitConnCb(void *param, TAOS_RES *result, int code) { char *sql = param; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 551b0a045742a56bbd879af555185c782a524c76..a134410bc44b92e0eaa7e92c5aefe30d4c484e5d 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4020,19 +4020,19 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { } if (strncasecmp(pItem->pVar.pz, "none", 4) == 0 && pItem->pVar.nLen == 4) { - pQueryInfo->interpoType = TSDB_INTERPO_NONE; + pQueryInfo->fillType = TSDB_FILL_NONE; } else if (strncasecmp(pItem->pVar.pz, "null", 4) == 0 && pItem->pVar.nLen == 4) { - pQueryInfo->interpoType = TSDB_INTERPO_NULL; + pQueryInfo->fillType = TSDB_FILL_NULL; for (int32_t i = START_INTERPO_COL_IDX; i < size; ++i) { TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); setNull((char*)&pQueryInfo->defaultVal[i], pFields->type, pFields->bytes); } } else if (strncasecmp(pItem->pVar.pz, "prev", 4) == 0 && pItem->pVar.nLen == 4) { - pQueryInfo->interpoType = TSDB_INTERPO_PREV; + pQueryInfo->fillType = TSDB_FILL_PREV; } else if (strncasecmp(pItem->pVar.pz, "linear", 6) == 0 && pItem->pVar.nLen == 6) { - pQueryInfo->interpoType = TSDB_INTERPO_LINEAR; + pQueryInfo->fillType = TSDB_FILL_LINEAR; } else if (strncasecmp(pItem->pVar.pz, "value", 5) == 0 && pItem->pVar.nLen == 5) { - pQueryInfo->interpoType = TSDB_INTERPO_SET_VALUE; + pQueryInfo->fillType = TSDB_FILL_SET_VALUE; if (pFillToken->nExpr == 1) { return invalidSqlErrMsg(pQueryInfo->msg, msg1); @@ -4416,6 +4416,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(pQueryInfo->msg, msg13); } + pAlterSQL->tagData.dataLen = pTagsSchema->bytes; // validate the length of binary if ((pTagsSchema->type == TSDB_DATA_TYPE_BINARY || pTagsSchema->type == TSDB_DATA_TYPE_NCHAR) && @@ -4539,11 +4540,13 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { return TSDB_CODE_INVALID_SQL; } - const SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[14] = { - {"resetLog", 8}, {"resetQueryCache", 15}, {"dDebugFlag", 10}, {"rpcDebugFlag", 12}, - {"tmrDebugFlag", 12}, {"cDebugFlag", 10}, {"uDebugFlag", 10}, {"mDebugFlag", 10}, - {"sdbDebugFlag", 12}, {"httpDebugFlag", 13}, {"monitorDebugFlag", 16}, {"qDebugflag", 10}, - {"debugFlag", 9}, {"monitor", 7}}; + const int DNODE_DYNAMIC_CFG_OPTIONS_SIZE = 17; + const SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[] = { + {"resetLog", 8}, {"resetQueryCache", 15}, {"debugFlag", 9}, {"mDebugFlag", 10}, + {"dDebugFlag", 10}, {"sdbDebugFlag", 12}, {"vDebugFlag", 10}, {"cDebugFlag", 10}, + {"httpDebugFlag", 13}, {"monitorDebugFlag", 16}, {"rpcDebugFlag", 12}, {"uDebugFlag", 10}, + {"tmrDebugFlag", 12}, {"qDebugflag", 10}, {"sDebugflag", 10}, {"tsdbDebugFlag", 13}, + {"monitor", 7}}; SSQLToken* pOptionToken = &pOptions->a[1]; @@ -4555,8 +4558,8 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { return TSDB_CODE_SUCCESS; } } - } else if ((strncasecmp(DNODE_DYNAMIC_CFG_OPTIONS[13].name, pOptionToken->z, pOptionToken->n) == 0) && - (DNODE_DYNAMIC_CFG_OPTIONS[13].len == pOptionToken->n)) { + } else if ((strncasecmp(DNODE_DYNAMIC_CFG_OPTIONS[DNODE_DYNAMIC_CFG_OPTIONS_SIZE - 1].name, pOptionToken->z, pOptionToken->n) == 0) && + (DNODE_DYNAMIC_CFG_OPTIONS[DNODE_DYNAMIC_CFG_OPTIONS_SIZE - 1].len == pOptionToken->n)) { SSQLToken* pValToken = &pOptions->a[2]; int32_t val = strtol(pValToken->z, NULL, 10); if (val != 0 && val != 1) { @@ -4572,7 +4575,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { return TSDB_CODE_INVALID_SQL; } - for (int32_t i = 2; i < tListLen(DNODE_DYNAMIC_CFG_OPTIONS) - 1; ++i) { + for (int32_t i = 2; i < DNODE_DYNAMIC_CFG_OPTIONS_SIZE - 1; ++i) { const SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i]; if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) { @@ -4823,7 +4826,7 @@ static int32_t setTimePrecision(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCreateDBIn static void setCreateDBOption(SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) { pMsg->maxTables = htonl(pCreateDb->maxTablesPerVnode); pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize); - pMsg->numOfBlocks = htonl(pCreateDb->numOfBlocks); + pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); pMsg->daysPerFile = htonl(pCreateDb->daysPerFile); pMsg->commitTime = htonl(pCreateDb->commitTime); pMsg->minRowsPerFileBlock = htonl(pCreateDb->minRowsPerBlock); @@ -5550,11 +5553,11 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { // too long tag values will return invalid sql, not be truncated automatically SSchema* pTagSchema = tscGetTableTagSchema(pStableMeterMetaInfo->pTableMeta); - char* tagVal = pCreateTable->usingInfo.tagdata.data; + STagData* pTag = &pCreateTable->usingInfo.tagdata; + char* tagVal = pTag->data; int32_t ret = TSDB_CODE_SUCCESS; for (int32_t i = 0; i < pList->nExpr; ++i) { - if (pTagSchema[i].type == TSDB_DATA_TYPE_BINARY || pTagSchema[i].type == TSDB_DATA_TYPE_NCHAR) { // validate the length of binary if (pList->a[i].pVar.nLen + VARSTR_HEADER_SIZE > pTagSchema[i].bytes) { @@ -5562,7 +5565,15 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { } ret = tVariantDump(&(pList->a[i].pVar), varDataVal(tagVal), pTagSchema[i].type); - varDataSetLen(tagVal, pList->a[i].pVar.nLen); + if (pList->a[i].pVar.nType == TSDB_DATA_TYPE_NULL) { + if (pTagSchema[i].type == TSDB_DATA_TYPE_BINARY) { + varDataSetLen(tagVal, sizeof(uint8_t)); + } else { + varDataSetLen(tagVal, sizeof(uint32_t)); + } + } else { // todo refactor + varDataSetLen(tagVal, pList->a[i].pVar.nLen); + } } else { ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type); } @@ -5585,6 +5596,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return ret; } + pTag->dataLen = tagVal - pTag->data; return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index a3a0441ff899a4c4cf317b1e9d7d39909069bddf..35658d18674f41085d3ee41bbf5e60cfe2748c95 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -25,7 +25,7 @@ typedef struct SCompareParam { SLocalDataSource **pLocalData; tOrderDescriptor * pDesc; - int32_t numOfElems; + int32_t num; int32_t groupOrderType; } SCompareParam; @@ -47,11 +47,11 @@ int32_t treeComparator(const void *pLeft, const void *pRight, void *param) { } if (pParam->groupOrderType == TSDB_ORDER_DESC) { // desc - return compare_d(pDesc, pParam->numOfElems, pLocalData[pLeftIdx]->rowIdx, pLocalData[pLeftIdx]->filePage.data, - pParam->numOfElems, pLocalData[pRightIdx]->rowIdx, pLocalData[pRightIdx]->filePage.data); + return compare_d(pDesc, pParam->num, pLocalData[pLeftIdx]->rowIdx, pLocalData[pLeftIdx]->filePage.data, + pParam->num, pLocalData[pRightIdx]->rowIdx, pLocalData[pRightIdx]->filePage.data); } else { - return compare_a(pDesc, pParam->numOfElems, pLocalData[pLeftIdx]->rowIdx, pLocalData[pLeftIdx]->filePage.data, - pParam->numOfElems, pLocalData[pRightIdx]->rowIdx, pLocalData[pRightIdx]->filePage.data); + return compare_a(pDesc, pParam->num, pLocalData[pLeftIdx]->rowIdx, pLocalData[pLeftIdx]->filePage.data, + pParam->num, pLocalData[pRightIdx]->rowIdx, pLocalData[pRightIdx]->filePage.data); } } @@ -132,6 +132,26 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc } } +static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { + int32_t numOfCols = tscSqlExprNumOfExprs(pQueryInfo); + int32_t offset = 0; + + SFillColInfo* pFillCol = calloc(numOfCols, sizeof(SFillColInfo)); + for(int32_t i = 0; i < numOfCols; ++i) { + SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); + + pFillCol[i].col.bytes = pExpr->resBytes; + pFillCol[i].col.type = pExpr->resType; + pFillCol[i].flag = pExpr->colInfo.flag; + pFillCol[i].col.offset = offset; + pFillCol[i].functionId = pExpr->functionId; + pFillCol[i].defaultVal.i = pQueryInfo->defaultVal[i]; + offset += pExpr->resBytes; + } + + return pFillCol; +} + void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc, SColumnModel *finalmodel, SSqlObj* pSql) { SSqlCmd* pCmd = &pSql->cmd; @@ -217,24 +237,24 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ds->pMemBuffer = pMemBuffer[i]; ds->flushoutIdx = j; - ds->filePage.numOfElems = 0; + ds->filePage.num = 0; ds->pageId = 0; ds->rowIdx = 0; tscTrace("%p load data from disk into memory, orderOfVnode:%d, total:%d", pSql, i + 1, idx + 1); tExtMemBufferLoadData(pMemBuffer[i], &(ds->filePage), j, 0); #ifdef _DEBUG_VIEW - printf("load data page into mem for build loser tree: %" PRIu64 " rows\n", ds->filePage.numOfElems); + printf("load data page into mem for build loser tree: %" PRIu64 " rows\n", ds->filePage.num); SSrcColumnInfo colInfo[256] = {0}; SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); tscGetSrcColumnInfo(colInfo, pQueryInfo); - tColModelDisplayEx(pDesc->pColumnModel, ds->filePage.data, ds->filePage.numOfElems, + tColModelDisplayEx(pDesc->pColumnModel, ds->filePage.data, ds->filePage.num, pMemBuffer[0]->numOfElemsPerPage, colInfo); #endif - if (ds->filePage.numOfElems == 0) { // no data in this flush, the index does not increase + if (ds->filePage.num == 0) { // no data in this flush, the index does not increase tscTrace("%p flush data is empty, ignore %d flush record", pSql, idx); tfree(ds); continue; @@ -254,7 +274,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd SCompareParam *param = malloc(sizeof(SCompareParam)); param->pLocalData = pReducer->pLocalDataSrc; param->pDesc = pReducer->pDesc; - param->numOfElems = pReducer->pLocalDataSrc[0]->pMemBuffer->numOfElemsPerPage; + param->num = pReducer->pLocalDataSrc[0]->pMemBuffer->numOfElemsPerPage; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); param->groupOrderType = pQueryInfo->groupbyExpr.orderType; @@ -295,25 +315,25 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd assert(finalRowLength <= pReducer->rowSize); pReducer->pFinalRes = calloc(1, pReducer->rowSize * pReducer->resColModel->capacity); - pReducer->pBufForInterpo = calloc(1, pReducer->nResultBufSize); +// pReducer->pBufForInterpo = calloc(1, pReducer->nResultBufSize); if (pReducer->pTempBuffer == NULL || pReducer->discardData == NULL || pReducer->pResultBuf == NULL || - pReducer->pBufForInterpo == NULL || pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) { + /*pReducer->pBufForInterpo == NULL || */pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) { tfree(pReducer->pTempBuffer); tfree(pReducer->discardData); tfree(pReducer->pResultBuf); tfree(pReducer->pFinalRes); - tfree(pReducer->pBufForInterpo); +// tfree(pReducer->pBufForInterpo); tfree(pReducer->prevRowOfInput); pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY; return; } - - size = tscSqlExprNumOfExprs(pQueryInfo); - pReducer->pTempBuffer->numOfElems = 0; - pReducer->pResInfo = calloc(size, sizeof(SResultInfo)); + size_t numOfCols = tscSqlExprNumOfExprs(pQueryInfo); + + pReducer->pTempBuffer->num = 0; + pReducer->pResInfo = calloc(numOfCols, sizeof(SResultInfo)); tscCreateResPointerInfo(pRes, pQueryInfo); tscInitSqlContext(pCmd, pReducer, pDesc); @@ -333,55 +353,58 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd pRes->numOfGroups = 0; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);; - int16_t prec = tinfo.precision; - int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey; + TSKEY stime = MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey); int64_t revisedSTime = - taosGetIntervalStartTimestamp(stime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, prec); - - SInterpolationInfo *pInterpoInfo = &pReducer->interpolationInfo; - taosInitInterpoInfo(pInterpoInfo, pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols, - pReducer->rowSize); + taosGetIntervalStartTimestamp(stime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, tinfo.precision); + + if (pQueryInfo->fillType != TSDB_FILL_NONE) { + SFillColInfo* pFillCol = createFillColInfo(pQueryInfo); + pReducer->pFillInfo = taosInitFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols, + 4096, numOfCols, pQueryInfo->slidingTime, pQueryInfo->fillType, pFillCol); + } int32_t startIndex = pQueryInfo->fieldsInfo.numOfOutput - pQueryInfo->groupbyExpr.numOfGroupCols; - if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { - pInterpoInfo->pTags[0] = (char *)pInterpoInfo->pTags + POINTER_BYTES * pQueryInfo->groupbyExpr.numOfGroupCols; + if (pQueryInfo->groupbyExpr.numOfGroupCols > 0 && pReducer->pFillInfo != NULL) { + pReducer->pFillInfo->pTags[0] = (char *)pReducer->pFillInfo->pTags + POINTER_BYTES * pQueryInfo->groupbyExpr.numOfGroupCols; for (int32_t i = 1; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) { SSchema *pSchema = getColumnModelSchema(pReducer->resColModel, startIndex + i - 1); - pInterpoInfo->pTags[i] = pSchema->bytes + pInterpoInfo->pTags[i - 1]; + pReducer->pFillInfo->pTags[i] = pSchema->bytes + pReducer->pFillInfo->pTags[i - 1]; } } else { - assert(pInterpoInfo->pTags == NULL); + if (pReducer->pFillInfo != NULL) { + assert(pReducer->pFillInfo->pTags == NULL); + } } } static int32_t tscFlushTmpBufferImpl(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePage *pPage, int32_t orderType) { - if (pPage->numOfElems == 0) { + if (pPage->num == 0) { return 0; } - assert(pPage->numOfElems <= pDesc->pColumnModel->capacity); + assert(pPage->num <= pDesc->pColumnModel->capacity); // sort before flush to disk, the data must be consecutively put on tFilePage. if (pDesc->orderIdx.numOfCols > 0) { - tColDataQSort(pDesc, pPage->numOfElems, 0, pPage->numOfElems - 1, pPage->data, orderType); + tColDataQSort(pDesc, pPage->num, 0, pPage->num - 1, pPage->data, orderType); } #ifdef _DEBUG_VIEW - printf("%" PRIu64 " rows data flushed to disk after been sorted:\n", pPage->numOfElems); - tColModelDisplay(pDesc->pColumnModel, pPage->data, pPage->numOfElems, pPage->numOfElems); + printf("%" PRIu64 " rows data flushed to disk after been sorted:\n", pPage->num); + tColModelDisplay(pDesc->pColumnModel, pPage->data, pPage->num, pPage->num); #endif // write to cache after being sorted - if (tExtMemBufferPut(pMemoryBuf, pPage->data, pPage->numOfElems) < 0) { + if (tExtMemBufferPut(pMemoryBuf, pPage->data, pPage->num) < 0) { tscError("failed to save data in temporary buffer"); return -1; } - pPage->numOfElems = 0; + pPage->num = 0; return 0; } @@ -402,17 +425,17 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa int32_t numOfRows, int32_t orderType) { SColumnModel *pModel = pDesc->pColumnModel; - if (pPage->numOfElems + numOfRows <= pModel->capacity) { + if (pPage->num + numOfRows <= pModel->capacity) { tColModelAppend(pModel, pPage, data, 0, numOfRows, numOfRows); return 0; } // current buffer is overflow, flush data to extensive buffer - int32_t numOfRemainEntries = pModel->capacity - pPage->numOfElems; + int32_t numOfRemainEntries = pModel->capacity - pPage->num; tColModelAppend(pModel, pPage, data, 0, numOfRemainEntries, numOfRows); // current buffer is full, need to flushed to disk - assert(pPage->numOfElems == pModel->capacity); + assert(pPage->num == pModel->capacity); int32_t ret = tscFlushTmpBuffer(pMemoryBuf, pDesc, pPage, orderType); if (ret != 0) { return -1; @@ -430,12 +453,12 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa tColModelAppend(pModel, pPage, data, numOfRows - remain, numOfWriteElems, numOfRows); - if (pPage->numOfElems == pModel->capacity) { + if (pPage->num == pModel->capacity) { if (tscFlushTmpBuffer(pMemoryBuf, pDesc, pPage, orderType) != TSDB_CODE_SUCCESS) { return -1; } } else { - pPage->numOfElems = numOfWriteElems; + pPage->num = numOfWriteElems; } remain -= numOfWriteElems; @@ -470,7 +493,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { tscTrace("%p waiting for delete procedure, status: %d", pSql, status); } - taosDestoryInterpoInfo(&pLocalReducer->interpolationInfo); + taosDestoryFillInfo(pLocalReducer->pFillInfo); if (pLocalReducer->pCtx != NULL) { for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { @@ -503,8 +526,6 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { tfree(pLocalReducer->pLoserTree); } - tfree(pLocalReducer->pBufForInterpo); - tfree(pLocalReducer->pFinalRes); tfree(pLocalReducer->discardData); @@ -617,7 +638,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * 1); + (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->numOfSubs); if (*pMemBuffer == NULL) { tscError("%p failed to allocate memory", pSql); pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY; @@ -740,7 +761,7 @@ int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *p #if defined(_DEBUG_VIEW) printf("new page load to buffer\n"); tColModelDisplay(pOneInterDataSrc->pMemBuffer->pColumnModel, pOneInterDataSrc->filePage.data, - pOneInterDataSrc->filePage.numOfElems, pOneInterDataSrc->pMemBuffer->pColumnModel->capacity); + pOneInterDataSrc->filePage.num, pOneInterDataSrc->pMemBuffer->pColumnModel->capacity); #endif *needAdjustLoserTree = true; } else { @@ -761,7 +782,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource * * since it's last record in buffer has been chosen to be processed, as the winner of loser-tree */ bool needToAdjust = true; - if (pOneInterDataSrc->filePage.numOfElems <= pOneInterDataSrc->rowIdx) { + if (pOneInterDataSrc->filePage.num <= pOneInterDataSrc->rowIdx) { loadNewDataFromDiskFor(pLocalReducer, pOneInterDataSrc, &needToAdjust); } @@ -787,23 +808,22 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource * } } -void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQueryInfo, - SInterpolationInfo *pInterpoInfo) { +void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) { // discard following dataset in the same group and reset the interpolation information STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - - int16_t prec = tinfo.precision; - int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey; - int64_t revisedSTime = - taosGetIntervalStartTimestamp(stime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, prec); - taosInitInterpoInfo(pInterpoInfo, pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols, - pLocalReducer->rowSize); + if (pFillInfo != NULL) { + int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey; + int64_t revisedSTime = + taosGetIntervalStartTimestamp(stime, pQueryInfo->slidingTime, pQueryInfo->slidingTimeUnit, tinfo.precision); + + taosResetFillInfo(pFillInfo, revisedSTime); + } pLocalReducer->discard = true; - pLocalReducer->discardData->numOfElems = 0; + pLocalReducer->discardData->num = 0; SColumnModel *pModel = pLocalReducer->pDesc->pColumnModel; tColModelAppend(pModel, pLocalReducer->discardData, pLocalReducer->prevRowOfInput, 0, 1, 1); @@ -856,6 +876,7 @@ static void reversedCopyFromInterpolationToDstBuf(SQueryInfo *pQueryInfo, SSqlRe static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneOutput) { SSqlCmd * pCmd = &pSql->cmd; SSqlRes * pRes = &pSql->res; + tFilePage * pFinalDataPage = pLocalReducer->pResultBuf; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); @@ -868,91 +889,65 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo assert(pRes->pLocalReducer == NULL); } - if (pQueryInfo->intervalTime == 0 || pQueryInfo->interpoType == TSDB_INTERPO_NONE) { - // no interval query, no interpolation + if (pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) { + // no interval query, no fill operation pRes->data = pLocalReducer->pFinalRes; - pRes->numOfRows = pFinalDataPage->numOfElems; - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfRows = pFinalDataPage->num; + pRes->numOfClauseTotal += pRes->numOfRows; if (pQueryInfo->limit.offset > 0) { if (pQueryInfo->limit.offset < pRes->numOfRows) { - int32_t prevSize = pFinalDataPage->numOfElems; + int32_t prevSize = pFinalDataPage->num; tColModelErase(pLocalReducer->resColModel, pFinalDataPage, prevSize, 0, pQueryInfo->limit.offset - 1); /* remove the hole in column model */ tColModelCompact(pLocalReducer->resColModel, pFinalDataPage, prevSize); pRes->numOfRows -= pQueryInfo->limit.offset; - pRes->numOfTotalInCurrentClause -= pQueryInfo->limit.offset; + pRes->numOfClauseTotal -= pQueryInfo->limit.offset; pQueryInfo->limit.offset = 0; } else { pQueryInfo->limit.offset -= pRes->numOfRows; pRes->numOfRows = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; } } - if (pQueryInfo->limit.limit >= 0 && pRes->numOfTotalInCurrentClause > pQueryInfo->limit.limit) { + if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { /* impose the limitation of output rows on the final result */ - int32_t prevSize = pFinalDataPage->numOfElems; - int32_t overFlow = pRes->numOfTotalInCurrentClause - pQueryInfo->limit.limit; - - assert(overFlow < pRes->numOfRows); + int32_t prevSize = pFinalDataPage->num; + int32_t overflow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; + assert(overflow < pRes->numOfRows); - pRes->numOfTotalInCurrentClause = pQueryInfo->limit.limit; - pRes->numOfRows -= overFlow; - pFinalDataPage->numOfElems -= overFlow; + pRes->numOfClauseTotal = pQueryInfo->limit.limit; + pRes->numOfRows -= overflow; + pFinalDataPage->num -= overflow; tColModelCompact(pLocalReducer->resColModel, pFinalDataPage, prevSize); /* set remain data to be discarded, and reset the interpolation information */ - savePrevRecordAndSetupInterpoInfo(pLocalReducer, pQueryInfo, &pLocalReducer->interpolationInfo); + savePrevRecordAndSetupInterpoInfo(pLocalReducer, pQueryInfo, pLocalReducer->pFillInfo); } int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList); memcpy(pRes->data, pFinalDataPage->data, pRes->numOfRows * rowSize); - pFinalDataPage->numOfElems = 0; + pFinalDataPage->num = 0; return; } - int64_t *pPrimaryKeys = (int64_t *)pLocalReducer->pBufForInterpo; - - SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo; - - int64_t actualETime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.ekey : pQueryInfo->window.skey; + SFillInfo *pFillInfo = pLocalReducer->pFillInfo; + int64_t actualETime = MAX(pQueryInfo->window.skey, pQueryInfo->window.ekey); tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput); for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->capacity); } - - char ** srcData = (char **)malloc((POINTER_BYTES + sizeof(int32_t)) * pQueryInfo->fieldsInfo.numOfOutput); - int32_t *functions = (int32_t *)((char *)srcData + pQueryInfo->fieldsInfo.numOfOutput * sizeof(void *)); - - for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { - srcData[i] = - pLocalReducer->pBufForInterpo + tscFieldInfoGetOffset(pQueryInfo, i) * pInterpoInfo->numOfRawDataInRows; - functions[i] = tscSqlExprGet(pQueryInfo, i)->functionId; - } - - STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - int8_t precision = tinfo.precision; - while (1) { - int32_t remains = taosNumOfRemainPoints(pInterpoInfo); - TSKEY etime = taosGetRevisedEndKey(actualETime, pQueryInfo->order.order, pQueryInfo->intervalTime, - pQueryInfo->slidingTimeUnit, precision); - int32_t nrows = taosGetNumOfResultWithInterpo(pInterpoInfo, pPrimaryKeys, remains, pQueryInfo->intervalTime, etime, - pLocalReducer->resColModel->capacity); - - int32_t newRows = taosDoInterpoResult(pInterpoInfo, pQueryInfo->interpoType, pResPages, remains, nrows, - pQueryInfo->intervalTime, pPrimaryKeys, pLocalReducer->resColModel, srcData, - pQueryInfo->defaultVal, functions, pLocalReducer->resColModel->capacity); - assert(newRows <= nrows); + int64_t newRows = -1; + taosGenerateDataBlock(pFillInfo, pResPages, &newRows, pLocalReducer->resColModel->capacity); if (pQueryInfo->limit.offset < newRows) { newRows -= pQueryInfo->limit.offset; @@ -967,7 +962,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo pRes->data = pLocalReducer->pFinalRes; pRes->numOfRows = newRows; - pRes->numOfTotalInCurrentClause += newRows; + pRes->numOfClauseTotal += newRows; pQueryInfo->limit.offset = 0; break; @@ -975,16 +970,15 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo pQueryInfo->limit.offset -= newRows; pRes->numOfRows = 0; - int32_t rpoints = taosNumOfRemainPoints(pInterpoInfo); + int32_t rpoints = taosNumOfRemainRows(pFillInfo); if (rpoints <= 0) { - if (!doneOutput) { - /* reduce procedure is not completed, but current results for interpolation are exhausted */ + if (!doneOutput) { // reduce procedure has not completed yet, but current results for fill are exhausted break; } /* all output for current group are completed */ int32_t totalRemainRows = - taosGetNumOfResWithoutLimit(pInterpoInfo, pPrimaryKeys, rpoints, pQueryInfo->intervalTime, actualETime); + taosGetNumOfResultWithFill(pFillInfo, rpoints, pFillInfo->slidingTime, actualETime); if (totalRemainRows <= 0) { break; } @@ -993,17 +987,17 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo } if (pRes->numOfRows > 0) { - if (pQueryInfo->limit.limit >= 0 && pRes->numOfTotalInCurrentClause > pQueryInfo->limit.limit) { - int32_t overFlow = pRes->numOfTotalInCurrentClause - pQueryInfo->limit.limit; - pRes->numOfRows -= overFlow; + if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { + int32_t overflow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; + pRes->numOfRows -= overflow; assert(pRes->numOfRows >= 0); - pRes->numOfTotalInCurrentClause = pQueryInfo->limit.limit; - pFinalDataPage->numOfElems -= overFlow; + pRes->numOfClauseTotal = pQueryInfo->limit.limit; + pFinalDataPage->num -= overflow; /* set remain data to be discarded, and reset the interpolation information */ - savePrevRecordAndSetupInterpoInfo(pLocalReducer, pQueryInfo, pInterpoInfo); + savePrevRecordAndSetupInterpoInfo(pLocalReducer, pQueryInfo, pFillInfo); } if (pQueryInfo->order.order == TSDB_ORDER_ASC) { @@ -1017,18 +1011,17 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo } } - pFinalDataPage->numOfElems = 0; + pFinalDataPage->num = 0; for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { tfree(pResPages[i]); } + tfree(pResPages); - - free(srcData); } static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) { SColumnModel *pColumnModel = pLocalReducer->pDesc->pColumnModel; - assert(pColumnModel->capacity == 1 && tmpBuffer->numOfElems == 1); + assert(pColumnModel->capacity == 1 && tmpBuffer->num == 1); // copy to previous temp buffer for (int32_t i = 0; i < pColumnModel->numOfCols; ++i) { @@ -1038,7 +1031,7 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) memcpy(pLocalReducer->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes); } - tmpBuffer->numOfElems = 0; + tmpBuffer->num = 0; pLocalReducer->hasPrevRow = true; } @@ -1168,7 +1161,7 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) { pLocalReducer->hasPrevRow = false; int32_t numOfRes = (int32_t)getNumOfResultLocal(pQueryInfo, pLocalReducer->pCtx); - pLocalReducer->pResultBuf->numOfElems += numOfRes; + pLocalReducer->pResultBuf->num += numOfRes; fillMultiRowsOfTagsVal(pQueryInfo, numOfRes, pLocalReducer); return numOfRes; @@ -1221,7 +1214,7 @@ static bool saveGroupResultInfo(SSqlObj *pSql) { // pRes->pGroupRec = realloc(pRes->pGroupRec, pRes->numOfGroups*sizeof(SResRec)); // pRes->pGroupRec[pRes->numOfGroups-1].numOfRows = pRes->numOfRows; - // pRes->pGroupRec[pRes->numOfGroups-1].numOfTotalInCurrentClause = pRes->numOfTotalInCurrentClause; + // pRes->pGroupRec[pRes->numOfGroups-1].numOfClauseTotal = pRes->numOfClauseTotal; return false; } @@ -1244,37 +1237,38 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no pRes->code = TSDB_CODE_SUCCESS; /* - * ignore the output of the current group since this group is skipped by user + * Ignore the output of the current group since this group is skipped by user * We set the numOfRows to be 0 and discard the possible remain results. */ if (pQueryInfo->slimit.offset > 0) { pRes->numOfRows = 0; pQueryInfo->slimit.offset -= 1; pLocalReducer->discard = !noMoreCurrentGroupRes; + return false; } tColModelCompact(pModel, pResBuf, pModel->capacity); - memcpy(pLocalReducer->pBufForInterpo, pResBuf->data, pLocalReducer->nResultBufSize); #ifdef _DEBUG_VIEW printf("final result before interpo:\n"); - tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->numOfElems, pResBuf->numOfElems); + assert(0); +// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num); #endif - - SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo; - int32_t startIndex = pQueryInfo->fieldsInfo.numOfOutput - pQueryInfo->groupbyExpr.numOfGroupCols; - - for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) { - int16_t offset = getColumnModelOffset(pModel, startIndex + i); - SSchema *pSchema = getColumnModelSchema(pModel, startIndex + i); - - memcpy(pInterpoInfo->pTags[i], pLocalReducer->pBufForInterpo + offset * pResBuf->numOfElems, pSchema->bytes); + + SFillInfo* pFillInfo = pLocalReducer->pFillInfo; + if (pFillInfo != NULL) { + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); + + TSKEY ekey = taosGetRevisedEndKey(pQueryInfo->window.ekey, pFillInfo->order, pFillInfo->slidingTime, + pQueryInfo->slidingTimeUnit, tinfo.precision); + + taosFillSetStartInfo(pFillInfo, pResBuf->num, ekey); + taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf); } - - taosInterpoSetStartInfo(&pLocalReducer->interpolationInfo, pResBuf->numOfElems, pQueryInfo->interpoType); + doInterpolateResult(pSql, pLocalReducer, noMoreCurrentGroupRes); - return true; } @@ -1290,7 +1284,7 @@ void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) { // static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer *pLocalReducer) { // In handling data in other groups, we need to reset the interpolation information for a new group data pRes->numOfRows = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); @@ -1302,13 +1296,13 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer int8_t precision = tinfo.precision; // for group result interpolation, do not return if not data is generated - if (pQueryInfo->interpoType != TSDB_INTERPO_NONE) { - int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey; + if (pQueryInfo->fillType != TSDB_FILL_NONE) { + TSKEY skey = MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey); int64_t newTime = - taosGetIntervalStartTimestamp(stime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, precision); - - taosInitInterpoInfo(&pLocalReducer->interpolationInfo, pQueryInfo->order.order, newTime, - pQueryInfo->groupbyExpr.numOfGroupCols, pLocalReducer->rowSize); + taosGetIntervalStartTimestamp(skey, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, precision); +// taosResetFillInfo(pLocalReducer->pFillInfo, pQueryInfo->order.order, newTime, +// pQueryInfo->groupbyExpr.numOfGroupCols, 4096, 0, NULL, pLocalReducer->rowSize); + taosResetFillInfo(pLocalReducer->pFillInfo, newTime); } } @@ -1320,26 +1314,26 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - SLocalReducer * pLocalReducer = pRes->pLocalReducer; - SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo; + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); + SLocalReducer *pLocalReducer = pRes->pLocalReducer; + SFillInfo *pFillInfo = pLocalReducer->pFillInfo; STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); int8_t p = tinfo.precision; - if (taosHasRemainsDataForInterpolation(pInterpoInfo)) { - assert(pQueryInfo->interpoType != TSDB_INTERPO_NONE); + if (pFillInfo != NULL && taosNumOfRemainRows(pFillInfo) > 0) { + assert(pQueryInfo->fillType != TSDB_FILL_NONE); tFilePage *pFinalDataBuf = pLocalReducer->pResultBuf; - int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pInterpoInfo->numOfRawDataInRows - 1)); + int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pFillInfo->numOfRows - 1)); - int32_t remain = taosNumOfRemainPoints(pInterpoInfo); - TSKEY ekey = - taosGetRevisedEndKey(etime, pQueryInfo->order.order, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, p); - int32_t rows = taosGetNumOfResultWithInterpo(pInterpoInfo, (TSKEY *)pLocalReducer->pBufForInterpo, remain, - pQueryInfo->intervalTime, ekey, pLocalReducer->resColModel->capacity); + int32_t remain = taosNumOfRemainRows(pFillInfo); + TSKEY ekey = taosGetRevisedEndKey(etime, pQueryInfo->order.order, pQueryInfo->slidingTime, pQueryInfo->slidingTimeUnit, p); + + // the first column must be the timestamp column + int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, ekey, pLocalReducer->resColModel->capacity); if (rows > 0) { // do interpo doInterpolateResult(pSql, pLocalReducer, false); } @@ -1355,7 +1349,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SLocalReducer * pLocalReducer = pRes->pLocalReducer; - SInterpolationInfo *pInterpoInfo = &pLocalReducer->interpolationInfo; + SFillInfo *pFillInfo = pLocalReducer->pFillInfo; bool prevGroupCompleted = (!pLocalReducer->discard) && pLocalReducer->hasUnprocessedRow; @@ -1363,18 +1357,16 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - int8_t precision = tinfo.precision; if ((isAllSourcesCompleted(pLocalReducer) && !pLocalReducer->hasPrevRow) || pLocalReducer->pLocalDataSrc[0] == NULL || prevGroupCompleted) { - // if interpoType == TSDB_INTERPO_NONE, return directly - if (pQueryInfo->interpoType != TSDB_INTERPO_NONE) { + // if fillType == TSDB_FILL_NONE, return directly + if (pQueryInfo->fillType != TSDB_FILL_NONE) { int64_t etime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.ekey : pQueryInfo->window.skey; etime = taosGetRevisedEndKey(etime, pQueryInfo->order.order, pQueryInfo->intervalTime, - pQueryInfo->slidingTimeUnit, precision); - int32_t rows = taosGetNumOfResultWithInterpo(pInterpoInfo, NULL, 0, pQueryInfo->intervalTime, etime, - pLocalReducer->resColModel->capacity); + pQueryInfo->slidingTimeUnit, tinfo.precision); + int32_t rows = taosGetNumOfResultWithFill(pFillInfo, 0, etime, pLocalReducer->resColModel->capacity); if (rows > 0) { // do interpo doInterpolateResult(pSql, pLocalReducer, true); } @@ -1474,7 +1466,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { printf("chosen data in pTree[0] = %d\n", pTree->pNode[0].index); #endif assert((pTree->pNode[0].index < pLocalReducer->numOfBuffer) && (pTree->pNode[0].index >= 0) && - tmpBuffer->numOfElems == 0); + tmpBuffer->num == 0); // chosen from loser tree SLocalDataSource *pOneDataSrc = pLocalReducer->pLocalDataSrc[pTree->pNode[0].index]; @@ -1487,7 +1479,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { SSrcColumnInfo colInfo[256] = {0}; tscGetSrcColumnInfo(colInfo, pQueryInfo); - tColModelDisplayEx(pModel, tmpBuffer->data, tmpBuffer->numOfElems, pModel->capacity, colInfo); + tColModelDisplayEx(pModel, tmpBuffer->data, tmpBuffer->num, pModel->capacity, colInfo); #endif if (pLocalReducer->discard) { @@ -1495,7 +1487,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { /* current record belongs to the same group of previous record, need to discard it */ if (isSameGroup(pCmd, pLocalReducer, pLocalReducer->discardData->data, tmpBuffer)) { - tmpBuffer->numOfElems = 0; + tmpBuffer->num = 0; pOneDataSrc->rowIdx += 1; adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree); @@ -1509,7 +1501,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { continue; } else { pLocalReducer->discard = false; - pLocalReducer->discardData->numOfElems = 0; + pLocalReducer->discardData->num = 0; if (saveGroupResultInfo(pSql)) { pLocalReducer->status = TSC_LOCALREDUCE_READY; @@ -1538,17 +1530,17 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { tFilePage *pResBuf = pLocalReducer->pResultBuf; /* - * if the previous group does NOT generate any result (pResBuf->numOfElems == 0), + * if the previous group does NOT generate any result (pResBuf->num == 0), * continue to process results instead of return results. */ - if ((!sameGroup && pResBuf->numOfElems > 0) || (pResBuf->numOfElems == pLocalReducer->resColModel->capacity)) { + if ((!sameGroup && pResBuf->num > 0) || (pResBuf->num == pLocalReducer->resColModel->capacity)) { // does not belong to the same group bool notSkipped = doGenerateFinalResults(pSql, pLocalReducer, !sameGroup); // this row needs to discard, since it belongs to the group of previous if (pLocalReducer->discard && sameGroup) { pLocalReducer->hasUnprocessedRow = false; - tmpBuffer->numOfElems = 0; + tmpBuffer->num = 0; } else { // current row does not belongs to the previous group, so it is not be handled yet. pLocalReducer->hasUnprocessedRow = true; @@ -1611,7 +1603,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { finalizeRes(pQueryInfo, pLocalReducer); } - if (pLocalReducer->pResultBuf->numOfElems) { + if (pLocalReducer->pResultBuf->num) { doGenerateFinalResults(pSql, pLocalReducer, true); } @@ -1641,6 +1633,6 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1; pRes->pLocalReducer->pResultBuf = (tFilePage *)calloc(1, allocSize); - pRes->pLocalReducer->pResultBuf->numOfElems = numOfRes; + pRes->pLocalReducer->pResultBuf->num = numOfRes; pRes->data = pRes->pLocalReducer->pResultBuf->data; } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 7324363c9d0a9004999883f13b3c8136b6b0ad8e..0aac5daa2eb3e541d35f5dffdf3b21080445853c 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -571,7 +571,6 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char pTableIdInfo->key = htobe64(tscGetSubscriptionProgress(pSql->pSubscription, pTableMeta->uid, dfltKey)); pQueryMsg->numOfTables = htonl(1); // set the number of tables - pMsg += sizeof(STableIdInfo); } else { int32_t index = pTableMetaInfo->vgroupIndex; @@ -601,8 +600,8 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char } } - tscTrace("%p vgId:%d, query on table:%s, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name, - pTableMeta->uid); + tscTrace("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name, + pTableMeta->sid, pTableMeta->uid); return pMsg; } @@ -652,7 +651,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->order = htons(pQueryInfo->order.order); pQueryMsg->orderColId = htons(pQueryInfo->order.orderColId); - pQueryMsg->interpoType = htons(pQueryInfo->interpoType); + pQueryMsg->fillType = htons(pQueryInfo->fillType); pQueryMsg->limit = htobe64(pQueryInfo->limit.limit); pQueryMsg->offset = htobe64(pQueryInfo->limit.offset); pQueryMsg->numOfCols = htons(taosArrayGetSize(pQueryInfo->colList)); @@ -780,7 +779,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } } - if (pQueryInfo->interpoType != TSDB_INTERPO_NONE) { + if (pQueryInfo->fillType != TSDB_FILL_NONE) { for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { *((int64_t *)pMsg) = htobe64(pQueryInfo->defaultVal[i]); pMsg += sizeof(pQueryInfo->defaultVal[0]); @@ -1213,8 +1212,13 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int8_t type = pInfo->pCreateTableInfo->type; if (type == TSQL_CREATE_TABLE_FROM_STABLE) { // create by using super table, tags value - memcpy(pMsg, &pInfo->pCreateTableInfo->usingInfo.tagdata, sizeof(STagData)); - pMsg += sizeof(STagData); + STagData* pTag = &pInfo->pCreateTableInfo->usingInfo.tagdata; + *(int32_t*)pMsg = htonl(pTag->dataLen); + pMsg += sizeof(int32_t); + memcpy(pMsg, pTag->name, sizeof(pTag->name)); + pMsg += sizeof(pTag->name); + memcpy(pMsg, pTag->data, pTag->dataLen); + pMsg += pTag->dataLen; } else { // create (super) table pSchema = (SSchema *)pCreateTableMsg->schema; @@ -1281,9 +1285,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { strcpy(pAlterTableMsg->tableId, pTableMetaInfo->name); pAlterTableMsg->type = htons(pAlterInfo->type); - pAlterTableMsg->numOfCols = tscNumOfFields(pQueryInfo); - memcpy(pAlterTableMsg->tagVal, pAlterInfo->tagData.data, TSDB_MAX_TAGS_LEN); - + pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo)); SSchema *pSchema = pAlterTableMsg->schema; for (int i = 0; i < pAlterTableMsg->numOfCols; ++i) { TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); @@ -1295,6 +1297,9 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } pMsg = (char *)pSchema; + pAlterTableMsg->tagValLen = htonl(pAlterInfo->tagData.dataLen); + memcpy(pMsg, pAlterInfo->tagData.data, pAlterInfo->tagData.dataLen); + pMsg += pAlterInfo->tagData.dataLen; msgLen = pMsg - (char*)pAlterTableMsg; pCmd->payloadLen = msgLen; @@ -1863,6 +1868,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { } free(pTableMeta); + tscTrace("%p recv table meta: %"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->uid, pTableMeta->sid, pTableMetaInfo->name); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index d8ec104a5072cd9331e8dfa088f3cd05f0ed1e6e..14605a571deefbf5543de7ebc57287f6a2eedaac 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -228,7 +228,7 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) { pRes->numOfRows = 1; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pCmd->curSql = NULL; if (NULL != pCmd->pTableList) { @@ -407,7 +407,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { // secondary merge has handle this situation if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE) { - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfClauseTotal += pRes->numOfRows; } SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); @@ -490,8 +490,8 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { pSql->cmd.command = pQueryInfo->command; pCmd->clauseIndex++; - pRes->numOfTotal += pRes->numOfTotalInCurrentClause; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfTotal += pRes->numOfClauseTotal; + pRes->numOfClauseTotal = 0; pRes->rspType = 0; pSql->numOfSubs = 0; @@ -790,7 +790,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { pRes->numOfRows = 1; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; tscTrace("%p Valid SQL: %s pObj:%p", pSql, sql, pObj); @@ -921,7 +921,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { SSqlRes *pRes = &pSql->res; pRes->numOfTotal = 0; // the number of getting table meta from server - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pRes->code = 0; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index a00f856b2a9917a261368ba4f3e29fd09e111894..fd84a2b759799d00d620aaff6a638fbc00de8972 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -165,7 +165,7 @@ static void tscSetTimestampForRes(SSqlStream *pStream, SSqlObj *pSql) { if (timestamp != actualTimestamp) { // reset the timestamp of each agg point by using start time of each interval *((int64_t *)pRes->data) = actualTimestamp; - tscWarn("%p stream:%p, timestamp of points is:%" PRId64 ", reset to %" PRId64 "", pSql, pStream, timestamp, actualTimestamp); + tscWarn("%p stream:%p, timestamp of points is:%" PRId64 ", reset to %" PRId64, pSql, pStream, timestamp, actualTimestamp); } } @@ -208,7 +208,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); if (pStream->numOfRes == 0) { - if (pQueryInfo->interpoType == TSDB_INTERPO_SET_VALUE || pQueryInfo->interpoType == TSDB_INTERPO_NULL) { + if (pQueryInfo->fillType == TSDB_FILL_SET_VALUE || pQueryInfo->fillType == TSDB_FILL_NULL) { SSqlRes *pRes = &pSql->res; /* failed to retrieve any result in this retrieve */ @@ -287,10 +287,10 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) return; } - tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64 "", pStream->pSql, pStream, + tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream, now + timer, timer, delay, pStream->stime, etime); } else { - tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64 "", pStream->pSql, pStream, + tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream, pStream->stime, timer, delay, pStream->stime - pStream->interval, pStream->stime - 1); } @@ -380,7 +380,7 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); if (pQueryInfo->intervalTime < minIntervalTime) { - tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64 "", pSql, pStream, + tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64, pSql, pStream, pQueryInfo->intervalTime, minIntervalTime); pQueryInfo->intervalTime = minIntervalTime; } @@ -397,14 +397,14 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { if (pQueryInfo->slidingTime == -1) { pQueryInfo->slidingTime = pQueryInfo->intervalTime; } else if (pQueryInfo->slidingTime < minSlidingTime) { - tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64 "", pSql, pStream, + tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64, pSql, pStream, pQueryInfo->slidingTime, minSlidingTime); pQueryInfo->slidingTime = minSlidingTime; } if (pQueryInfo->slidingTime > pQueryInfo->intervalTime) { - tscWarn("%p stream:%p, sliding value:%" PRId64 " can not be larger than interval range, reset to:%" PRId64 "", pSql, pStream, + tscWarn("%p stream:%p, sliding value:%" PRId64 " can not be larger than interval range, reset to:%" PRId64, pSql, pStream, pQueryInfo->slidingTime, pQueryInfo->intervalTime); pQueryInfo->slidingTime = pQueryInfo->intervalTime; @@ -433,11 +433,11 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in } else { // timewindow based aggregation stream if (stime == 0) { // no data in meter till now stime = ((int64_t)taosGetTimestamp(pStream->precision) / pStream->interval) * pStream->interval; - tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64 "", pSql, pStream, stime); + tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64, pSql, pStream, stime); } else { int64_t newStime = (stime / pStream->interval) * pStream->interval; if (newStime != stime) { - tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64 "", pSql, pStream, stime, newStime); + tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql, pStream, stime, newStime); stime = newStime; } } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 75363de3a700935b7cbfb90a4263a1a25f9340c5..3a205924bf934ddb3ddf85604f349cbd9431c85c 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -771,7 +771,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) { } SSqlRes* pRes1 = &pParentSql->pSubs[i]->res; - pRes1->numOfTotalInCurrentClause += pRes1->numOfRows; + pRes1->numOfClauseTotal += pRes1->numOfRows; } // data has retrieved to client, build the join results @@ -1390,7 +1390,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO tExtMemBufferClear(trsupport->pExtMemBuffer[subqueryIndex]); // clear local saved number of results - trsupport->localBuffer->numOfElems = 0; + trsupport->localBuffer->num = 0; pthread_mutex_unlock(&trsupport->queryMutex); tscTrace("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSqlObj, pSql, @@ -1457,7 +1457,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0]; // data in from current vnode is stored in cache and disk - uint32_t numOfRowsFromSubquery = trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->numOfElems; + uint32_t numOfRowsFromSubquery = trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num; tscTrace("%p sub:%p all data retrieved from ip:%u,vgId:%d, numOfRows:%d, orderOfSub:%d", pPObj, pSql, pTableMetaInfo->vgroupList->vgroups[0].ipAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId, numOfRowsFromSubquery, idx); @@ -1465,11 +1465,11 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p tColModelCompact(pDesc->pColumnModel, trsupport->localBuffer, pDesc->pColumnModel->capacity); #ifdef _DEBUG_VIEW - printf("%" PRIu64 " rows data flushed to disk:\n", trsupport->localBuffer->numOfElems); + printf("%" PRIu64 " rows data flushed to disk:\n", trsupport->localBuffer->num); SSrcColumnInfo colInfo[256] = {0}; tscGetSrcColumnInfo(colInfo, pQueryInfo); - tColModelDisplayEx(pDesc->pColumnModel, trsupport->localBuffer->data, trsupport->localBuffer->numOfElems, - trsupport->localBuffer->numOfElems, colInfo); + tColModelDisplayEx(pDesc->pColumnModel, trsupport->localBuffer->data, trsupport->localBuffer->num, + trsupport->localBuffer->num, colInfo); #endif if (tsTotalTmpDirGB != 0 && tsAvailTmpDirGB < tsMinimalTmpDirGB) { @@ -1834,7 +1834,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { pRes->tsrow[i] = pRes1->tsrow[pIndex->columnIndex]; } - pRes->numOfTotalInCurrentClause++; + pRes->numOfClauseTotal++; break; } else { // continue retrieve data from vnode if (!tscHashRemainDataInSubqueryResultSet(pSql)) { @@ -1879,9 +1879,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pField) { SSqlRes *pRes = &pSql->res; - if (pRes->tsrow[columnIndex] != NULL && isNull(pRes->tsrow[columnIndex], pField->type)) { - pRes->tsrow[columnIndex] = NULL; - } else if (pField->type == TSDB_DATA_TYPE_NCHAR) { + if (pRes->tsrow[columnIndex] != NULL && pField->type == TSDB_DATA_TYPE_NCHAR) { // convert unicode to native code in a temporary buffer extra one byte for terminated symbol if (pRes->buffer[columnIndex] == NULL) { pRes->buffer[columnIndex] = malloc(pField->bytes + TSDB_NCHAR_SIZE); @@ -1893,7 +1891,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF if (taosUcs4ToMbs(pRes->tsrow[columnIndex], pField->bytes - VARSTR_HEADER_SIZE, pRes->buffer[columnIndex])) { pRes->tsrow[columnIndex] = pRes->buffer[columnIndex]; } else { - tscError("%p charset:%s to %s. val:%ls convert failed.", pSql, DEFAULT_UNICODE_ENCODEC, tsCharset, pRes->tsrow); + tscError("%p charset:%s to %s. val:%ls convert failed.", pSql, DEFAULT_UNICODE_ENCODEC, tsCharset, pRes->tsrow[columnIndex]); pRes->tsrow[columnIndex] = NULL; } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 8570c2b304b3522342ee6a5ee6b53707a4f588f2..296ffe33339eedd0574406551d4d9bf0cfa7792f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -280,7 +280,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) { return; } - pQueryInfo->interpoType = TSDB_INTERPO_NONE; + pQueryInfo->fillType = TSDB_FILL_NONE; tfree(pQueryInfo->defaultVal); } @@ -1779,7 +1779,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond); - if (pQueryInfo->interpoType != TSDB_INTERPO_NONE) { + if (pQueryInfo->fillType != TSDB_FILL_NONE) { pNewQueryInfo->defaultVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); memcpy(pNewQueryInfo->defaultVal, pQueryInfo->defaultVal, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); } @@ -1989,7 +1989,7 @@ int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* s bool tscHasReachLimitation(SQueryInfo* pQueryInfo, SSqlRes* pRes) { assert(pQueryInfo != NULL && pQueryInfo->clauseLimit != 0); - return (pQueryInfo->clauseLimit > 0 && pRes->numOfTotalInCurrentClause >= pQueryInfo->clauseLimit); + return (pQueryInfo->clauseLimit > 0 && pRes->numOfClauseTotal >= pQueryInfo->clauseLimit); } char* tscGetErrorMsgPayload(SSqlCmd* pCmd) { return pCmd->payload; } @@ -2037,7 +2037,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups; while (++pTableMetaInfo->vgroupIndex < totalVgroups) { tscTrace("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql, - pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfTotalInCurrentClause); + pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); /* * update the limit and offset value for the query on the next vnode, @@ -2045,11 +2045,11 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { * * NOTE: * if the pRes->offset is larger than 0, the start returned position has not reached yet. - * Therefore, the pRes->numOfRows, as well as pRes->numOfTotalInCurrentClause, must be 0. + * Therefore, the pRes->numOfRows, as well as pRes->numOfClauseTotal, must be 0. * The pRes->offset value will be updated by virtual node, during query execution. */ if (pQueryInfo->clauseLimit >= 0) { - pQueryInfo->limit.limit = pQueryInfo->clauseLimit - pRes->numOfTotalInCurrentClause; + pQueryInfo->limit.limit = pQueryInfo->clauseLimit - pRes->numOfClauseTotal; } pQueryInfo->limit.offset = pRes->offset; @@ -2092,7 +2092,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) { pSql->cmd.command = pQueryInfo->command; //backup the total number of result first - int64_t num = pRes->numOfTotal + pRes->numOfTotalInCurrentClause; + int64_t num = pRes->numOfTotal + pRes->numOfClauseTotal; tscFreeSqlResult(pSql); pRes->numOfTotal = num; @@ -2126,16 +2126,26 @@ void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t column int32_t realLen = varDataLen(pData); assert(realLen <= bytes - VARSTR_HEADER_SIZE); + if (isNull(pData, type)) { + pRes->tsrow[columnIndex] = NULL; + } else { + pRes->tsrow[columnIndex] = pData + VARSTR_HEADER_SIZE; + } + if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor *(char*) (pData + realLen + VARSTR_HEADER_SIZE) = 0; } - pRes->tsrow[columnIndex] = pData + VARSTR_HEADER_SIZE; pRes->length[columnIndex] = realLen; } else { assert(bytes == tDataTypeDesc[type].nSize); - pRes->tsrow[columnIndex] = pData; + if (isNull(pData, type)) { + pRes->tsrow[columnIndex] = NULL; + } else { + pRes->tsrow[columnIndex] = pData; + } + pRes->length[columnIndex] = bytes; } } diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 51a5dad4869f3d464d83397157d9fda4482dc6a9..956121086ca5f8fc13c716428156d2754f9fb12b 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -106,9 +106,28 @@ typedef void *SDataRow; SDataRow tdNewDataRowFromSchema(STSchema *pSchema); void tdFreeDataRow(SDataRow row); void tdInitDataRow(SDataRow row, STSchema *pSchema); -int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset); SDataRow tdDataRowDup(SDataRow row); +static FORCE_INLINE int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset) { + ASSERT(value != NULL); + int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE; + char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row)); + + switch (type) { + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row); + memcpy(ptr, value, varDataTLen(value)); + dataRowLen(row) += varDataTLen(value); + break; + default: + memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]); + break; + } + + return 0; +} + // NOTE: offset here including the header size static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t offset) { switch (type) { diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index da8f3cd1e1971518d744cbe69ac05b187a6aa412..319772b60652d6e567e9aa70d06cbffb8167b218 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -103,6 +103,7 @@ extern int32_t tsOfflineThreshold; extern int32_t tsMgmtEqualVnodeNum; extern int32_t tsEnableHttpModule; +extern int32_t tsEnableMqttModule; extern int32_t tsEnableMonitorModule; extern int32_t tsRestRowLimit; @@ -147,6 +148,7 @@ extern int32_t jniDebugFlag; extern int32_t tmrDebugFlag; extern int32_t sdbDebugFlag; extern int32_t httpDebugFlag; +extern int32_t mqttDebugFlag; extern int32_t monitorDebugFlag; extern int32_t uDebugFlag; extern int32_t rpcDebugFlag; diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 9d81cd07af47ec20b727fc0a1e945bb289823964..cf1b77d12ce671d3d0f31bc9c4a1c8a535bc6113 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -158,32 +158,6 @@ void tdFreeDataRow(SDataRow row) { if (row) free(row); } -/** - * Append a column value to the data row - * @param type: column type - * @param bytes: column bytes - * @param offset: offset in the data row tuple, not including the data row header - */ -int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset) { - ASSERT(value != NULL); - int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE; - char * ptr = POINTER_SHIFT(row, dataRowLen(row)); - - switch (type) { - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row); - memcpy(ptr, value, varDataTLen(value)); - dataRowLen(row) += varDataTLen(value); - break; - default: - memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]); - break; - } - - return 0; -} - SDataRow tdDataRowDup(SDataRow row) { SDataRow trow = malloc(dataRowLen(row)); if (trow == NULL) return NULL; @@ -453,27 +427,25 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol TSKEY key1 = (*iter1 >= src1->numOfPoints) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1]; TSKEY key2 = (*iter2 >= src2->numOfPoints) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2]; - if (key1 < key2) { + if (key1 <= key2) { for (int i = 0; i < src1->numOfCols; i++) { ASSERT(target->cols[i].type == src1->cols[i].type); - dataColAppendVal(target->cols[i].pData, tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfPoints, + dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfPoints, target->maxPoints); } target->numOfPoints++; (*iter1)++; - } else if (key1 > key2) { + if (key1 == key2) (*iter2)++; + } else { for (int i = 0; i < src2->numOfCols; i++) { ASSERT(target->cols[i].type == src2->cols[i].type); - dataColAppendVal(target->cols[i].pData, tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfPoints, + dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfPoints, target->maxPoints); } target->numOfPoints++; (*iter2)++; - } else { - // TODO: deal with duplicate keys - ASSERT(false); } } } \ No newline at end of file diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 324edb422b653cb9c0734a1af8c405df6377c3f6..250b79febe1886cda66209082121fbc5f1cbb213 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -107,7 +107,6 @@ int32_t tsReplications = TSDB_DEFAULT_REPLICA_NUM; int16_t tsAffectedRowsMod = 0; int32_t tsNumOfMPeers = 3; int32_t tsMaxShellConns = 2000; -int32_t tsMaxTables = 100000; char tsDefaultDB[TSDB_DB_NAME_LEN] = {0}; char tsDefaultUser[64] = "root"; @@ -121,6 +120,7 @@ int32_t tsOfflineThreshold = 86400*100; // seconds 10days int32_t tsMgmtEqualVnodeNum = 4; int32_t tsEnableHttpModule = 1; +int32_t tsEnableMqttModule = 0; // not finished yet, not started it by default int32_t tsEnableMonitorModule = 0; int32_t tsRestRowLimit = 10240; @@ -135,12 +135,14 @@ int32_t cDebugFlag = 135; int32_t jniDebugFlag = 131; int32_t odbcDebugFlag = 131; int32_t httpDebugFlag = 131; +int32_t mqttDebugFlag = 131; int32_t monitorDebugFlag = 131; int32_t qDebugFlag = 131; int32_t rpcDebugFlag = 135; int32_t uDebugFlag = 131; int32_t debugFlag = 131; int32_t sDebugFlag = 135; +int32_t tsdbDebugFlag = 131; // the maximum number of results for projection query on super table that are returned from // one virtual node, to order according to timestamp @@ -212,11 +214,13 @@ void taosSetAllDebugFlag() { jniDebugFlag = debugFlag; odbcDebugFlag = debugFlag; httpDebugFlag = debugFlag; + mqttDebugFlag = debugFlag; monitorDebugFlag = debugFlag; rpcDebugFlag = debugFlag; uDebugFlag = debugFlag; sDebugFlag = debugFlag; - //qDebugFlag = debugFlag; + tsdbDebugFlag = debugFlag; + qDebugFlag = debugFlag; } uPrint("all debug flag are set to %d", debugFlag); } @@ -889,6 +893,17 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + + cfg.option = "mqtt"; + cfg.ptr = &tsEnableMqttModule; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "monitor"; cfg.ptr = &tsEnableMonitorModule; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -1111,6 +1126,17 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "mqttDebugFlag"; + cfg.ptr = &mqttDebugFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; + cfg.minValue = 0; + cfg.maxValue = 255; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + + cfg.option = "monitorDebugFlag"; cfg.ptr = &monitorDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -1131,6 +1157,16 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "tsdbDebugFlag"; + cfg.ptr = &tsdbDebugFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 255; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "tscEnableRecordSql"; cfg.ptr = &tsTscEnableRecordSql; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/common/src/tname.c b/src/common/src/tname.c index 29236ed0ff89a4bb2b803a4d924591ba7a05c291..3566f26abd944d1f170b2569e8058c08c0478807 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -29,6 +29,7 @@ void extractTableName(const char* tableId, char* name) { size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]); strncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN); + name[TSDB_TABLE_NAME_LEN] = 0; } char* extractDBName(const char* tableId, char* name) { diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index a972881a41a054f92ae34608bb1f038a5d52680d..265e63222c784227fdd21f7f37c2717e4f8769c1 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -304,7 +304,7 @@ tDataTypeDescriptor tDataTypeDesc[11] = { {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f}, {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d}, {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, NULL}, - {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, NULL}, + {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, NULL}, }; @@ -402,7 +402,7 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) { *(uint64_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_DOUBLE_NULL; } break; - case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_NCHAR: // todo : without length? for (int32_t i = 0; i < numOfElems; ++i) { *(uint32_t *)(val + i * bytes) = TSDB_DATA_NCHAR_NULL; } diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py index f18920c553aedf6e475c66643e6c336455df77f4..7ea52aa5add052284174354c3993c6b55512de8f 100644 --- a/src/connector/python/linux/python2/taos/cursor.py +++ b/src/connector/python/linux/python2/taos/cursor.py @@ -1,5 +1,7 @@ from .cinterface import CTaosInterface from .error import * +from .constants import FieldType + class TDengineCursor(object): """Database cursor which is used to manage the context of a fetch operation. @@ -19,7 +21,7 @@ class TDengineCursor(object): if the cursor has not had an operation invoked via the .execute*() method yet. .rowcount:This read-only attribute specifies the number of rows that the last - .execute*() produced (for DQL statements like SELECT) or affected + .execute*() produced (for DQL statements like SELECT) or affected """ def __init__(self, connection=None): @@ -32,6 +34,7 @@ class TDengineCursor(object): self._block_rows = -1 self._block_iter = 0 self._affected_rows = 0 + self._logfile = "" if connection is not None: self._connection = connection @@ -44,13 +47,14 @@ class TDengineCursor(object): raise OperationalError("Invalid use of fetch iterator") if self._block_rows <= self._block_iter: - block, self._block_rows = CTaosInterface.fetchBlock(self._result, self._fields) + block, self._block_rows = CTaosInterface.fetchBlock( + self._result, self._fields) if self._block_rows == 0: raise StopIteration self._block = list(map(tuple, zip(*block))) self._block_iter = 0 - data = self._block[self._block_iter] + data = self._block[self._block_iter] self._block_iter += 1 return data @@ -80,12 +84,15 @@ class TDengineCursor(object): """ pass + def log(self, logfile): + self._logfile = logfile + def close(self): """Close the cursor. """ if self._connection is None: return False - + self._connection.clear_result_set() self._reset_result() self._connection = None @@ -101,24 +108,33 @@ class TDengineCursor(object): if not self._connection: # TODO : change the exception raised here raise ProgrammingError("Cursor is not connected") - + self._connection.clear_result_set() self._reset_result() stmt = operation if params is not None: pass - + res = CTaosInterface.query(self._connection._conn, stmt) + + if (self._logfile): + with open(self._logfile, "a") as logfile: + logfile.write("%s;\n" % operation) + if res == 0: if CTaosInterface.fieldsCount(self._connection._conn) == 0: - self._affected_rows += CTaosInterface.affectedRows(self._connection._conn) + self._affected_rows += CTaosInterface.affectedRows( + self._connection._conn) return CTaosInterface.affectedRows(self._connection._conn) else: - self._result, self._fields = CTaosInterface.useResult(self._connection._conn) + self._result, self._fields = CTaosInterface.useResult( + self._connection._conn) return self._handle_result() else: - raise ProgrammingError(CTaosInterface.errStr(self._connection._conn)) + raise ProgrammingError( + CTaosInterface.errStr( + self._connection._conn)) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. @@ -130,6 +146,37 @@ class TDengineCursor(object): """ pass + def istype(self, col, dataType): + if (dataType.upper() == "BOOL"): + if (self._description[col][1] == FieldType.C_BOOL): + return True + if (dataType.upper() == "TINYINT"): + if (self._description[col][1] == FieldType.C_TINYINT): + return True + if (dataType.upper() == "INT"): + if (self._description[col][1] == FieldType.C_INT): + return True + if (dataType.upper() == "BIGINT"): + if (self._description[col][1] == FieldType.C_INT): + return True + if (dataType.upper() == "FLOAT"): + if (self._description[col][1] == FieldType.C_FLOAT): + return True + if (dataType.upper() == "DOUBLE"): + if (self._description[col][1] == FieldType.C_DOUBLE): + return True + if (dataType.upper() == "BINARY"): + if (self._description[col][1] == FieldType.C_BINARY): + return True + if (dataType.upper() == "TIMESTAMP"): + if (self._description[col][1] == FieldType.C_TIMESTAMP): + return True + if (dataType.upper() == "NCHAR"): + if (self._description[col][1] == FieldType.C_NCHAR): + return True + + return False + def fetchmany(self): pass @@ -138,21 +185,21 @@ class TDengineCursor(object): """ if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") - + buffer = [[] for i in range(len(self._fields))] self._rowcount = 0 while True: - block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) - if num_of_fields == 0: break + block, num_of_fields = CTaosInterface.fetchBlock( + self._result, self._fields) + if num_of_fields == 0: + break self._rowcount += num_of_fields for i in range(len(self._fields)): buffer[i].extend(block[i]) self._connection.clear_result_set() - - return list(map(tuple, zip(*buffer))) - + return list(map(tuple, zip(*buffer))) def nextset(self): """ @@ -176,12 +223,13 @@ class TDengineCursor(object): self._block_rows = -1 self._block_iter = 0 self._affected_rows = 0 - + def _handle_result(self): """Handle the return result from query. """ self._description = [] for ele in self._fields: - self._description.append((ele['name'], ele['type'], None, None, None, None, False)) - + self._description.append( + (ele['name'], ele['type'], None, None, None, None, False)) + return self._result diff --git a/src/connector/python/linux/python3/taos/cursor.py b/src/connector/python/linux/python3/taos/cursor.py index dfbb0f2064fbbedc528a6315df0a1c39f610d2d8..dc038a72bab142f128235fe67740f02f98216f8d 100644 --- a/src/connector/python/linux/python3/taos/cursor.py +++ b/src/connector/python/linux/python3/taos/cursor.py @@ -1,8 +1,10 @@ from .cinterface import CTaosInterface from .error import * +from .constants import FieldType # querySeqNum = 0 + class TDengineCursor(object): """Database cursor which is used to manage the context of a fetch operation. @@ -21,7 +23,7 @@ class TDengineCursor(object): if the cursor has not had an operation invoked via the .execute*() method yet. .rowcount:This read-only attribute specifies the number of rows that the last - .execute*() produced (for DQL statements like SELECT) or affected + .execute*() produced (for DQL statements like SELECT) or affected """ def __init__(self, connection=None): @@ -34,6 +36,7 @@ class TDengineCursor(object): self._block_rows = -1 self._block_iter = 0 self._affected_rows = 0 + self._logfile = "" if connection is not None: self._connection = connection @@ -46,13 +49,14 @@ class TDengineCursor(object): raise OperationalError("Invalid use of fetch iterator") if self._block_rows <= self._block_iter: - block, self._block_rows = CTaosInterface.fetchBlock(self._result, self._fields) + block, self._block_rows = CTaosInterface.fetchBlock( + self._result, self._fields) if self._block_rows == 0: raise StopIteration self._block = list(map(tuple, zip(*block))) self._block_iter = 0 - data = self._block[self._block_iter] + data = self._block[self._block_iter] self._block_iter += 1 return data @@ -82,12 +86,15 @@ class TDengineCursor(object): """ pass + def log(self, logfile): + self._logfile = logfile + def close(self): """Close the cursor. """ if self._connection is None: return False - + self._connection.clear_result_set() self._reset_result() self._connection = None @@ -103,14 +110,13 @@ class TDengineCursor(object): if not self._connection: # TODO : change the exception raised here raise ProgrammingError("Cursor is not connected") - + self._connection.clear_result_set() self._reset_result() stmt = operation if params is not None: pass - # global querySeqNum # querySeqNum += 1 @@ -119,15 +125,23 @@ class TDengineCursor(object): res = CTaosInterface.query(self._connection._conn, stmt) # print(" << Query ({}) Exec Done".format(localSeqNum)) + if (self._logfile): + with open(self._logfile, "a") as logfile: + logfile.write("%s;\n" % operation) + if res == 0: if CTaosInterface.fieldsCount(self._connection._conn) == 0: - self._affected_rows += CTaosInterface.affectedRows(self._connection._conn) + self._affected_rows += CTaosInterface.affectedRows( + self._connection._conn) return CTaosInterface.affectedRows(self._connection._conn) else: - self._result, self._fields = CTaosInterface.useResult(self._connection._conn) + self._result, self._fields = CTaosInterface.useResult( + self._connection._conn) return self._handle_result() else: - raise ProgrammingError(CTaosInterface.errStr(self._connection._conn)) + raise ProgrammingError( + CTaosInterface.errStr( + self._connection._conn)) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. @@ -142,26 +156,57 @@ class TDengineCursor(object): def fetchmany(self): pass + def istype(self, col, dataType): + if (dataType.upper() == "BOOL"): + if (self._description[col][1] == FieldType.C_BOOL): + return True + if (dataType.upper() == "TINYINT"): + if (self._description[col][1] == FieldType.C_TINYINT): + return True + if (dataType.upper() == "INT"): + if (self._description[col][1] == FieldType.C_INT): + return True + if (dataType.upper() == "BIGINT"): + if (self._description[col][1] == FieldType.C_INT): + return True + if (dataType.upper() == "FLOAT"): + if (self._description[col][1] == FieldType.C_FLOAT): + return True + if (dataType.upper() == "DOUBLE"): + if (self._description[col][1] == FieldType.C_DOUBLE): + return True + if (dataType.upper() == "BINARY"): + if (self._description[col][1] == FieldType.C_BINARY): + return True + if (dataType.upper() == "TIMESTAMP"): + if (self._description[col][1] == FieldType.C_TIMESTAMP): + return True + if (dataType.upper() == "NCHAR"): + if (self._description[col][1] == FieldType.C_NCHAR): + return True + + return False + def fetchall(self): """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. """ if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") - + buffer = [[] for i in range(len(self._fields))] self._rowcount = 0 while True: - block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) - if num_of_fields == 0: break + block, num_of_fields = CTaosInterface.fetchBlock( + self._result, self._fields) + if num_of_fields == 0: + break self._rowcount += num_of_fields for i in range(len(self._fields)): buffer[i].extend(block[i]) self._connection.clear_result_set() - - return list(map(tuple, zip(*buffer))) - + return list(map(tuple, zip(*buffer))) def nextset(self): """ @@ -185,12 +230,13 @@ class TDengineCursor(object): self._block_rows = -1 self._block_iter = 0 self._affected_rows = 0 - + def _handle_result(self): """Handle the return result from query. """ self._description = [] for ele in self._fields: - self._description.append((ele['name'], ele['type'], None, None, None, None, False)) - + self._description.append( + (ele['name'], ele['type'], None, None, None, None, False)) + return self._result diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index e4f3142b8962ea41f7661968827fa18073860d14..5cc3ce0159ca12e809f92857d71991104e410711 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "taosdef.h" #include "taosmsg.h" #include "tglobal.h" @@ -40,6 +41,7 @@ typedef struct { int num; // number of continuous streams struct SCqObj *pHead; void *dbConn; + int master; pthread_mutex_t mutex; } SCqContext; @@ -58,17 +60,22 @@ typedef struct SCqObj { int cqDebugFlag = 135; static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row); +static void cqCreateStream(SCqContext *pContext, SCqObj *pObj); void *cqOpen(void *ahandle, const SCqCfg *pCfg) { SCqContext *pContext = calloc(sizeof(SCqContext), 1); - if (pContext == NULL) return NULL; + if (pContext == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return NULL; + } strcpy(pContext->user, pCfg->user); strcpy(pContext->pass, pCfg->pass); pContext->vgId = pCfg->vgId; pContext->cqWrite = pCfg->cqWrite; pContext->ahandle = ahandle; + tscEmbedded = 1; pthread_mutex_init(&pContext->mutex, NULL); @@ -79,11 +86,14 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) { void cqClose(void *handle) { SCqContext *pContext = handle; + if (handle == NULL) return; // stop all CQs cqStop(pContext); // free all resources + pthread_mutex_lock(&pContext->mutex); + SCqObj *pObj = pContext->pHead; while (pObj) { SCqObj *pTemp = pObj; @@ -91,6 +101,8 @@ void cqClose(void *handle) { free(pTemp); } + pthread_mutex_unlock(&pContext->mutex); + pthread_mutex_destroy(&pContext->mutex); cTrace("vgId:%d, CQ is closed", pContext->vgId); @@ -99,29 +111,16 @@ void cqClose(void *handle) { void cqStart(void *handle) { SCqContext *pContext = handle; - cTrace("vgId:%d, start all CQs", pContext->vgId); - if (pContext->dbConn) return; + if (pContext->dbConn || pContext->master) return; + cTrace("vgId:%d, start all CQs", pContext->vgId); pthread_mutex_lock(&pContext->mutex); - tscEmbedded = 1; - pContext->dbConn = taos_connect("localhost", pContext->user, pContext->pass, NULL, 0); - if (pContext->dbConn == NULL) { - cError("vgId:%d, failed to connect to TDengine(%s)", pContext->vgId, tstrerror(terrno)); - pthread_mutex_unlock(&pContext->mutex); - return; - } + pContext->master = 1; SCqObj *pObj = pContext->pHead; while (pObj) { - int64_t lastKey = 0; - pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, lastKey, pObj, NULL); - if (pObj->pStream) { - pContext->num++; - cTrace("vgId:%d, id:%d CQ:%s is openned", pContext->vgId, pObj->tid, pObj->sqlStr); - } else { - cError("vgId:%d, id:%d CQ:%s, failed to open", pContext->vgId, pObj->tid, pObj->sqlStr); - } + cqCreateStream(pContext, pObj); pObj = pObj->next; } @@ -131,10 +130,11 @@ void cqStart(void *handle) { void cqStop(void *handle) { SCqContext *pContext = handle; cTrace("vgId:%d, stop all CQs", pContext->vgId); - if (pContext->dbConn == NULL) return; + if (pContext->dbConn == NULL || pContext->master == 0) return; pthread_mutex_lock(&pContext->mutex); + pContext->master = 0; SCqObj *pObj = pContext->pHead; while (pObj) { if (pObj->pStream) { @@ -176,16 +176,7 @@ void *cqCreate(void *handle, int tid, char *sqlStr, SSchema *pSchema, int column if (pContext->pHead) pContext->pHead->prev = pObj; pContext->pHead = pObj; - if (pContext->dbConn) { - int64_t lastKey = 0; - pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, lastKey, pObj, NULL); - if (pObj->pStream) { - pContext->num++; - cTrace("vgId:%d, id:%d CQ:%s is openned", pContext->vgId, pObj->tid, pObj->sqlStr); - } else { - cError("vgId:%d, id:%d CQ:%s, failed to launch", pContext->vgId, pObj->tid, pObj->sqlStr); - } - } + cqCreateStream(pContext, pObj); pthread_mutex_unlock(&pContext->mutex); @@ -218,6 +209,26 @@ void cqDrop(void *handle) { pthread_mutex_lock(&pContext->mutex); } +static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { + + if (pContext->dbConn == NULL) { + pContext->dbConn = taos_connect("localhost", pContext->user, pContext->pass, NULL, 0); + if (pContext->dbConn == NULL) { + cError("vgId:%d, failed to connect to TDengine(%s)", pContext->vgId, tstrerror(terrno)); + } + return; + } + + int64_t lastKey = 0; + pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, lastKey, pObj, NULL); + if (pObj->pStream) { + pContext->num++; + cTrace("vgId:%d, id:%d CQ:%s is openned", pContext->vgId, pObj->tid, pObj->sqlStr); + } else { + cError("vgId:%d, id:%d CQ:%s, failed to open", pContext->vgId, pObj->tid, pObj->sqlStr); + } +} + static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { SCqObj *pObj = (SCqObj *)param; SCqContext *pContext = pObj->pContext; diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index af2dc2d777bb6d294beecf3b3fa2210ab7230571..de6e15e6b9fa8546ad232c16c8ac2c9472806cb4 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -16,7 +16,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) AUX_SOURCE_DIRECTORY(src SRC) ADD_EXECUTABLE(taosd ${SRC}) - TARGET_LINK_LIBRARIES(taosd mnode taos_static monitor http tsdb twal vnode cJson lz4) + TARGET_LINK_LIBRARIES(taosd mnode taos_static monitor http mqtt tsdb twal vnode cJson lz4) IF (TD_ACCOUNT) TARGET_LINK_LIBRARIES(taosd account) diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 2f693c61fbf5df441b57a130f7beab1cc77cd81e..68fe9869899edc42a1f6c251cce9749a800f43f6 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -37,6 +37,7 @@ static SDnodeRunStatus tsDnodeRunStatus = TSDB_DNODE_RUN_STATUS_STOPPED; int32_t dnodeInitSystem() { dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_INITIALIZE); tscEmbedded = 1; + taosBlockSIGPIPE(); taosResolveCRC(); taosInitGlobalCfg(); taosReadGlobalLogCfg(); diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 86193fcebc14b0db0c326f62e298fca5f99b21e2..2f3008c33e52b2c2265fd80d786e1312705468d7 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -20,6 +20,7 @@ #include "trpc.h" #include "mnode.h" #include "http.h" +#include "mqtt.h" #include "monitor.h" #include "dnodeInt.h" #include "dnodeModule.h" @@ -62,6 +63,16 @@ static void dnodeAllocModules() { dnodeSetModuleStatus(TSDB_MOD_HTTP); } + tsModule[TSDB_MOD_MQTT].enable = (tsEnableMqttModule == 1); + tsModule[TSDB_MOD_MQTT].name = "mqtt"; + tsModule[TSDB_MOD_MQTT].initFp = mqttInitSystem; + tsModule[TSDB_MOD_MQTT].cleanUpFp = mqttCleanUpSystem; + tsModule[TSDB_MOD_MQTT].startFp = mqttStartSystem; + tsModule[TSDB_MOD_MQTT].stopFp = mqttStopSystem; + if (tsEnableMqttModule) { + dnodeSetModuleStatus(TSDB_MOD_MQTT); + } + tsModule[TSDB_MOD_MONITOR].enable = (tsEnableMonitorModule == 1); tsModule[TSDB_MOD_MONITOR].name = "monitor"; tsModule[TSDB_MOD_MONITOR].initFp = monitorInitSystem; @@ -114,18 +125,20 @@ void dnodeStartModules() { } void dnodeProcessModuleStatus(uint32_t moduleStatus) { - bool enableMgmtModule = moduleStatus & (1 << TSDB_MOD_MGMT); - if (!tsModule[TSDB_MOD_MGMT].enable && enableMgmtModule) { - dPrint("module status is received, start mgmt module", tsModuleStatus, moduleStatus); - tsModule[TSDB_MOD_MGMT].enable = true; - dnodeSetModuleStatus(TSDB_MOD_MGMT); - (*tsModule[TSDB_MOD_MGMT].startFp)(); - } + for (int32_t module = TSDB_MOD_MGMT; module < TSDB_MOD_HTTP; ++module) { + bool enableModule = moduleStatus & (1 << module); + if (!tsModule[module].enable && enableModule) { + dPrint("module status:%u is received, start %s module", tsModuleStatus, tsModule[module].name); + tsModule[module].enable = true; + dnodeSetModuleStatus(module); + (*tsModule[module].startFp)(); + } - if (tsModule[TSDB_MOD_MGMT].enable && !enableMgmtModule) { - dPrint("module status is received, stop mgmt module", tsModuleStatus, moduleStatus); - tsModule[TSDB_MOD_MGMT].enable = false; - dnodeUnSetModuleStatus(TSDB_MOD_MGMT); - (*tsModule[TSDB_MOD_MGMT].stopFp)(); + if (tsModule[module].enable && !enableModule) { + dPrint("module status:%u is received, stop %s module", tsModuleStatus, tsModule[module].name); + tsModule[module].enable = false; + dnodeUnSetModuleStatus(module); + (*tsModule[module].stopFp)(); + } } } diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 683328db29e4a4e072549d91e5e9cc7da9e6e53d..a7bfc2d7d2224287dec353b7a40b239307d93a74 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -22,6 +22,7 @@ #include "dnodeMain.h" static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context); +static sem_t exitSem; int32_t main(int32_t argc, char *argv[]) { // Set global configuration file @@ -65,6 +66,11 @@ int32_t main(int32_t argc, char *argv[]) { #endif } + if (sem_init(&exitSem, 0, 0) != 0) { + printf("failed to create exit semphore\n"); + exit(EXIT_FAILURE); + } + /* Set termination handler. */ struct sigaction act = {{0}}; act.sa_flags = SA_SIGINFO; @@ -90,9 +96,19 @@ int32_t main(int32_t argc, char *argv[]) { syslog(LOG_INFO, "Started TDengine service successfully."); - while (1) { - sleep(1000); + for (int res = sem_wait(&exitSem); res != 0; res = sem_wait(&exitSem)) { + if (res != EINTR) { + syslog(LOG_ERR, "failed to wait exit semphore: %d", res); + break; + } } + + dnodeCleanUpSystem(); + // close the syslog + syslog(LOG_INFO, "Shut down TDengine service successfully"); + dPrint("TDengine is shut down!"); + closelog(); + return EXIT_SUCCESS; } static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) { @@ -104,14 +120,21 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) { taosCfgDynamicOptions("resetlog"); return; } + syslog(LOG_INFO, "Shut down signal is %d", signum); syslog(LOG_INFO, "Shutting down TDengine service..."); // clean the system. dPrint("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid); - dnodeCleanUpSystem(); - // close the syslog - syslog(LOG_INFO, "Shut down TDengine service successfully"); - dPrint("TDengine is shut down!"); - closelog(); - exit(EXIT_SUCCESS); + + // protect the application from receive another signal + struct sigaction act = {{0}}; + act.sa_handler = SIG_IGN; + sigaction(SIGTERM, &act, NULL); + sigaction(SIGHUP, &act, NULL); + sigaction(SIGINT, &act, NULL); + sigaction(SIGUSR1, &act, NULL); + sigaction(SIGUSR2, &act, NULL); + + // inform main thread to exit + sem_post(&exitSem); } diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index aa8cd997858c7ad27a02d751b00e765fc176d327..22505f2780bd220740b8523bca769ca8cb699a54 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -17,6 +17,7 @@ #include "os.h" #include "taoserror.h" #include "taosmsg.h" +#include "tutil.h" #include "tqueue.h" #include "trpc.h" #include "twal.h" @@ -71,11 +72,16 @@ int32_t dnodeInitRead() { } void dnodeCleanupRead() { + for (int i=0; i < readPool.max; ++i) { + SReadWorker *pWorker = readPool.readWorker + i; + if (pWorker->thread) { + taosQsetThreadResume(readQset); + } + } for (int i=0; i < readPool.max; ++i) { SReadWorker *pWorker = readPool.readWorker + i; if (pWorker->thread) { - pthread_cancel(pWorker->thread); pthread_join(pWorker->thread, NULL); } } @@ -201,15 +207,14 @@ void dnodeSendRpcReadRsp(void *pVnode, SReadMsg *pRead, int32_t code) { } static void *dnodeProcessReadQueue(void *param) { - SReadWorker *pWorker = param; SReadMsg *pReadMsg; int type; void *pVnode; while (1) { if (taosReadQitemFromQset(readQset, &type, (void **)&pReadMsg, &pVnode) == 0) { - dnodeHandleIdleReadWorker(pWorker); - continue; + dTrace("dnodeProcessReadQueee: got no message from qset, exiting..."); + break; } dTrace("%p, msg:%s will be processed", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]); @@ -221,6 +226,8 @@ static void *dnodeProcessReadQueue(void *param) { return NULL; } + +UNUSED_FUNC static void dnodeHandleIdleReadWorker(SReadWorker *pWorker) { int32_t num = taosGetQueueNumber(readQset); diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 879082f223e27537f8f0dbd8a4e6cc53fce5117b..a1531433ef4569634ebc530f87dd7b8b7dd640d9 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -17,6 +17,7 @@ #include "os.h" #include "taosmsg.h" #include "taoserror.h" +#include "tutil.h" #include "tqueue.h" #include "trpc.h" #include "tsdb.h" @@ -67,11 +68,16 @@ int32_t dnodeInitWrite() { } void dnodeCleanupWrite() { + for (int32_t i = 0; i < wWorkerPool.max; ++i) { + SWriteWorker *pWorker = wWorkerPool.writeWorker + i; + if (pWorker->thread) { + taosQsetThreadResume(pWorker->qset); + } + } for (int32_t i = 0; i < wWorkerPool.max; ++i) { SWriteWorker *pWorker = wWorkerPool.writeWorker + i; if (pWorker->thread) { - pthread_cancel(pWorker->thread); pthread_join(pWorker->thread, NULL); taosFreeQall(pWorker->qall); taosCloseQset(pWorker->qset); @@ -186,9 +192,9 @@ static void *dnodeProcessWriteQueue(void *param) { while (1) { numOfMsgs = taosReadAllQitemsFromQset(pWorker->qset, pWorker->qall, &pVnode); - if (numOfMsgs <=0) { - dnodeHandleIdleWorker(pWorker); // thread exit if no queues anymore - continue; + if (numOfMsgs ==0) { + dTrace("dnodeProcessWriteQueee: got no message from qset, exiting..."); + break; } for (int32_t i = 0; i < numOfMsgs; ++i) { @@ -228,6 +234,7 @@ static void *dnodeProcessWriteQueue(void *param) { return NULL; } +UNUSED_FUNC static void dnodeHandleIdleWorker(SWriteWorker *pWorker) { int32_t num = taosGetQueueNumber(pWorker->qset); diff --git a/src/inc/mqtt.h b/src/inc/mqtt.h new file mode 100644 index 0000000000000000000000000000000000000000..710737e79a320989ad1ebf0a669246e8352a4f1d --- /dev/null +++ b/src/inc/mqtt.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_MQTT_H +#define TDENGINE_MQTT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int32_t mqttGetReqCount(); +int32_t mqttInitSystem(); +int32_t mqttStartSystem(); +void mqttStopSystem(); +void mqttCleanUpSystem(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 2393654f796666c481e85fbeff81cd7e92e836a8..6914961463aeddb1a4bbf230495f6389a33c28e4 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -32,7 +32,7 @@ extern "C" { #define TSKEY int64_t #endif -#define TSWINDOW_INITIALIZER {INT64_MIN, INT64_MAX}; +#define TSWINDOW_INITIALIZER ((STimeWindow) {INT64_MIN, INT64_MAX}) #define TSKEY_INITIAL_VAL INT64_MIN // ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR @@ -252,12 +252,12 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta #define TSDB_MIN_CACHE_BLOCK_SIZE 1 -#define TSDB_MAX_CACHE_BLOCK_SIZE 10240 // 10GB for each vnode +#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode #define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 #define TSDB_MIN_TOTAL_BLOCKS 2 #define TSDB_MAX_TOTAL_BLOCKS 10000 -#define TSDB_DEFAULT_TOTAL_BLOCKS 2 +#define TSDB_DEFAULT_TOTAL_BLOCKS 4 #define TSDB_MIN_TABLES 4 #define TSDB_MAX_TABLES 200000 @@ -340,13 +340,14 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_SESSIONS_PER_VNODE (300) #define TSDB_SESSIONS_PER_DNODE (TSDB_SESSIONS_PER_VNODE * TSDB_MAX_VNODES) -#define TSDB_MAX_MNODES 5 -#define TSDB_MAX_DNODES 10 -#define TSDB_MAX_ACCOUNTS 10 -#define TSDB_MAX_USERS 20 -#define TSDB_MAX_DBS 100 -#define TSDB_MAX_VGROUPS 1000 -#define TSDB_MAX_SUPER_TABLES 100 +#define TSDB_DEFAULT_MNODES_HASH_SIZE 5 +#define TSDB_DEFAULT_DNODES_HASH_SIZE 10 +#define TSDB_DEFAULT_ACCOUNTS_HASH_SIZE 10 +#define TSDB_DEFAULT_USERS_HASH_SIZE 20 +#define TSDB_DEFAULT_DBS_HASH_SIZE 100 +#define TSDB_DEFAULT_VGROUPS_HASH_SIZE 100 +#define TSDB_DEFAULT_STABLES_HASH_SIZE 100 +#define TSDB_DEFAULT_CTABLES_HASH_SIZE 10000 #define TSDB_PORT_DNODESHELL 0 #define TSDB_PORT_DNODEDNODE 5 @@ -375,6 +376,7 @@ typedef enum { TSDB_MOD_MGMT, TSDB_MOD_HTTP, TSDB_MOD_MONITOR, + TSDB_MOD_MQTT, TSDB_MOD_MAX } EModuleType; diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 1390d66113ac9bd5f184947dd27ec4ebf4baaac6..ae30efd93eb1bb58ddcf7b94ecf710bb17a3ae91 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -156,6 +156,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 405, "server out of m TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 406, "no disk permissions") TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 407, "file corrupted") TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 408, "memory corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 409, "no such file or directory") // client TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 451, "invalid client version") diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 3aa75523eab5b67b19654712a2fed0854f6cd965..f550b1660fb071a9af04244f66fa628edea2ea79 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -140,19 +140,19 @@ enum _mgmt_table { TSDB_MGMT_TABLE_MAX, }; -#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN 1 -#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN 2 +#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN 1 +#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN 2 #define TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN 3 -#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4 +#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4 -#define TSDB_ALTER_TABLE_ADD_COLUMN 5 -#define TSDB_ALTER_TABLE_DROP_COLUMN 6 +#define TSDB_ALTER_TABLE_ADD_COLUMN 5 +#define TSDB_ALTER_TABLE_DROP_COLUMN 6 -#define TSDB_INTERPO_NONE 0 -#define TSDB_INTERPO_NULL 1 -#define TSDB_INTERPO_SET_VALUE 2 -#define TSDB_INTERPO_LINEAR 3 -#define TSDB_INTERPO_PREV 4 +#define TSDB_FILL_NONE 0 +#define TSDB_FILL_NULL 1 +#define TSDB_FILL_SET_VALUE 2 +#define TSDB_FILL_LINEAR 3 +#define TSDB_FILL_PREV 4 #define TSDB_ALTER_USER_PASSWD 0x1 #define TSDB_ALTER_USER_PRIVILEGES 0x2 @@ -164,8 +164,8 @@ enum _mgmt_table { #define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS) #define TSDB_COL_NORMAL 0x0u -#define TSDB_COL_TAG 0x1u -#define TSDB_COL_JOIN 0x2u +#define TSDB_COL_TAG 0x1u +#define TSDB_COL_JOIN 0x2u extern char *taosMsg[]; @@ -269,9 +269,11 @@ typedef struct { char tableId[TSDB_TABLE_ID_LEN + 1]; char db[TSDB_DB_NAME_LEN + 1]; int16_t type; /* operation type */ - char tagVal[TSDB_MAX_BYTES_PER_ROW]; - int8_t numOfCols; /* number of schema */ + int16_t numOfCols; /* number of schema */ + int32_t tagValLen; SSchema schema[]; + // tagVal is padded after schema + // char tagVal[]; } SCMAlterTableMsg; typedef struct { @@ -440,7 +442,7 @@ typedef struct { uint16_t queryType; // denote another query process int16_t numOfOutput; // final output columns numbers int16_t tagNameRelType; // relation of tag criteria and tbname criteria - int16_t interpoType; // interpolate type + int16_t fillType; // interpolate type uint64_t defaultVal; // default value array list int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed int32_t tsLen; // total length of ts comp block @@ -485,20 +487,20 @@ typedef struct { typedef struct { char acct[TSDB_USER_LEN + 1]; char db[TSDB_DB_NAME_LEN + 1]; - int32_t maxTables; int32_t cacheBlockSize; //MB - int32_t numOfBlocks; + int32_t totalBlocks; + int32_t maxTables; int32_t daysPerFile; + int32_t daysToKeep; int32_t daysToKeep1; int32_t daysToKeep2; - int32_t daysToKeep; - int32_t commitTime; int32_t minRowsPerFileBlock; int32_t maxRowsPerFileBlock; + int32_t commitTime; + uint8_t precision; // time resolution int8_t compression; int8_t walLevel; int8_t replications; - uint8_t precision; // time resolution int8_t ignoreExist; } SCMCreateDbMsg, SCMAlterDbMsg; @@ -563,9 +565,9 @@ typedef struct { typedef struct { uint32_t vgId; int32_t cfgVersion; + int32_t maxTables; int32_t cacheBlockSize; int32_t totalBlocks; - int32_t maxTables; int32_t daysPerFile; int32_t daysToKeep; int32_t daysToKeep1; @@ -647,6 +649,7 @@ typedef struct SMultiTableMeta { } SMultiTableMeta; typedef struct { + int32_t dataLen; char name[TSDB_TABLE_ID_LEN + 1]; char data[TSDB_MAX_TAGS_LEN]; } STagData; @@ -722,6 +725,8 @@ typedef struct { typedef struct { uint32_t queryId; uint32_t streamId; + uint32_t totalDnodes; + uint32_t onlineDnodes; int8_t killConnection; SRpcIpSet ipList; } SCMHeartBeatRsp; diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 729ed17053479ee509f613d01ea3e2b11bcafd73..bee68b81f567bf0259edea33e944a4aa074ccdaa 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -167,12 +167,6 @@ typedef struct { SArray *pGroupList; } STableGroupInfo; -typedef struct { -} SFields; - -#define TSDB_TS_GREATER_EQUAL 1 -#define TSDB_TS_LESS_EQUAL 2 - typedef struct SQueryRowCond { int32_t rel; TSKEY ts; diff --git a/src/inc/tsync.h b/src/inc/tsync.h index 137b97e28797d0d6dbc8654ccfc23f3fa99b7760..fcf26d22c39d5bb6f2742677196409456bc531b7 100644 --- a/src/inc/tsync.h +++ b/src/inc/tsync.h @@ -94,8 +94,8 @@ typedef void* tsync_h; tsync_h syncStart(const SSyncInfo *); void syncStop(tsync_h shandle); -int syncReconfig(tsync_h shandle, const SSyncCfg *); -int syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle); +int32_t syncReconfig(tsync_h shandle, const SSyncCfg *); +int32_t syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype); void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code); void syncRecover(tsync_h shandle); // recover from other nodes: int syncGetNodesRole(tsync_h shandle, SNodesRole *); diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 3cacafa50501cfd0cf677c92327df499bff7a220..04194c6127f2b825735dcc7cf102c0a321f3079b 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -362,6 +362,26 @@ int main(int argc, char *argv[]) { time_t tTime = time(NULL); struct tm tm = *localtime(&tTime); + printf("###################################################################\n"); + printf("# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port); + printf("# User: %s\n", user); + printf("# Password: %s\n", pass); + printf("# Use metric: %s\n", use_metric ? "true" : "false"); + printf("# Datatype of Columns: %s\n", dataString); + printf("# Binary Length(If applicable): %d\n", + (strcasestr(dataString, "BINARY") != NULL) ? len_of_binary : -1); + printf("# Number of Columns per record: %d\n", ncols_per_record); + printf("# Number of Connections: %d\n", nconnections); + printf("# Number of Tables: %d\n", ntables); + printf("# Number of Data per Table: %d\n", nrecords_per_table); + printf("# Records/Request: %d\n", nrecords_per_request); + printf("# Database name: %s\n", db_name); + printf("# Table prefix: %s\n", tb_prefix); + printf("# Test time: %d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + printf("###################################################################\n\n"); + printf("Press enter key to continue"); + getchar(); fprintf(fp, "###################################################################\n"); fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port); @@ -858,15 +878,16 @@ void generateData(char *res, char **data_type, int num_of_cols, int64_t timestam pstr += sprintf(pstr, ")"); } +static const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"; void rand_string(char *str, int size) { - memset(str, 0, size); - const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"; - char *sptr = str; - if (size) { + str[0] = 0; + if (size > 0) { --size; - for (size_t n = 0; n < size; n++) { + int n; + for (n = 0; n < size; n++) { int key = rand() % (int)(sizeof charset - 1); - sptr += sprintf(sptr, "%c", charset[key]); + str[n] = charset[key]; } + str[n] = 0; } } diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index adba0911369731624934cacf9be350c4e1972745..9886a91f48242191a6259a9d15bbc1f3cefc0a81 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -37,6 +37,8 @@ #define COMMAND_SIZE 65536 #define DEFAULT_DUMP_FILE "taosdump.sql" +#define MAX_DBS 100 + int converStringToReadable(char *str, int size, char *buf, int bufsize); int convertNCharToReadable(char *str, int size, char *buf, int bufsize); void taosDumpCharset(FILE *fp); @@ -359,7 +361,7 @@ int main(int argc, char *argv[]) { void taosFreeDbInfos() { if (dbInfos == NULL) return; - for (int i = 0; i < TSDB_MAX_DBS; i++) tfree(dbInfos[i]); + for (int i = 0; i < MAX_DBS; i++) tfree(dbInfos[i]); tfree(dbInfos); } @@ -437,7 +439,7 @@ int taosDumpOut(SDumpArguments *arguments) { return -1; } - dbInfos = (SDbInfo **)calloc(TSDB_MAX_DBS, sizeof(SDbInfo *)); + dbInfos = (SDbInfo **)calloc(MAX_DBS, sizeof(SDbInfo *)); if (dbInfos == NULL) { fprintf(stderr, "failed to allocate memory\n"); goto _exit_failure; @@ -531,7 +533,7 @@ int taosDumpOut(SDumpArguments *arguments) { } } - taos_free_result(result); + // taos_free_result(result); if (count == 0) { fprintf(stderr, "No databases valid to dump\n"); @@ -720,6 +722,57 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols count_temp = counter; for (; counter < numOfCols; counter++) { + TAOS_ROW row = NULL; + + sprintf(command, "select %s from %s limit 1", tableDes->cols[counter].field, tableDes->name); + if (taos_query(taos, command) != 0) { + fprintf(stderr, "failed to run command %s\n", command); + return; + } + + result = taos_use_result(taos); + if (result == NULL) { + fprintf(stderr, "failed to use result\n"); + return; + } + + TAOS_FIELD *fields = taos_fetch_fields(result); + + row = taos_fetch_row(result); + switch (fields[0].type) { + case TSDB_DATA_TYPE_BOOL: + sprintf(tableDes->cols[counter].note, "%d", ((((int)(*((char *)row[0]))) == 1) ? 1 : 0)); + break; + case TSDB_DATA_TYPE_TINYINT: + sprintf(tableDes->cols[counter].note, "%d", (int)(*((char *)row[0]))); + break; + case TSDB_DATA_TYPE_SMALLINT: + sprintf(tableDes->cols[counter].note, "%d", (int)(*((short *)row[0]))); + break; + case TSDB_DATA_TYPE_INT: + sprintf(tableDes->cols[counter].note, "%d", *((int *)row[0])); + break; + case TSDB_DATA_TYPE_BIGINT: + sprintf(tableDes->cols[counter].note, "%" PRId64 "", *((int64_t *)row[0])); + break; + case TSDB_DATA_TYPE_FLOAT: + sprintf(tableDes->cols[counter].note, "%f", GET_FLOAT_VAL(row[0])); + break; + case TSDB_DATA_TYPE_DOUBLE: + sprintf(tableDes->cols[counter].note, "%f", GET_DOUBLE_VAL(row[0])); + break; + case TSDB_DATA_TYPE_TIMESTAMP: + sprintf(tableDes->cols[counter].note, "%" PRId64 "", *(int64_t *)row[0]); + break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + default: + strncpy(tableDes->cols[counter].note, (char *)row[0], fields[0].bytes); + break; + } + + taos_free_result(result); + if (counter != count_temp) { if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 || strcasecmp(tableDes->cols[counter].type, "nchar") == 0) { @@ -941,7 +994,7 @@ int taosDumpTableData(FILE *fp, char *tbname, SDumpArguments *arguments) { pstr += sprintf(pstr, "%d", *((int *)row[col])); break; case TSDB_DATA_TYPE_BIGINT: - pstr += sprintf(pstr, "%" PRId64 "", *((int64_t *)row[col])); + pstr += sprintf(pstr, "%" PRId64, *((int64_t *)row[col])); break; case TSDB_DATA_TYPE_FLOAT: pstr += sprintf(pstr, "%f", GET_FLOAT_VAL(row[col])); @@ -960,7 +1013,7 @@ int taosDumpTableData(FILE *fp, char *tbname, SDumpArguments *arguments) { pstr += sprintf(pstr, "\'%s\'", tbuf); break; case TSDB_DATA_TYPE_TIMESTAMP: - pstr += sprintf(pstr, "%" PRId64 "", *(int64_t *)row[col]); + pstr += sprintf(pstr, "%" PRId64, *(int64_t *)row[col]); break; default: break; diff --git a/src/mnode/inc/mgmtDef.h b/src/mnode/inc/mgmtDef.h index fac342901aaadebaa825a206dba97c3af5be8e62..9d3e46205d1ed21d673db72997164274371b3c64 100644 --- a/src/mnode/inc/mgmtDef.h +++ b/src/mnode/inc/mgmtDef.h @@ -63,10 +63,8 @@ typedef struct SMnodeObj { int8_t updateEnd[1]; int32_t refCount; int8_t role; - SDnodeObj *pDnode; } SMnodeObj; -// todo use dynamic length string typedef struct { char *tableId; int8_t type; diff --git a/src/mnode/inc/mgmtDnode.h b/src/mnode/inc/mgmtDnode.h index c9e062255b017a06e4a53ff65ef7d8f2dcbd7479..14960c5701b358259f695002808b876ce8b39fe4 100644 --- a/src/mnode/inc/mgmtDnode.h +++ b/src/mnode/inc/mgmtDnode.h @@ -34,6 +34,7 @@ char* mgmtGetDnodeStatusStr(int32_t dnodeStatus); void mgmtMonitorDnodeModule(); int32_t mgmtGetDnodesNum(); +int32_t mgmtGetOnlinDnodesNum(); void * mgmtGetNextDnode(void *pIter, SDnodeObj **pDnode); void mgmtIncDnodeRef(SDnodeObj *pDnode); void mgmtDecDnodeRef(SDnodeObj *pDnode); diff --git a/src/mnode/inc/mgmtMnode.h b/src/mnode/inc/mgmtMnode.h index b9a135346dc971205f97900149d6839f879a61cf..0973aa6ea67985e5736c1b90f3d7c2ba1286e642 100644 --- a/src/mnode/inc/mgmtMnode.h +++ b/src/mnode/inc/mgmtMnode.h @@ -44,7 +44,7 @@ void mgmtDecMnodeRef(struct SMnodeObj *pMnode); char * mgmtGetMnodeRoleStr(); void mgmtGetMnodeIpSet(SRpcIpSet *ipSet); void mgmtGetMnodeInfos(void *mnodes); - +void mgmtUpdateMnodeIpSet(); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtTable.h b/src/mnode/inc/mgmtTable.h index 84220c9cf8ce942f86c668320e831beab2927fe0..3ef4c6d45309a681d585f7e2a0cb2e48c35b4842 100644 --- a/src/mnode/inc/mgmtTable.h +++ b/src/mnode/inc/mgmtTable.h @@ -31,6 +31,7 @@ void * mgmtGetNextChildTable(void *pIter, SChildTableObj **pTable); void * mgmtGetNextSuperTable(void *pIter, SSuperTableObj **pTable); void mgmtDropAllChildTables(SDbObj *pDropDb); void mgmtDropAllSuperTables(SDbObj *pDropDb); +void mgmtDropAllChildTablesInVgroups(SVgObj *pVgroup); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtVgroup.h b/src/mnode/inc/mgmtVgroup.h index ce4cfed5323d209c7cb80ea2c452455234543915..ab0345cd2037ef92e3285bbb2880129824434b1f 100644 --- a/src/mnode/inc/mgmtVgroup.h +++ b/src/mnode/inc/mgmtVgroup.h @@ -29,6 +29,7 @@ void mgmtIncVgroupRef(SVgObj *pVgroup); void mgmtDecVgroupRef(SVgObj *pVgroup); void mgmtDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg); void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode); +void mgmtUpdateAllDbVgroups(SDbObj *pAlterDb); void * mgmtGetNextVgroup(void *pIter, SVgObj **pVgroup); void mgmtUpdateVgroup(SVgObj *pVgroup); diff --git a/src/mnode/src/mgmtAcct.c b/src/mnode/src/mgmtAcct.c index 27beff8944f717d4193fdd6ae91b5a2c23c84506..a35591382c9a2d00dbedcdaa7f34f870ae74887c 100644 --- a/src/mnode/src/mgmtAcct.c +++ b/src/mnode/src/mgmtAcct.c @@ -94,7 +94,7 @@ int32_t mgmtInitAccts() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_ACCOUNT, .tableName = "accounts", - .hashSessions = TSDB_MAX_ACCOUNTS, + .hashSessions = TSDB_DEFAULT_ACCOUNTS_HASH_SIZE, .maxRowSize = tsAcctUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_STRING, diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 3f43d4bf8911c9ad8e92c76b788bfcf19d03752d..df18fe8786f523cac624f5a4ffa0718ee5a906ee 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -96,6 +96,7 @@ static int32_t mgmtDbActionUpdate(SSdbOper *pOper) { memcpy(pSaved, pDb, pOper->rowSize); free(pDb); } + mgmtUpdateAllDbVgroups(pSaved); mgmtDecDbRef(pSaved); return TSDB_CODE_SUCCESS; } @@ -127,7 +128,7 @@ int32_t mgmtInitDbs() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_DB, .tableName = "dbs", - .hashSessions = TSDB_MAX_DBS, + .hashSessions = TSDB_DEFAULT_DBS_HASH_SIZE, .maxRowSize = tsDbUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_STRING, @@ -187,11 +188,13 @@ static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) { if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) { mError("invalid db option cacheBlockSize:%d valid range: [%d, %d]", pCfg->cacheBlockSize, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE); + return TSDB_CODE_INVALID_OPTION; } if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) { mError("invalid db option totalBlocks:%d valid range: [%d, %d]", pCfg->totalBlocks, TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS); + return TSDB_CODE_INVALID_OPTION; } if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) { @@ -206,18 +209,22 @@ static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) { } if (pCfg->daysToKeep < TSDB_MIN_KEEP || pCfg->daysToKeep > TSDB_MAX_KEEP) { - mError("invalid db option daysToKeep:%d", pCfg->daysToKeep); + mError("invalid db option daysToKeep:%d valid range: [%d, %d]", pCfg->daysToKeep, TSDB_MIN_KEEP, TSDB_MAX_KEEP); return TSDB_CODE_INVALID_OPTION; } if (pCfg->daysToKeep < pCfg->daysPerFile) { - mError("invalid db option daysToKeep:%d daysPerFile:%d", pCfg->daysToKeep, pCfg->daysPerFile); + mError("invalid db option daysToKeep:%d should larger than daysPerFile:%d", pCfg->daysToKeep, pCfg->daysPerFile); return TSDB_CODE_INVALID_OPTION; } - if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) { - mError("invalid db option minRowsPerFileBlock:%d valid range: [%d, %d]", pCfg->minRowsPerFileBlock, - TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); + if (pCfg->daysToKeep2 < TSDB_MIN_KEEP || pCfg->daysToKeep2 > pCfg->daysToKeep) { + mError("invalid db option daysToKeep2:%d valid range: [%d, %d]", pCfg->daysToKeep, TSDB_MIN_KEEP, pCfg->daysToKeep); + return TSDB_CODE_INVALID_OPTION; + } + + if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > pCfg->daysToKeep2) { + mError("invalid db option daysToKeep1:%d valid range: [%d, %d]", pCfg->daysToKeep1, TSDB_MIN_KEEP, pCfg->daysToKeep2); return TSDB_CODE_INVALID_OPTION; } @@ -227,9 +234,15 @@ static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_INVALID_OPTION; } + if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) { + mError("invalid db option minRowsPerFileBlock:%d valid range: [%d, %d]", pCfg->minRowsPerFileBlock, + TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); + return TSDB_CODE_INVALID_OPTION; + } + if (pCfg->minRowsPerFileBlock > pCfg->maxRowsPerFileBlock) { - mError("invalid db option minRowsPerFileBlock:%d maxRowsPerFileBlock:%d", pCfg->minRowsPerFileBlock, - pCfg->maxRowsPerFileBlock); + mError("invalid db option minRowsPerFileBlock:%d should smaller than maxRowsPerFileBlock:%d", + pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock); return TSDB_CODE_INVALID_OPTION; } @@ -252,7 +265,7 @@ static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) { } if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) { - mError("invalid db option walLevel:%d, only 0-2 allowed", pCfg->walLevel); + mError("invalid db option walLevel:%d, valid range: [%d, %d]", pCfg->walLevel, TSDB_MIN_WAL_LEVEL, TSDB_MAX_WAL_LEVEL); return TSDB_CODE_INVALID_OPTION; } @@ -262,6 +275,11 @@ static int32_t mgmtCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_INVALID_OPTION; } + if (pCfg->replications > 1 && pCfg->walLevel <= TSDB_MIN_WAL_LEVEL) { + mError("invalid db option walLevel:%d must > 0, while replica:%d > 1", pCfg->walLevel, pCfg->replications); + return TSDB_CODE_INVALID_OPTION; + } + #ifndef _SYNC if (pCfg->replications != 1) { mError("invalid db option replications:%d can only be 1 in this version", pCfg->replications); @@ -314,13 +332,13 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) { pDb->createdTime = taosGetTimestampMs(); pDb->cfg = (SDbCfg) { .cacheBlockSize = pCreate->cacheBlockSize, - .totalBlocks = pCreate->numOfBlocks, + .totalBlocks = pCreate->totalBlocks, .maxTables = pCreate->maxTables, .daysPerFile = pCreate->daysPerFile, .daysToKeep = pCreate->daysToKeep, .daysToKeep1 = pCreate->daysToKeep1, .daysToKeep2 = pCreate->daysToKeep2, - .minRowsPerFileBlock = pCreate->maxRowsPerFileBlock, + .minRowsPerFileBlock = pCreate->minRowsPerFileBlock, .maxRowsPerFileBlock = pCreate->maxRowsPerFileBlock, .commitTime = pCreate->commitTime, .precision = pCreate->precision, @@ -735,7 +753,7 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) { pCreate->maxTables = htonl(pCreate->maxTables); pCreate->cacheBlockSize = htonl(pCreate->cacheBlockSize); - pCreate->numOfBlocks = htonl(pCreate->numOfBlocks); + pCreate->totalBlocks = htonl(pCreate->totalBlocks); pCreate->daysPerFile = htonl(pCreate->daysPerFile); pCreate->daysToKeep = htonl(pCreate->daysToKeep); pCreate->daysToKeep1 = htonl(pCreate->daysToKeep1); @@ -763,37 +781,47 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) { static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { SDbCfg newCfg = pDb->cfg; - int32_t cacheBlockSize = htonl(pAlter->daysToKeep); - int32_t totalBlocks = htonl(pAlter->numOfBlocks); - int32_t maxTables = htonl(pAlter->maxTables); - int32_t daysToKeep = htonl(pAlter->daysToKeep); - int32_t daysToKeep1 = htonl(pAlter->daysToKeep1); - int32_t daysToKeep2 = htonl(pAlter->daysToKeep2); - int8_t compression = pAlter->compression; - int8_t replications = pAlter->replications; - int8_t walLevel = pAlter->walLevel; + int32_t maxTables = htonl(pAlter->maxTables); + int32_t cacheBlockSize = htonl(pAlter->cacheBlockSize); + int32_t totalBlocks = htonl(pAlter->totalBlocks); + int32_t daysPerFile = htonl(pAlter->daysPerFile); + int32_t daysToKeep = htonl(pAlter->daysToKeep); + int32_t daysToKeep1 = htonl(pAlter->daysToKeep1); + int32_t daysToKeep2 = htonl(pAlter->daysToKeep2); + int32_t minRows = htonl(pAlter->minRowsPerFileBlock); + int32_t maxRows = htonl(pAlter->maxRowsPerFileBlock); + int32_t commitTime = htonl(pAlter->commitTime); + int8_t compression = pAlter->compression; + int8_t walLevel = pAlter->walLevel; + int8_t replications = pAlter->replications; + int8_t precision = pAlter->precision; terrno = TSDB_CODE_SUCCESS; if (cacheBlockSize > 0 && cacheBlockSize != pDb->cfg.cacheBlockSize) { - mTrace("db:%s, cache:%d change to %d", pDb->name, pDb->cfg.cacheBlockSize, cacheBlockSize); - newCfg.cacheBlockSize = cacheBlockSize; + mError("db:%s, can't alter cache option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; } if (totalBlocks > 0 && totalBlocks != pDb->cfg.totalBlocks) { - mTrace("db:%s, blocks:%d change to %d", pDb->name, pDb->cfg.totalBlocks, totalBlocks); + mPrint("db:%s, blocks:%d change to %d", pDb->name, pDb->cfg.totalBlocks, totalBlocks); newCfg.totalBlocks = totalBlocks; } - if (maxTables > 0 && maxTables != pDb->cfg.maxTables) { - mTrace("db:%s, tables:%d change to %d", pDb->name, pDb->cfg.maxTables, maxTables); + if (maxTables > 0) { + mPrint("db:%s, maxTables:%d change to %d", pDb->name, pDb->cfg.maxTables, maxTables); newCfg.maxTables = maxTables; if (newCfg.maxTables < pDb->cfg.maxTables) { - mTrace("db:%s, tables:%d should larger than origin:%d", pDb->name, newCfg.maxTables, pDb->cfg.maxTables); + mError("db:%s, tables:%d should larger than origin:%d", pDb->name, newCfg.maxTables, pDb->cfg.maxTables); terrno = TSDB_CODE_INVALID_OPTION; } } + if (daysPerFile > 0 && daysPerFile != pDb->cfg.daysPerFile) { + mError("db:%s, can't alter days option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + if (daysToKeep > 0 && daysToKeep != pDb->cfg.daysToKeep) { mTrace("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep); newCfg.daysToKeep = daysToKeep; @@ -809,15 +837,45 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { newCfg.daysToKeep2 = daysToKeep2; } + if (minRows > 0 && minRows != pDb->cfg.minRowsPerFileBlock) { + mError("db:%s, can't alter minRows option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + + if (maxRows > 0 && maxRows != pDb->cfg.maxRowsPerFileBlock) { + mError("db:%s, can't alter maxRows option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + + if (commitTime > 0 && commitTime != pDb->cfg.commitTime) { + mError("db:%s, can't alter commitTime option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + + if (precision > 0 && precision != pDb->cfg.precision) { + mError("db:%s, can't alter precision option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + if (compression >= 0 && compression != pDb->cfg.compression) { mTrace("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression); newCfg.compression = compression; } + if (walLevel > 0 && walLevel != pDb->cfg.walLevel) { + mError("db:%s, can't alter walLevel option", pDb->name); + terrno = TSDB_CODE_INVALID_OPTION; + } + if (replications > 0 && replications != pDb->cfg.replications) { mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications); newCfg.replications = replications; + if (replications > 1 && pDb->cfg.walLevel <= TSDB_MIN_WAL_LEVEL) { + mError("db:%s, walLevel:%d must > 0, while replica:%d > 1", pDb->name, pDb->cfg.walLevel, replications); + terrno = TSDB_CODE_INVALID_OPTION; + } + if (replications > mgmtGetDnodesNum()) { mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications); terrno = TSDB_CODE_NO_ENOUGH_DNODES; @@ -829,11 +887,6 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { } } - if (walLevel >= 0 && (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL)) { - mError("db:%s, wal level %d should be between 0-2, origin:%d", pDb->name, walLevel, pDb->cfg.walLevel); - terrno = TSDB_CODE_INVALID_OPTION; - } - return newCfg; } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index c3ae8b5ab1cbb16233a4a89173ada241710c9108..93c8276b14f3571f7743667f4536c5b8a375437b 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -74,7 +74,6 @@ static int32_t mgmtDnodeActionDelete(SSdbOper *pOper) { SDnodeObj *pDnode = pOper->pObj; #ifndef _SYNC - //TODO: drop dnode local mgmtDropAllDnodeVgroups(pDnode); #endif mgmtDropMnodeLocal(pDnode->dnodeId); @@ -130,7 +129,7 @@ int32_t mgmtInitDnodes() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_DNODE, .tableName = "dnodes", - .hashSessions = TSDB_MAX_DNODES, + .hashSessions = TSDB_DEFAULT_DNODES_HASH_SIZE, .maxRowSize = tsDnodeUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_AUTO, @@ -179,6 +178,23 @@ int32_t mgmtGetDnodesNum() { return sdbGetNumOfRows(tsDnodeSdb); } +int32_t mgmtGetOnlinDnodesNum(char *ep) { + SDnodeObj *pDnode = NULL; + void * pIter = NULL; + int32_t onlineDnodes = 0; + + while (1) { + pIter = mgmtGetNextDnode(pIter, &pDnode); + if (pDnode == NULL) break; + if (pDnode->status != TAOS_DN_STATUS_OFFLINE) onlineDnodes++; + mgmtDecDnodeRef(pDnode); + } + + sdbFreeIter(pIter); + + return onlineDnodes; +} + void *mgmtGetDnode(int32_t dnodeId) { return sdbGetRow(tsDnodeSdb, &dnodeId); } @@ -397,7 +413,6 @@ static int32_t mgmtCreateDnode(char *ep) { return code; } -//TODO drop others tables int32_t mgmtDropDnode(SDnodeObj *pDnode) { SSdbOper oper = { .type = SDB_OPER_GLOBAL, @@ -410,7 +425,7 @@ int32_t mgmtDropDnode(SDnodeObj *pDnode) { code = TSDB_CODE_SDB_ERROR; } - mLPrint("dnode:%d is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); + mLPrint("dnode:%d, is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); return code; } diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index d9ddd465f6d7ac1e60db572e2839905a498bac03..6471b7f182b41c9e077230671f722f8e37b1985d 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -36,6 +36,25 @@ static int32_t tsMnodeUpdateSize = 0; static int32_t mgmtGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); +static SRpcIpSet tsMnodeRpcIpSet; +static SDMMnodeInfos tsMnodeInfos; + +#if defined(LINUX) + static pthread_rwlock_t tsMnodeLock; + #define mgmtMnodeWrLock() pthread_rwlock_wrlock(&tsMnodeLock) + #define mgmtMnodeRdLock() pthread_rwlock_rdlock(&tsMnodeLock) + #define mgmtMnodeUnLock() pthread_rwlock_unlock(&tsMnodeLock) + #define mgmtMnodeInitLock() pthread_rwlock_init(&tsMnodeLock, NULL) + #define mgmtMnodeDestroyLock() pthread_rwlock_destroy(&tsMnodeLock) +#else + static pthread_mutex_t tsMnodeLock; + #define mgmtMnodeWrLock() pthread_mutex_lock(&tsMnodeLock) + #define mgmtMnodeRdLock() pthread_mutex_lock(&tsMnodeLock) + #define mgmtMnodeUnLock() pthread_mutex_unlock(&tsMnodeLock) + #define mgmtMnodeInitLock() pthread_mutex_init(&tsMnodeLock, NULL) + #define mgmtMnodeDestroyLock() pthread_mutex_destroy(&tsMnodeLock) +#endif + static int32_t mgmtMnodeActionDestroy(SSdbOper *pOper) { tfree(pOper->pObj); return TSDB_CODE_SUCCESS; @@ -46,7 +65,6 @@ static int32_t mgmtMnodeActionInsert(SSdbOper *pOper) { SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId); if (pDnode == NULL) return TSDB_CODE_DNODE_NOT_EXIST; - pMnode->pDnode = pDnode; pDnode->isMgmt = true; mgmtDecDnodeRef(pDnode); @@ -102,17 +120,22 @@ static int32_t mgmtMnodeActionRestored() { } sdbFreeIter(pIter); } + + mgmtUpdateMnodeIpSet(); + return TSDB_CODE_SUCCESS; } int32_t mgmtInitMnodes() { + mgmtMnodeInitLock(); + SMnodeObj tObj; tsMnodeUpdateSize = (int8_t *)tObj.updateEnd - (int8_t *)&tObj; SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_MNODE, .tableName = "mnodes", - .hashSessions = TSDB_MAX_MNODES, + .hashSessions = TSDB_DEFAULT_MNODES_HASH_SIZE, .maxRowSize = tsMnodeUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_INT, @@ -140,6 +163,7 @@ int32_t mgmtInitMnodes() { void mgmtCleanupMnodes() { sdbCloseTable(tsMnodeSdb); + mgmtMnodeDestroyLock(); } int32_t mgmtGetMnodesNum() { @@ -177,50 +201,65 @@ char *mgmtGetMnodeRoleStr(int32_t role) { } } -void mgmtGetMnodeIpSet(SRpcIpSet *ipSet) { - void *pIter = NULL; - while (1) { - SMnodeObj *pMnode = NULL; - pIter = mgmtGetNextMnode(pIter, &pMnode); - if (pMnode == NULL) break; +void mgmtUpdateMnodeIpSet() { + SRpcIpSet *ipSet = &tsMnodeRpcIpSet; + SDMMnodeInfos *mnodes = &tsMnodeInfos; - strcpy(ipSet->fqdn[ipSet->numOfIps], pMnode->pDnode->dnodeFqdn); - ipSet->port[ipSet->numOfIps] = htons(pMnode->pDnode->dnodePort); + mPrint("update mnodes ipset, numOfIps:%d ", mgmtGetMnodesNum()); - if (pMnode->role == TAOS_SYNC_ROLE_MASTER) { - ipSet->inUse = ipSet->numOfIps; - } + mgmtMnodeWrLock(); - ipSet->numOfIps++; - - mgmtDecMnodeRef(pMnode); - } - sdbFreeIter(pIter); -} + memset(ipSet, 0, sizeof(tsMnodeRpcIpSet)); + memset(mnodes, 0, sizeof(SDMMnodeInfos)); -void mgmtGetMnodeInfos(void *param) { - SDMMnodeInfos *mnodes = param; - mnodes->inUse = 0; - int32_t index = 0; - void *pIter = NULL; + void * pIter = NULL; while (1) { SMnodeObj *pMnode = NULL; pIter = mgmtGetNextMnode(pIter, &pMnode); if (pMnode == NULL) break; - mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId); - strcpy(mnodes->nodeInfos[index].nodeEp, pMnode->pDnode->dnodeEp); - if (pMnode->role == TAOS_SYNC_ROLE_MASTER) { - mnodes->inUse = index; + SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId); + if (pDnode != NULL) { + strcpy(ipSet->fqdn[ipSet->numOfIps], pDnode->dnodeFqdn); + ipSet->port[ipSet->numOfIps] = htons(pDnode->dnodePort); + + mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId); + strcpy(mnodes->nodeInfos[index].nodeEp, pDnode->dnodeEp); + + if (pMnode->role == TAOS_SYNC_ROLE_MASTER) { + ipSet->inUse = ipSet->numOfIps; + mnodes->inUse = index; + } + + mPrint("mnode:%d, ep:%s %s", index, pDnode->dnodeEp, + pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : ""); + + ipSet->numOfIps++; + index++; } - index++; + mgmtDecDnodeRef(pDnode); mgmtDecMnodeRef(pMnode); } - sdbFreeIter(pIter); mnodes->nodeNum = index; + + sdbFreeIter(pIter); + + mgmtMnodeUnLock(); +} + +void mgmtGetMnodeIpSet(SRpcIpSet *ipSet) { + mgmtMnodeRdLock(); + *ipSet = tsMnodeRpcIpSet; + mgmtMnodeUnLock(); +} + +void mgmtGetMnodeInfos(void *mnodeInfos) { + mgmtMnodeRdLock(); + *(SDMMnodeInfos *)mnodeInfos = tsMnodeInfos; + mgmtMnodeUnLock(); } int32_t mgmtAddMnode(int32_t dnodeId) { @@ -240,6 +279,8 @@ int32_t mgmtAddMnode(int32_t dnodeId) { code = TSDB_CODE_SDB_ERROR; } + mgmtUpdateMnodeIpSet(); + return code; } @@ -250,6 +291,8 @@ void mgmtDropMnodeLocal(int32_t dnodeId) { sdbDeleteRow(&oper); mgmtDecMnodeRef(pMnode); } + + mgmtUpdateMnodeIpSet(); } int32_t mgmtDropMnode(int32_t dnodeId) { @@ -270,6 +313,9 @@ int32_t mgmtDropMnode(int32_t dnodeId) { } sdbDecRef(tsMnodeSdb, pMnode); + + mgmtUpdateMnodeIpSet(); + return code; } @@ -343,7 +389,15 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pMnode->pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE); + + SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId); + if (pDnode != NULL) { + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE); + } else { + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, "invalid ep", pShow->bytes[cols] - VARSTR_HEADER_SIZE); + } + mgmtDecDnodeRef(pDnode); + cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 087c84effd63e8735a30cc9e738f20050046a3bf..237d2ca499296d00ffd50007430a57649767fa9f 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -28,6 +28,7 @@ #include "mgmtDef.h" #include "mgmtInt.h" #include "mgmtMnode.h" +#include "mgmtDnode.h" #include "mgmtSdb.h" typedef enum { @@ -196,6 +197,8 @@ void sdbUpdateMnodeRoles() { mgmtDecMnodeRef(pMnode); } } + + mgmtUpdateMnodeIpSet(); } static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion) { @@ -227,7 +230,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { static int32_t sdbForwardToPeer(SWalHead *pHead) { if (tsSdbObj.sync == NULL) return TSDB_CODE_SUCCESS; - int32_t code = syncForwardToPeer(tsSdbObj.sync, pHead, (void*)pHead->version); + int32_t code = syncForwardToPeer(tsSdbObj.sync, pHead, (void*)pHead->version, TAOS_QTYPE_RPC); if (code > 0) { sdbTrace("forward request is sent, version:%" PRIu64 ", code:%d", pHead->version, code); sem_wait(&tsSdbObj.sem); @@ -257,10 +260,15 @@ void sdbUpdateSync() { if (pMnode == NULL) break; syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId; - syncCfg.nodeInfo[index].nodePort = pMnode->pDnode->dnodePort + TSDB_PORT_SYNC; - strcpy(syncCfg.nodeInfo[index].nodeFqdn, pMnode->pDnode->dnodeEp); - index++; + SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId); + if (pDnode != NULL) { + syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC; + strcpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeEp); + index++; + } + + mgmtDecDnodeRef(pDnode); mgmtDecMnodeRef(pMnode); } sdbFreeIter(pIter); @@ -352,7 +360,7 @@ void sdbIncRef(void *handle, void *pObj) { int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); atomic_add_fetch_32(pRefCount, 1); if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { - sdbTrace("table:%s, add ref to record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("add ref to table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } } @@ -363,7 +371,7 @@ void sdbDecRef(void *handle, void *pObj) { int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); int32_t refCount = atomic_sub_fetch_32(pRefCount, 1); if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { - sdbTrace("table:%s, def ref of record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("def ref of table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } int8_t *updateEnd = pObj + pTable->refCountPos - 1; @@ -442,8 +450,8 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) { pthread_mutex_unlock(&pTable->mutex); - sdbTrace("table:%s, insert record:%s to hash, numOfRows:%d version:%" PRIu64, pTable->tableName, - sdbGetKeyStrFromObj(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion()); + sdbTrace("table:%s, insert record:%s to hash, rowSize:%d vnumOfRows:%d version:%" PRIu64, pTable->tableName, + sdbGetKeyStrFromObj(pTable, pOper->pObj), pOper->rowSize, pTable->numOfRows, sdbGetVersion()); (*pTable->insertFp)(pOper); return TSDB_CODE_SUCCESS; diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index d8bcf6724236d6e7bfa1e4372797a78ab95aa1e3..ccbed350dc3b22ebbfde250ef2edfd0c887a1cde 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -119,7 +119,7 @@ static void mgmtDoDealyedAddToShellQueue(void *param, void *tmrId) { void mgmtDealyedAddToShellQueue(SQueuedMsg *queuedMsg) { void *unUsed = NULL; - taosTmrReset(mgmtDoDealyedAddToShellQueue, 1000, queuedMsg, tsMgmtTmr, &unUsed); + taosTmrReset(mgmtDoDealyedAddToShellQueue, 300, queuedMsg, tsMgmtTmr, &unUsed); } void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { @@ -325,6 +325,8 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) { return; } + pHBRsp->onlineDnodes = htonl(mgmtGetOnlinDnodesNum()); + pHBRsp->totalDnodes = htonl(mgmtGetDnodesNum()); mgmtGetMnodeIpSet(&pHBRsp->ipList); /* diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 30433069789c228e5f6d5591bc2592d21cae196e..53fbd64f87e9c50fcb87deb15137c206412f1e35 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -269,7 +269,6 @@ static int32_t mgmtChildTableActionRestored() { SChildTableObj *pTable = NULL; while (1) { - mgmtDecTableRef(pTable); pIter = mgmtGetNextChildTable(pIter, &pTable); if (pTable == NULL) break; @@ -278,6 +277,7 @@ static int32_t mgmtChildTableActionRestored() { mError("ctable:%s, failed to get db, discard it", pTable->info.tableId); SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); + mgmtDecTableRef(pTable); continue; } mgmtDecDbRef(pDb); @@ -288,6 +288,7 @@ static int32_t mgmtChildTableActionRestored() { pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); + mgmtDecTableRef(pTable); continue; } mgmtDecVgroupRef(pVgroup); @@ -298,6 +299,7 @@ static int32_t mgmtChildTableActionRestored() { pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); + mgmtDecTableRef(pTable); continue; } @@ -306,6 +308,7 @@ static int32_t mgmtChildTableActionRestored() { pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); + mgmtDecTableRef(pTable); continue; } @@ -316,10 +319,13 @@ static int32_t mgmtChildTableActionRestored() { pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); + mgmtDecTableRef(pTable); continue; } mgmtDecTableRef(pSuperTable); } + + mgmtDecTableRef(pTable); } sdbFreeIter(pIter); @@ -334,7 +340,7 @@ static int32_t mgmtInitChildTables() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_CTABLE, .tableName = "ctables", - .hashSessions = tsMaxTables, + .hashSessions = TSDB_DEFAULT_CTABLES_HASH_SIZE, .maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_ID_LEN + TSDB_CQ_SQL_SIZE, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_VAR_STRING, @@ -501,7 +507,7 @@ static int32_t mgmtInitSuperTables() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_STABLE, .tableName = "stables", - .hashSessions = TSDB_MAX_SUPER_TABLES, + .hashSessions = TSDB_DEFAULT_STABLES_HASH_SIZE, .maxRowSize = sizeof(SSuperTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_ID_LEN, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_VAR_STRING, @@ -1133,22 +1139,23 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v prefixLen = strlen(prefix); SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - char stableName[TSDB_TABLE_NAME_LEN] = {0}; + char stableName[TSDB_TABLE_NAME_LEN + 1] = {0}; while (numOfRows < rows) { - mgmtDecTableRef(pTable); pShow->pIter = mgmtGetNextSuperTable(pShow->pIter, &pTable); if (pTable == NULL) break; if (strncmp(pTable->info.tableId, prefix, prefixLen)) { + mgmtDecTableRef(pTable); continue; } memset(stableName, 0, tListLen(stableName)); mgmtExtractTableName(pTable->info.tableId, stableName); - if (pShow->payloadLen > 0 && - patternMatch(pShow->payload, stableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) + if (pShow->payloadLen > 0 && patternMatch(pShow->payload, stableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) { + mgmtDecTableRef(pTable); continue; + } cols = 0; @@ -1178,6 +1185,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v cols++; numOfRows++; + mgmtDecTableRef(pTable); } pShow->numOfReads += numOfRows; @@ -1252,7 +1260,7 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) { pMeta->contLen = htons(pMeta->contLen); rpcSendResponse(&rpcRsp); - mTrace("stable:%%s, uid:%" PRIu64 " table meta is retrieved", pTable->info.tableId, pTable->uid); + mTrace("stable:%s, uid:%" PRIu64 " table meta is retrieved", pTable->info.tableId, pTable->uid); } static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { @@ -1297,7 +1305,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { if (pDnode == NULL) break; strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); - pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort); + pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(pDnode->dnodePort); pVgroupInfo->vgroups[vgSize].numOfIps++; } @@ -1326,13 +1334,13 @@ static void mgmtProcessDropSuperTableRsp(SRpcMsg *rpcMsg) { } static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTable) { - char * pTagData = NULL; + STagData * pTagData = NULL; int32_t tagDataLen = 0; int32_t totalCols = 0; int32_t contLen = 0; if (pTable->info.type == TSDB_CHILD_TABLE && pMsg != NULL) { - pTagData = pMsg->schema + TSDB_TABLE_ID_LEN + 1; - tagDataLen = htonl(pMsg->contLen) - sizeof(SCMCreateTableMsg) - TSDB_TABLE_ID_LEN - 1; + pTagData = (STagData*)pMsg->schema; + tagDataLen = ntohl(pTagData->dataLen); totalCols = pTable->superTable->numOfColumns + pTable->superTable->numOfTags; contLen = sizeof(SMDCreateTableMsg) + totalCols * sizeof(SSchema) + tagDataLen + pTable->sqlLen; } else { @@ -1385,7 +1393,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb } if (pTable->info.type == TSDB_CHILD_TABLE && pMsg != NULL) { - memcpy(pCreate->data + totalCols * sizeof(SSchema), pTagData, tagDataLen); + memcpy(pCreate->data + totalCols * sizeof(SSchema), pTagData->data, tagDataLen); memcpy(pCreate->data + totalCols * sizeof(SSchema) + tagDataLen, pTable->sql, pTable->sqlLen); } @@ -1412,10 +1420,10 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj pTable->vgId = pVgroup->vgId; if (pTable->info.type == TSDB_CHILD_TABLE) { - char *pTagData = (char *) pCreate->schema; // it is a tag key - SSuperTableObj *pSuperTable = mgmtGetSuperTable(pTagData); + STagData *pTagData = (STagData *) pCreate->schema; // it is a tag key + SSuperTableObj *pSuperTable = mgmtGetSuperTable(pTagData->name); if (pSuperTable == NULL) { - mError("table:%s, corresponding super table:%s does not exist", pCreate->tableId, pTagData); + mError("table:%s, corresponding super table:%s does not exist", pCreate->tableId, pTagData->name); free(pTable); terrno = TSDB_CODE_INVALID_TABLE; return NULL; @@ -1475,7 +1483,7 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj return NULL; } - mTrace("table:%s, create table in vgroup, id:%d, uid:%" PRIu64 , pTable->info.tableId, pTable->sid, pTable->uid); + mTrace("table:%s, create table in vgroup:%d, id:%d, uid:%" PRIu64 , pTable->info.tableId, pVgroup->vgId, pTable->sid, pTable->uid); return pTable; } @@ -1530,7 +1538,7 @@ static void mgmtProcessCreateChildTableMsg(SQueuedMsg *pMsg) { SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SQueuedMsg *newMsg = mgmtCloneQueuedMsg(pMsg); newMsg->ahandle = pMsg->pTable; - newMsg->maxRetry = 5; + newMsg->maxRetry = 10; SRpcMsg rpcMsg = { .handle = newMsg, .pCont = pMDCreate, @@ -1734,7 +1742,9 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) { static void mgmtAutoCreateChildTable(SQueuedMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->pCont; - int32_t contLen = sizeof(SCMCreateTableMsg) + sizeof(STagData); + STagData* pTag = (STagData*)pInfo->tags; + + int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + ntohl(pTag->dataLen); SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen); if (pCreateMsg == NULL) { mError("table:%s, failed to create table while get meta info, no enough memory", pInfo->tableId); @@ -1748,18 +1758,13 @@ static void mgmtAutoCreateChildTable(SQueuedMsg *pMsg) { pCreateMsg->getMeta = 1; pCreateMsg->contLen = htonl(contLen); - contLen = sizeof(STagData); - if (contLen > pMsg->contLen - sizeof(SCMTableInfoMsg)) { - contLen = pMsg->contLen - sizeof(SCMTableInfoMsg); - } - memcpy(pCreateMsg->schema, pInfo->tags, contLen); + memcpy(pCreateMsg->schema, pInfo->tags, contLen - sizeof(SCMCreateTableMsg)); SQueuedMsg *newMsg = mgmtCloneQueuedMsg(pMsg); - pMsg->pCont = newMsg->pCont; newMsg->msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE; newMsg->pCont = pCreateMsg; - mTrace("table:%s, start to create on demand", pInfo->tableId); + mTrace("table:%s, start to create on demand, stable:%s", pInfo->tableId, pInfo->tags); mgmtAddToShellQueue(newMsg); } @@ -1782,6 +1787,34 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) { rpcSendResponse(&rpcRsp); } +void mgmtDropAllChildTablesInVgroups(SVgObj *pVgroup) { + void * pIter = NULL; + int32_t numOfTables = 0; + SChildTableObj *pTable = NULL; + + mPrint("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId); + + while (1) { + pIter = mgmtGetNextChildTable(pIter, &pTable); + if (pTable == NULL) break; + + if (pTable->vgId == pVgroup->vgId) { + SSdbOper oper = { + .type = SDB_OPER_LOCAL, + .table = tsChildTableSdb, + .pObj = pTable, + }; + sdbDeleteRow(&oper); + numOfTables++; + } + mgmtDecTableRef(pTable); + } + + sdbFreeIter(pIter); + + mPrint("vgId:%d, all child tables is dropped from sdb", pVgroup->vgId); +} + void mgmtDropAllChildTables(SDbObj *pDropDb) { void * pIter = NULL; int32_t numOfTables = 0; @@ -1991,7 +2024,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { SCMMultiTableInfoMsg *pInfo = pMsg->pCont; pInfo->numOfTables = htonl(pInfo->numOfTables); - int32_t totalMallocLen = 4*1024*1024; // first malloc 4 MB, subsequent reallocation as twice + int32_t totalMallocLen = 4 * 1024 * 1024; // first malloc 4 MB, subsequent reallocation as twice SMultiTableMeta *pMultiMeta = rpcMallocCont(totalMallocLen); if (pMultiMeta == NULL) { mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); @@ -2001,26 +2034,30 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { pMultiMeta->contLen = sizeof(SMultiTableMeta); pMultiMeta->numOfTables = 0; - for (int t = 0; t < pInfo->numOfTables; ++t) { - char *tableId = (char*)(pInfo->tableIds + t * TSDB_TABLE_ID_LEN); + for (int32_t t = 0; t < pInfo->numOfTables; ++t) { + char * tableId = (char *)(pInfo->tableIds + t * TSDB_TABLE_ID_LEN + 1); SChildTableObj *pTable = mgmtGetChildTable(tableId); if (pTable == NULL) continue; if (pMsg->pDb == NULL) pMsg->pDb = mgmtGetDbByTableId(tableId); - if (pMsg->pDb == NULL) continue; + if (pMsg->pDb == NULL) { + mgmtDecTableRef(pTable); + continue; + } int availLen = totalMallocLen - pMultiMeta->contLen; if (availLen <= sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16)) { - //TODO realloc - //totalMallocLen *= 2; - //pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen); - //if (pMultiMeta == NULL) { - /// rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0); - // return TSDB_CODE_SERV_OUT_OF_MEMORY; - //} else { - // t--; - // continue; - //} + totalMallocLen *= 2; + pMultiMeta = rpcReallocCont(pMultiMeta, totalMallocLen); + if (pMultiMeta == NULL) { + mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); + mgmtDecTableRef(pTable); + return; + } else { + t--; + mgmtDecTableRef(pTable); + continue; + } } STableMetaMsg *pMeta = (STableMetaMsg *)(pMultiMeta->metas + pMultiMeta->contLen); @@ -2029,6 +2066,8 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { pMultiMeta->numOfTables ++; pMultiMeta->contLen += pMeta->contLen; } + + mgmtDecTableRef(pTable); } SRpcMsg rpcRsp = {0}; @@ -2106,22 +2145,22 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, int32_t prefixLen = strlen(prefix); while (numOfRows < rows) { - mgmtDecTableRef(pTable); pShow->pIter = mgmtGetNextChildTable(pShow->pIter, &pTable); if (pTable == NULL) break; // not belong to current db if (strncmp(pTable->info.tableId, prefix, prefixLen)) { + mgmtDecTableRef(pTable); continue; } - char tableName[TSDB_TABLE_NAME_LEN] = {0}; + char tableName[TSDB_TABLE_NAME_LEN + 1] = {0}; // pattern compare for table name mgmtExtractTableName(pTable->info.tableId, tableName); - if (pShow->payloadLen > 0 && - patternMatch(pShow->payload, tableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) { + if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) { + mgmtDecTableRef(pTable); continue; } @@ -2156,6 +2195,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, cols++; numOfRows++; + mgmtDecTableRef(pTable); } pShow->numOfReads += numOfRows; @@ -2192,6 +2232,8 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) { } pAlter->type = htons(pAlter->type); + pAlter->numOfCols = htons(pAlter->numOfCols); + pAlter->tagValLen = htonl(pAlter->tagValLen); if (pAlter->numOfCols > 2) { mError("table:%s, error numOfCols:%d in alter table", pAlter->tableId, pAlter->numOfCols); @@ -2223,7 +2265,8 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) { mTrace("table:%s, start to alter ctable", pAlter->tableId); SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) { - code = mgmtModifyChildTableTagValue(pTable, pAlter->schema[0].name, pAlter->tagVal); + char *tagVal = (char*)(pAlter->schema + pAlter->numOfCols); + code = mgmtModifyChildTableTagValue(pTable, pAlter->schema[0].name, tagVal); } else if (pAlter->type == TSDB_ALTER_TABLE_ADD_COLUMN) { code = mgmtAddNormalTableColumn(pMsg->pDb, pTable, pAlter->schema, 1); } else if (pAlter->type == TSDB_ALTER_TABLE_DROP_COLUMN) { diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index cc22ed2169d3c810a8c5921538b188f1dcb45746..62a98c41707c11083818ad96af4c2fdb7744ffb4 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -117,7 +117,7 @@ int32_t mgmtInitUsers() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_USER, .tableName = "users", - .hashSessions = TSDB_MAX_USERS, + .hashSessions = TSDB_DEFAULT_USERS_HASH_SIZE, .maxRowSize = tsUserUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_STRING, diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index ef5582f395b816df5b7b5ccf49f86253239bc59d..960863d665504e0c6d6e6b9cef54581f84c325b2 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -121,6 +121,20 @@ static int32_t mgmtVgroupActionDelete(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } +static void mgmtVgroupUpdateIdPool(SVgObj *pVgroup) { + int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool); + SDbObj *pDb = pVgroup->pDb; + if (pDb != NULL) { + if (pDb->cfg.maxTables != oldTables) { + mPrint("vgId:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables); + taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables); + int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables; + pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); + memset(pVgroup->tableList + oldTables, 0, (pDb->cfg.maxTables - oldTables) * sizeof(SChildTableObj **)); + } + } +} + static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) { SVgObj *pNew = pOper->pObj; SVgObj *pVgroup = mgmtGetVgroup(pNew->vgId); @@ -146,20 +160,11 @@ static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) { } } - int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool); - SDbObj *pDb = pVgroup->pDb; - if (pDb != NULL) { - if (pDb->cfg.maxTables != oldTables) { - mPrint("vgId:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables); - taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables); - int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables; - pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); - } - } + mgmtVgroupUpdateIdPool(pVgroup); mgmtDecVgroupRef(pVgroup); - mTrace("vgId:%d, is updated, numOfVnode:%d tables:%d", pVgroup->vgId, pVgroup->numOfVnodes, pDb == NULL ? 0 : pDb->cfg.maxTables); + mTrace("vgId:%d, is updated, numOfVnode:%d", pVgroup->vgId, pVgroup->numOfVnodes); return TSDB_CODE_SUCCESS; } @@ -196,7 +201,7 @@ int32_t mgmtInitVgroups() { SSdbTableDesc tableDesc = { .tableId = SDB_TABLE_VGROUP, .tableName = "vgroups", - .hashSessions = TSDB_MAX_VGROUPS, + .hashSessions = TSDB_DEFAULT_VGROUPS_HASH_SIZE, .maxRowSize = tsVgUpdateSize, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .keyType = SDB_KEY_AUTO, @@ -742,11 +747,14 @@ void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode) { SVgObj *pVgroup = NULL; int32_t numOfVgroups = 0; + mPrint("dnode:%d, all vgroups will be dropped from sdb", pDropDnode->dnodeId); + while (1) { pIter = mgmtGetNextVgroup(pIter, &pVgroup); if (pVgroup == NULL) break; if (pVgroup->vnodeGid[0].dnodeId == pDropDnode->dnodeId) { + mgmtDropAllChildTablesInVgroups(pVgroup); SSdbOper oper = { .type = SDB_OPER_LOCAL, .table = tsVgroupSdb, @@ -754,12 +762,35 @@ void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode) { }; sdbDeleteRow(&oper); numOfVgroups++; - continue; } mgmtDecVgroupRef(pVgroup); } sdbFreeIter(pIter); + + mPrint("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId); +} + +void mgmtUpdateAllDbVgroups(SDbObj *pAlterDb) { + void * pIter = NULL; + SVgObj *pVgroup = NULL; + + mPrint("db:%s, all vgroups will be update in sdb", pAlterDb->name); + + while (1) { + pIter = mgmtGetNextVgroup(pIter, &pVgroup); + if (pVgroup == NULL) break; + + if (pVgroup->pDb == pAlterDb) { + mgmtVgroupUpdateIdPool(pVgroup); + } + + mgmtDecVgroupRef(pVgroup); + } + + sdbFreeIter(pIter); + + mPrint("db:%s, all vgroups is updated in sdb", pAlterDb->name); } void mgmtDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) { diff --git a/src/os/linux/inc/os.h b/src/os/linux/inc/os.h index 40fcf834318aa90baf3b9ddf575618f402124623..35d2236001cf27f29864baf2e48e725ab5f4a507 100644 --- a/src/os/linux/inc/os.h +++ b/src/os/linux/inc/os.h @@ -53,6 +53,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/src/os/linux/src/linuxPlatform.c b/src/os/linux/src/linuxPlatform.c index 73cccd020aec4f6b59b4fc18f7eca4f93aa28539..782a508b174d87576f454c73dda6478b116207f0 100644 --- a/src/os/linux/src/linuxPlatform.c +++ b/src/os/linux/src/linuxPlatform.c @@ -148,6 +148,10 @@ static void taosDeleteTimer(void *tharg) { timer_delete(*pTimer); } +static pthread_t timerThread; +static timer_t timerId; +static volatile bool stopTimer = false; + void *taosProcessAlarmSignal(void *tharg) { // Block the signal sigset_t sigset; @@ -156,7 +160,6 @@ void *taosProcessAlarmSignal(void *tharg) { sigprocmask(SIG_BLOCK, &sigset, NULL); void (*callback)(int) = tharg; - static timer_t timerId; struct sigevent sevent = {{0}}; #ifdef _ALPINE @@ -187,7 +190,7 @@ void *taosProcessAlarmSignal(void *tharg) { } int signo; - while (1) { + while (!stopTimer) { if (sigwait(&sigset, &signo)) { uError("Failed to wait signal: number %d", signo); continue; @@ -202,7 +205,6 @@ void *taosProcessAlarmSignal(void *tharg) { return NULL; } -static pthread_t timerThread; int taosInitTimer(void (*callback)(int), int ms) { pthread_attr_t tattr; @@ -217,7 +219,7 @@ int taosInitTimer(void (*callback)(int), int ms) { } void taosUninitTimer() { - pthread_cancel(timerThread); + stopTimer = true; pthread_join(timerThread, NULL); } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 562de724105ae934fb804fb7c6f9844ddfbe5e17..2bc6bf54bfe9b330ede401cee521b0931f4be684 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -3,3 +3,4 @@ PROJECT(TDengine) ADD_SUBDIRECTORY(monitor) ADD_SUBDIRECTORY(http) +ADD_SUBDIRECTORY(mqtt) diff --git a/src/plugins/http/inc/httpHandle.h b/src/plugins/http/inc/httpHandle.h index d8b3b8eade94c86fb4a9b95a54d6195e52d39445..9be2796a9629055fa5fa5b77b5bdb689970542da 100644 --- a/src/plugins/http/inc/httpHandle.h +++ b/src/plugins/http/inc/httpHandle.h @@ -199,7 +199,7 @@ typedef struct HttpThread { pthread_t thread; HttpContext * pHead; pthread_mutex_t threadMutex; - pthread_cond_t fdReady; + bool stop; int pollFd; int numOfFds; int threadId; @@ -212,6 +212,8 @@ typedef struct HttpServer { char label[HTTP_LABEL_SIZE]; uint32_t serverIp; uint16_t serverPort; + bool online; + int fd; int cacheContext; int sessionExpire; int numOfThreads; @@ -226,7 +228,6 @@ typedef struct HttpServer { bool (*processData)(HttpContext *pContext); int requestNum; void *timerHandle; - bool online; } HttpServer; // http util method diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 51795a570d2a25360561938642cd175623244bd7..9a9c659b038a0061c4af3acc5581298800db378d 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -258,28 +258,47 @@ void httpCloseContextByServerForExpired(void *param, void *tmrId) { httpCloseContextByServer(pContext->pThread, pContext); } -void httpCleanUpConnect(HttpServer *pServer) { - int i; - HttpThread *pThread; - if (pServer == NULL) return; +static void httpStopThread(HttpThread* pThread) { + pThread->stop = true; - pthread_cancel(pServer->thread); - pthread_join(pServer->thread, NULL); + // signal the thread to stop, try graceful method first, + // and use pthread_cancel when failed + struct epoll_event event = { .events = EPOLLIN }; + eventfd_t fd = eventfd(1, 0); + if (fd == -1) { + httpError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); + pthread_cancel(pThread->thread); + } else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { + httpError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); + pthread_cancel(pThread->thread); + } - for (i = 0; i < pServer->numOfThreads; ++i) { - pThread = pServer->pThreads + i; - if (pThread == NULL) continue; - //taosCloseSocket(pThread->pollFd); + pthread_join(pThread->thread, NULL); + if (fd != -1) { + close(fd); + } - //while (pThread->pHead) { - // httpCleanUpContext(pThread->pHead, 0); - //} + close(pThread->pollFd); + pthread_mutex_destroy(&(pThread->threadMutex)); - pthread_cancel(pThread->thread); - pthread_join(pThread->thread, NULL); - pthread_cond_destroy(&(pThread->fdReady)); - pthread_mutex_destroy(&(pThread->threadMutex)); + //while (pThread->pHead) { + // httpCleanUpContext(pThread->pHead, 0); + //} +} + + +void httpCleanUpConnect(HttpServer *pServer) { + if (pServer == NULL) return; + + shutdown(pServer->fd, SHUT_RD); + pthread_join(pServer->thread, NULL); + + for (int i = 0; i < pServer->numOfThreads; ++i) { + HttpThread* pThread = pServer->pThreads + i; + if (pThread != NULL) { + httpStopThread(pThread); + } } tfree(pServer->pThreads); @@ -412,15 +431,13 @@ void httpProcessHttpData(void *param) { pthread_sigmask(SIG_SETMASK, &set, NULL); while (1) { - pthread_mutex_lock(&pThread->threadMutex); - if (pThread->numOfFds < 1) { - pthread_cond_wait(&pThread->fdReady, &pThread->threadMutex); - } - pthread_mutex_unlock(&pThread->threadMutex); - struct epoll_event events[HTTP_MAX_EVENTS]; //-1 means uncertainty, 0-nowait, 1-wait 1 ms, set it from -1 to 1 fdNum = epoll_wait(pThread->pollFd, events, HTTP_MAX_EVENTS, 1); + if (pThread->stop) { + httpTrace("%p, http thread get stop event, exiting...", pThread); + break; + } if (fdNum <= 0) continue; for (int i = 0; i < fdNum; ++i) { @@ -485,10 +502,9 @@ void httpProcessHttpData(void *param) { } } -void httpAcceptHttpConnection(void *arg) { +void* httpAcceptHttpConnection(void *arg) { int connFd = -1; struct sockaddr_in clientAddr; - int sockFd; int threadId = 0; HttpThread * pThread; HttpServer * pServer; @@ -502,12 +518,12 @@ void httpAcceptHttpConnection(void *arg) { sigaddset(&set, SIGPIPE); pthread_sigmask(SIG_SETMASK, &set, NULL); - sockFd = taosOpenTcpServerSocket(pServer->serverIp, pServer->serverPort); + pServer->fd = taosOpenTcpServerSocket(pServer->serverIp, pServer->serverPort); - if (sockFd < 0) { + if (pServer->fd < 0) { httpError("http server:%s, failed to open http socket, ip:%s:%u error:%s", pServer->label, taosIpStr(pServer->serverIp), pServer->serverPort, strerror(errno)); - return; + return NULL; } else { httpPrint("http service init success at %u", pServer->serverPort); pServer->online = true; @@ -515,9 +531,12 @@ void httpAcceptHttpConnection(void *arg) { while (1) { socklen_t addrlen = sizeof(clientAddr); - connFd = (int)accept(sockFd, (struct sockaddr *)&clientAddr, &addrlen); - - if (connFd < 3) { + connFd = (int)accept(pServer->fd, (struct sockaddr *)&clientAddr, &addrlen); + if (connFd == -1) { + if (errno == EINVAL) { + httpTrace("%s HTTP server socket was shutdown, exiting...", pServer->label); + break; + } httpError("http server:%s, accept connect failure, errno:%d, reason:%s", pServer->label, errno, strerror(errno)); continue; } @@ -579,7 +598,6 @@ void httpAcceptHttpConnection(void *arg) { pThread->pHead = pContext; pThread->numOfFds++; - pthread_cond_signal(&pThread->fdReady); pthread_mutex_unlock(&(pThread->threadMutex)); @@ -587,6 +605,9 @@ void httpAcceptHttpConnection(void *arg) { threadId++; threadId = threadId % pServer->numOfThreads; } + + close(pServer->fd); + return NULL; } bool httpInitConnect(HttpServer *pServer) { @@ -612,11 +633,6 @@ bool httpInitConnect(HttpServer *pServer) { return false; } - if (pthread_cond_init(&(pThread->fdReady), NULL) != 0) { - httpError("http thread:%s, init HTTP condition variable failed, reason:%s", pThread->label, strerror(errno)); - return false; - } - pThread->pollFd = epoll_create(HTTP_MAX_EVENTS); // size does not matter if (pThread->pollFd < 0) { httpError("http thread:%s, failed to create HTTP epoll", pThread->label); diff --git a/src/plugins/mqtt/CMakeLists.txt b/src/plugins/mqtt/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6224a0cad4471bbf15157cf9b9b3b0455440853f --- /dev/null +++ b/src/plugins/mqtt/CMakeLists.txt @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) + INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc) + INCLUDE_DIRECTORIES(inc) + AUX_SOURCE_DIRECTORY(src SRC) + ADD_LIBRARY(mqtt ${SRC}) + TARGET_LINK_LIBRARIES(mqtt taos_static z) + + IF (TD_ADMIN) + TARGET_LINK_LIBRARIES(mqtt admin) + ENDIF () +ENDIF () diff --git a/src/plugins/mqtt/inc/mqttLog.h b/src/plugins/mqtt/inc/mqttLog.h new file mode 100644 index 0000000000000000000000000000000000000000..735678a326c0842c1c3084ad203255991a0e3615 --- /dev/null +++ b/src/plugins/mqtt/inc/mqttLog.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_MQTT_LOG_H +#define TDENGINE_MQTT_LOG_H + +#include "tlog.h" + +extern int32_t mqttDebugFlag; + +#define mqttError(...) \ + if (mqttDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("ERROR MQT ", 255, __VA_ARGS__); \ + } +#define mqttWarn(...) \ + if ( mqttDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttTrace(...) \ + if ( mqttDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttDump(...) \ + if ( mqttDebugFlag & DEBUG_TRACE) { \ + taosPrintLongString("MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttPrint(...) \ + { taosPrintLog("MQT ", 255, __VA_ARGS__); } + +#endif diff --git a/src/plugins/mqtt/inc/mqttSystem.h b/src/plugins/mqtt/inc/mqttSystem.h new file mode 100644 index 0000000000000000000000000000000000000000..c61318806d0adc65ce19eb42d36e42a53c015918 --- /dev/null +++ b/src/plugins/mqtt/inc/mqttSystem.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_MQTT_SYSTEM_H +#define TDENGINE_MQTT_SYSTEM_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int32_t mqttGetReqCount(); +int32_t mqttInitSystem(); +int32_t mqttStartSystem(); +void mqttStopSystem(); +void mqttCleanUpSystem(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c new file mode 100644 index 0000000000000000000000000000000000000000..ccf6cfb3e34844eea95c48f774f9202794f6a3fa --- /dev/null +++ b/src/plugins/mqtt/src/mqttSystem.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mqttSystem.h" +#include "mqtt.h" +#include "mqttLog.h" +#include "os.h" +#include "taos.h" +#include "tglobal.h" +#include "tsocket.h" +#include "ttimer.h" + +int32_t mqttGetReqCount() { return 0; } +int mqttInitSystem() { + mqttPrint("mqttInitSystem"); + return 0; +} + +int mqttStartSystem() { + mqttPrint("mqttStartSystem"); + return 0; +} + +void mqttStopSystem() { + mqttPrint("mqttStopSystem"); +} + +void mqttCleanUpSystem() { + mqttPrint("mqttCleanUpSystem"); +} diff --git a/src/query/inc/queryExecutor.h b/src/query/inc/qExecutor.h similarity index 96% rename from src/query/inc/queryExecutor.h rename to src/query/inc/qExecutor.h index 991b3b73f7d7820dc5d292f95a815e734cfdb64b..3f4618bf1cff651af09efaf6c20f55958b8f1e74 100644 --- a/src/query/inc/queryExecutor.h +++ b/src/query/inc/qExecutor.h @@ -18,20 +18,20 @@ #include "os.h" #include "hash.h" -#include "tsdb.h" -#include "qinterpolation.h" +#include "qfill.h" #include "qresultBuf.h" #include "qsqlparser.h" #include "qtsbuf.h" #include "taosdef.h" +#include "tarray.h" #include "tref.h" +#include "tsdb.h" #include "tsqlfunction.h" -#include "tarray.h" -typedef struct SData { - int32_t num; - char data[]; -} SData; +//typedef struct tFilePage { +// int64_t num; +// char data[]; +//} tFilePage; struct SColumnFilterElem; typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2); @@ -129,7 +129,7 @@ typedef struct SQuery { char slidingTimeUnit; // interval data type, used for daytime revise int8_t precision; int16_t numOfOutput; - int16_t interpoType; + int16_t fillType; int16_t checkBuffer; // check if the buffer is full during scan each block SLimitVal limit; int32_t rowSize; @@ -139,11 +139,10 @@ typedef struct SQuery { SColumnInfo* tagColList; int32_t numOfFilterCols; int64_t* defaultVal; -// TSKEY lastKey; uint32_t status; // query status SResultRec rec; int32_t pos; - SData** sdata; + tFilePage** sdata; STableQueryInfo* current; SSingleColumnFilterInfo* pFilterInfo; } SQuery; @@ -151,12 +150,11 @@ typedef struct SQuery { typedef struct SQueryRuntimeEnv { SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo SQuery* pQuery; - SData** pInterpoBuf; SQLFunctionCtx* pCtx; int16_t numOfRowsPerPage; int16_t offset[TSDB_MAX_COLUMNS]; uint16_t scanFlag; // denotes reversed scan of data or not - SInterpolationInfo interpoInfo; + SFillInfo* pFillInfo; SWindowResInfo windowResInfo; STSBuf* pTSBuf; STSCursor cur; diff --git a/src/query/inc/queryUtil.h b/src/query/inc/qUtil.h similarity index 100% rename from src/query/inc/queryUtil.h rename to src/query/inc/qUtil.h diff --git a/src/query/inc/qextbuffer.h b/src/query/inc/qextbuffer.h index 9389e5a5ab9d9eb603866ff3bb97c183423666c8..0d608f1f1bbc3515db461f5ee5c98bfe324a073f 100644 --- a/src/query/inc/qextbuffer.h +++ b/src/query/inc/qextbuffer.h @@ -68,7 +68,7 @@ typedef struct SExtFileInfo { } SExtFileInfo; typedef struct tFilePage { - uint64_t numOfElems; + uint64_t num; char data[]; } tFilePage; diff --git a/src/query/inc/qfill.h b/src/query/inc/qfill.h new file mode 100644 index 0000000000000000000000000000000000000000..d0ba8941b215f4de141e4914b52a4cf482b4d27e --- /dev/null +++ b/src/query/inc/qfill.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_QFILL_H +#define TDENGINE_QFILL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "os.h" +#include "taosdef.h" +#include "qextbuffer.h" + +typedef struct { + STColumn col; // column info + int16_t functionId; // sql function id + int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN + union {int64_t i; double d;} defaultVal; +} SFillColInfo; + +typedef struct SFillInfo { + TSKEY start; // start timestamp + TSKEY endKey; // endKey for fill + int32_t order; // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC] + int32_t fillType; // fill type + int32_t numOfRows; // number of rows in the input data block + int32_t rowIdx; // rowIdx + int32_t numOfTotal; // number of filled rows in one round + int32_t numOfCurrent; // number of filled rows in current results + + int32_t numOfTags; // number of tags + int32_t numOfCols; // number of columns, including the tags columns + int32_t rowSize; // size of each row + char ** pTags; // tags value for current interpolation + + int64_t slidingTime; // sliding value to determine the number of result for a given time window + char * prevValues; // previous row of data, to generate the interpolation results + char * nextValues; // next row of data + SFillColInfo* pFillCol; // column info for fill operations + char** pData; // original result data block involved in filling data +} SFillInfo; + +typedef struct SPoint { + int64_t key; + void * val; +} SPoint; + +int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, char timeUnit, int16_t precision); + +SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, + int32_t numOfCols, int64_t slidingTime, int32_t fillType, SFillColInfo* pFillCol); + +void taosResetFillInfo(SFillInfo* pFillInfo, TSKEY startTimestamp); + +void taosDestoryFillInfo(SFillInfo *pFillInfo); + +void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey); + +void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput); + +void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInput); + +TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision); + +int32_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows); + +int32_t taosNumOfRemainRows(SFillInfo *pFillInfo); + +int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numOfRows, int32_t outputRows, char** srcData); + +int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point); + +void taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int64_t* outputRows, int32_t capacity); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_QFILL_H diff --git a/src/query/inc/qinterpolation.h b/src/query/inc/qinterpolation.h deleted file mode 100644 index c8ebd850b61cdc69e5816837d5a439a10ba99e43..0000000000000000000000000000000000000000 --- a/src/query/inc/qinterpolation.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_TINTERPOLATION_H -#define TDENGINE_TINTERPOLATION_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "os.h" -#include "taosdef.h" -#include "qextbuffer.h" - -typedef struct SInterpolationInfo { - int64_t startTimestamp; - int32_t order; // order [asc/desc] - int32_t numOfRawDataInRows; // number of points in pQuery->sdata - int32_t rowIdx; // rowIdx in pQuery->sdata - int32_t numOfTotalInterpo; // number of interpolated rows in one round - int32_t numOfCurrentInterpo; // number of interpolated rows in current results - char * prevValues; // previous row of data - char * nextValues; // next row of data - int32_t numOfTags; - char ** pTags; // tags value for current interoplation -} SInterpolationInfo; - -typedef struct SPoint { - int64_t key; - void * val; -} SPoint; - -int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char intervalTimeUnit, int16_t precision); - -void taosInitInterpoInfo(SInterpolationInfo *pInterpoInfo, int32_t order, int64_t startTimeStamp, int32_t numOfTags, - int32_t rowSize); - -void taosDestoryInterpoInfo(SInterpolationInfo *pInterpoInfo); - -void taosInterpoSetStartInfo(SInterpolationInfo *pInterpoInfo, int32_t numOfRawDataInRows, int32_t type); - -TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int32_t timeInterval, int8_t intervalTimeUnit, int8_t precision); - -/** - * - * @param pInterpoInfo - * @param pPrimaryKeyArray - * @param numOfRows - * @param nInterval - * @param ekey - * @param maxNumOfRows - * @return - */ -int32_t taosGetNumOfResultWithInterpo(SInterpolationInfo *pInterpoInfo, int64_t *pPrimaryKeyArray, int32_t numOfRows, - int64_t nInterval, int64_t ekey, int32_t maxNumOfRows); - -int32_t taosGetNumOfResWithoutLimit(SInterpolationInfo *pInterpoInfo, int64_t *pPrimaryKeyArray, - int32_t numOfRawDataInRows, int64_t nInterval, int64_t ekey); -/** - * - * @param pInterpoInfo - * @return - */ -bool taosHasRemainsDataForInterpolation(SInterpolationInfo *pInterpoInfo); - -int32_t taosNumOfRemainPoints(SInterpolationInfo *pInterpoInfo); - -/** - * - */ -int32_t taosDoInterpoResult(SInterpolationInfo *pInterpoInfo, int16_t interpoType, tFilePage **data, - int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval, - const int64_t *pPrimaryKeyArray, SColumnModel *pModel, char **srcData, int64_t *defaultVal, - const int32_t *functionIDs, int32_t bufSize); - -int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point); - -#ifdef __cplusplus -} -#endif - -#endif // TDENGINE_TINTERPOLATION_H diff --git a/src/query/inc/queryLog.h b/src/query/inc/queryLog.h index 4894d67e0415d57ceb7bd3fed6499cd4fad1658c..32338a4143ef63495235b8ac0da19661654cd9a3 100644 --- a/src/query/inc/queryLog.h +++ b/src/query/inc/queryLog.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_RPC_LOG_H -#define TDENGINE_RPC_LOG_H +#ifndef TDENGINE_QUERY_LOG_H +#define TDENGINE_QUERY_LOG_H #ifdef __cplusplus extern "C" { @@ -24,22 +24,23 @@ extern "C" { extern int32_t qDebugFlag; -#define qTrace(...) \ - if (qDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("DND QRY ", qDebugFlag, __VA_ARGS__); \ +#define qTrace(...) \ + if (qDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); \ } -#define qError(...) \ - if (qDebugFlag & DEBUG_ERROR) { \ +#define qError(...) \ + if (qDebugFlag & DEBUG_ERROR) { \ taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); \ } -#define qWarn(...) \ - if (qDebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); \ - } + +#define qWarn(...) \ + if (qDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); \ + } #ifdef __cplusplus } #endif -#endif // TDENGINE_RPC_CACHE_H +#endif // TDENGINE_QUERY_CACHE_H diff --git a/src/query/inc/tlosertree.h b/src/query/inc/tlosertree.h index 197d27a76126097f23cfc47a227957301f5b2c5c..4c731625dd5c7950c321b2180ca913e49362059b 100644 --- a/src/query/inc/tlosertree.h +++ b/src/query/inc/tlosertree.h @@ -32,7 +32,7 @@ typedef struct SLoserTreeNode { typedef struct SLoserTreeInfo { int32_t numOfEntries; int32_t totalEntries; - __merge_compare_fn_t comparaFn; + __merge_compare_fn_t comparFn; void * param; SLoserTreeNode *pNode; diff --git a/src/query/src/queryExecutor.c b/src/query/src/qExecutor.c similarity index 93% rename from src/query/src/queryExecutor.c rename to src/query/src/qExecutor.c index ef6ff8a70bf3cb9ba08fa63e34b29bdfaa7693f4..052273a90cfd539eb36b9bea55dd7943d1a6a495 100644 --- a/src/query/src/queryExecutor.c +++ b/src/query/src/qExecutor.c @@ -12,22 +12,23 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#include #include "os.h" #include "hash.h" #include "hashfunc.h" +#include "qExecutor.h" +#include "qUtil.h" #include "qast.h" #include "qresultBuf.h" #include "query.h" -#include "queryExecutor.h" #include "queryLog.h" -#include "queryUtil.h" #include "taosmsg.h" +#include "tdataformat.h" #include "tlosertree.h" +#include "tscUtil.h" // todo move the function to common module #include "tscompression.h" #include "ttime.h" -#include "tscUtil.h" // todo move the function to common module -#include "tdataformat.h" #define DEFAULT_INTERN_BUF_SIZE 16384L @@ -96,7 +97,9 @@ typedef struct { STSCursor cur; } SQueryStatusInfo; +#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st))) static void setQueryStatus(SQuery *pQuery, int8_t status); + static bool isIntervalQuery(SQuery *pQuery) { return pQuery->intervalTime > 0; } // todo move to utility @@ -277,6 +280,26 @@ int64_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv) { return maxOutput; } +/* + * the value of number of result needs to be update due to offset value upated. + */ +void updateNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOfRes) { + SQuery *pQuery = pRuntimeEnv->pQuery; + + for (int32_t j = 0; j < pQuery->numOfOutput; ++j) { + SResultInfo *pResInfo = GET_RES_INFO(&pRuntimeEnv->pCtx[j]); + + int16_t functionId = pRuntimeEnv->pCtx[j].functionId; + if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TAGPRJ || + functionId == TSDB_FUNC_TS_DUMMY) { + continue; + } + + assert(pResInfo->numOfRes > numOfRes); + pResInfo->numOfRes = numOfRes; + } +} + static int32_t getGroupResultId(int32_t groupIndex) { int32_t base = 200000; return base + (groupIndex * 10000); @@ -353,9 +376,7 @@ bool isSelectivityWithTagsQuery(SQuery *pQuery) { bool isTSCompQuery(SQuery *pQuery) { return pQuery->pSelectExpr[0].base.functionId == TSDB_FUNC_TS_COMP; } -static bool limitResults(SQInfo *pQInfo) { - SQuery *pQuery = pQInfo->runtimeEnv.pQuery; - +static bool limitResults(SQuery *pQuery) { if ((pQuery->limit.limit > 0) && (pQuery->rec.total + pQuery->rec.rows > pQuery->limit.limit)) { pQuery->rec.rows = pQuery->limit.limit - pQuery->rec.total; assert(pQuery->rec.rows > 0); @@ -529,10 +550,10 @@ static int32_t addNewWindowResultBuf(SWindowResult *pWindowRes, SDiskbasedResult pageId = getLastPageId(&list); pData = getResultBufferPageById(pResultBuf, pageId); - if (pData->numOfElems >= numOfRowsPerPage) { + if (pData->num >= numOfRowsPerPage) { pData = getNewDataBuf(pResultBuf, sid, &pageId); if (pData != NULL) { - assert(pData->numOfElems == 0); // number of elements must be 0 for new allocated buffer + assert(pData->num == 0); // number of elements must be 0 for new allocated buffer } } } @@ -544,7 +565,7 @@ static int32_t addNewWindowResultBuf(SWindowResult *pWindowRes, SDiskbasedResult // set the number of rows in current disk page if (pWindowRes->pos.pageId == -1) { // not allocated yet, allocate new buffer pWindowRes->pos.pageId = pageId; - pWindowRes->pos.rowId = pData->numOfElems++; + pWindowRes->pos.rowId = pData->num++; } return 0; @@ -625,6 +646,7 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, int32_t i = 0; int64_t skey = TSKEY_INITIAL_VAL; + // TODO opt performance: get the closed time window here for (i = 0; i < pWindowResInfo->size; ++i) { SWindowResult *pResult = &pWindowResInfo->pResult[i]; if (pResult->status.closed) { @@ -1202,9 +1224,9 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS while (1) { getNextTimeWindow(pQuery, &nextWin); - if (pWindowResInfo->startTime > nextWin.skey || + if (/*pWindowResInfo->startTime > nextWin.skey ||*/ (nextWin.skey > pQuery->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) || - (nextWin.skey > pQuery->window.skey && !QUERY_IS_ASC_QUERY(pQuery))) { + (nextWin.skey < pQuery->window.ekey && !QUERY_IS_ASC_QUERY(pQuery))) { break; } @@ -1302,6 +1324,10 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl if (numOfRes >= pQuery->rec.threshold) { setQueryStatus(pQuery, QUERY_RESBUF_FULL); } + + if ((pQuery->limit.limit >= 0) && numOfRes >= (pQuery->limit.limit + pQuery->limit.offset)) { + setQueryStatus(pQuery, QUERY_COMPLETED); + } } return numOfRes; @@ -1334,7 +1360,6 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY // last_dist or first_dist function // store the first&last timestamp into the intermediate buffer [1], the true // value may be null but timestamp will never be null - // pCtx->ptsList = tsCol; } else if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_TWA || functionId == TSDB_FUNC_DIFF || (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) { /* @@ -1415,7 +1440,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order pRuntimeEnv->pCtx = (SQLFunctionCtx *)calloc(pQuery->numOfOutput, sizeof(SQLFunctionCtx)); if (pRuntimeEnv->resultInfo == NULL || pRuntimeEnv->pCtx == NULL) { - goto _error_clean; + goto _clean; } pRuntimeEnv->offset[0] = 0; @@ -1427,7 +1452,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order int32_t index = pSqlFuncMsg->colInfo.colIndex; if (TSDB_COL_IS_TAG(pIndex->flag)) { - if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { + if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { // todo refactor pCtx->inputBytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE; pCtx->inputType = TSDB_DATA_TYPE_BINARY; } else { @@ -1489,7 +1514,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order setCtxTagColumnInfo(pQuery, pRuntimeEnv->pCtx); return TSDB_CODE_SUCCESS; -_error_clean: +_clean: tfree(pRuntimeEnv->resultInfo); tfree(pRuntimeEnv->pCtx); @@ -1524,15 +1549,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { tfree(pRuntimeEnv->pCtx); } - taosDestoryInterpoInfo(&pRuntimeEnv->interpoInfo); - - if (pRuntimeEnv->pInterpoBuf != NULL) { - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - tfree(pRuntimeEnv->pInterpoBuf[i]); - } - - tfree(pRuntimeEnv->pInterpoBuf); - } + taosDestoryFillInfo(pRuntimeEnv->pFillInfo); destroyResultBuf(pRuntimeEnv->pResultBuf, pQInfo); tsdbCleanupQueryHandle(pRuntimeEnv->pQueryHandle); @@ -1975,7 +1992,7 @@ void pointInterpSupporterSetData(SQInfo *pQInfo, SPointInterpoSupporter *pPointI // set the direct previous(next) point for process count = 2; - if (pQuery->interpoType == TSDB_INTERPO_SET_VALUE) { + if (pQuery->fillType == TSDB_FILL_SET_VALUE) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; @@ -2005,7 +2022,7 @@ void pointInterpSupporterSetData(SQInfo *pQInfo, SPointInterpoSupporter *pPointI } pInterpDetail->ts = pQuery->window.skey; - pInterpDetail->type = pQuery->interpoType; + pInterpDetail->type = pQuery->fillType; } } else { TSKEY prevKey = *(TSKEY *)pPointInterpSupport->pPrevPoint[0]; @@ -2040,7 +2057,7 @@ void pointInterpSupporterSetData(SQInfo *pQInfo, SPointInterpoSupporter *pPointI tVariantCreateFromBinary(&pRuntimeEnv->pCtx[i].param[3], (char *)&count, sizeof(count), TSDB_DATA_TYPE_INT); pInterpDetail->ts = pQInfo->runtimeEnv.pQuery->window.skey; - pInterpDetail->type = pQuery->interpoType; + pInterpDetail->type = pQuery->fillType; } } } @@ -2094,23 +2111,6 @@ void pointInterpSupporterDestroy(SPointInterpoSupporter *pPointInterpSupport) { #endif } -static UNUSED_FUNC void allocMemForInterpo(SQInfo *pQInfo, SQuery *pQuery, void *pMeterObj) { -#if 0 - if (pQuery->interpoType != TSDB_INTERPO_NONE) { - assert(isIntervalQuery(pQuery) || (pQuery->intervalTime == 0 && isPointInterpoQuery(pQuery))); - - if (isIntervalQuery(pQuery)) { - pQInfo->runtimeEnv.pInterpoBuf = malloc(POINTER_BYTES * pQuery->numOfOutput); - - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - pQInfo->runtimeEnv.pInterpoBuf[i] = - calloc(1, sizeof(tFilePage) + pQuery->pSelectExpr[i].bytes * pMeterObj->pointsPerFileBlock); - } - } - } -#endif -} - static int32_t getInitialPageNum(SQInfo *pQInfo) { SQuery *pQuery = pQInfo->runtimeEnv.pQuery; int32_t INITIAL_RESULT_ROWS_VALUE = 16; @@ -2396,7 +2396,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pQueryHandle); // todo extract methods - if (isIntervalQuery(pQuery) && pRuntimeEnv->windowResInfo.prevSKey == 0) { + if (isIntervalQuery(pQuery) && pRuntimeEnv->windowResInfo.prevSKey == TSKEY_INITIAL_VAL) { TSKEY skey1, ekey1; STimeWindow w = TSWINDOW_INITIALIZER; SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo; @@ -2414,6 +2414,10 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { pWindowResInfo->startTime = pQuery->window.skey; pWindowResInfo->prevSKey = w.skey; } + + if (pRuntimeEnv->pFillInfo != NULL) { + pRuntimeEnv->pFillInfo->start = w.skey; + } } // in case of prj/diff query, ensure the output buffer is sufficient to accommodate the results of current block @@ -2427,10 +2431,11 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t bytes = pQuery->pSelectExpr[i].bytes; - char *tmp = realloc(pQuery->sdata[i], bytes * newSize + sizeof(SData)); + char *tmp = realloc(pQuery->sdata[i], bytes * newSize + sizeof(tFilePage)); if (tmp == NULL) { // todo handle the oom + assert(0); } else { - pQuery->sdata[i] = (SData *)tmp; + pQuery->sdata[i] = (tFilePage *)tmp; } // set the pCtx output buffer position @@ -2442,7 +2447,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { } } - qTrace("QInfo: %p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv), newSize, pRec->capacity, newSize - pRec->rows); pRec->capacity = newSize; @@ -2455,11 +2460,11 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1; int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock); - qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, numOfRes:%d", GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes); - // save last access position - if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) { + // while the output buffer is full or limit/offset is applied, query may be paused here + if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL | QUERY_COMPLETED)) { break; } } @@ -2648,7 +2653,7 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t } } -void UNUSED_FUNC displayInterResult(SData **pdata, SQueryRuntimeEnv* pRuntimeEnv, int32_t numOfRows) { +void UNUSED_FUNC displayInterResult(tFilePage **pdata, SQueryRuntimeEnv* pRuntimeEnv, int32_t numOfRows) { SQuery* pQuery = pRuntimeEnv->pQuery; int32_t numOfCols = pQuery->numOfOutput; printf("super table query intermediate result, total:%d\n", numOfRows); @@ -2787,7 +2792,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) { int32_t total = 0; for (int32_t i = 0; i < list.size; ++i) { tFilePage *pData = getResultBufferPageById(pResultBuf, list.pData[i]); - total += pData->numOfElems; + total += pData->num; } int32_t rows = total; @@ -2800,11 +2805,11 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) { int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes; char * pDest = pQuery->sdata[i]->data; - memcpy(pDest + offset * bytes, pData->data + pRuntimeEnv->offset[i] * pData->numOfElems, - bytes * pData->numOfElems); + memcpy(pDest + offset * bytes, pData->data + pRuntimeEnv->offset[i] * pData->num, + bytes * pData->num); } - offset += pData->numOfElems; + offset += pData->num; } assert(pQuery->rec.rows == 0); @@ -2907,7 +2912,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { if (ts == lastTimestamp) { // merge with the last one doMerge(pRuntimeEnv, ts, pWindowRes, true); } else { // copy data to disk buffer - if (buffer[0]->numOfElems == pQuery->rec.capacity) { + if (buffer[0]->num == pQuery->rec.capacity) { if (flushFromResultBuf(pQInfo) != TSDB_CODE_SUCCESS) { return -1; } @@ -2916,7 +2921,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { } doMerge(pRuntimeEnv, ts, pWindowRes, false); - buffer[0]->numOfElems += 1; + buffer[0]->num += 1; } lastTimestamp = ts; @@ -2935,7 +2940,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { tLoserTreeAdjust(pTree, pos + pTree->numOfEntries); } - if (buffer[0]->numOfElems != 0) { // there are data in buffer + if (buffer[0]->num != 0) { // there are data in buffer if (flushFromResultBuf(pQInfo) != TSDB_CODE_SUCCESS) { qError("QInfo:%p failed to flush data into temp file, abort query", pQInfo); @@ -2993,10 +2998,10 @@ int32_t flushFromResultBuf(SQInfo *pQInfo) { // pagewise copy to dest buffer for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes; - buf->numOfElems = r; + buf->num = r; - memcpy(buf->data + pRuntimeEnv->offset[i] * buf->numOfElems, ((char *)pQuery->sdata[i]->data) + offset * bytes, - buf->numOfElems * bytes); + memcpy(buf->data + pRuntimeEnv->offset[i] * buf->num, ((char *)pQuery->sdata[i]->data) + offset * bytes, + buf->num * bytes); } offset += r; @@ -3025,11 +3030,13 @@ static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo * // order has change already! int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); - if (!QUERY_IS_ASC_QUERY(pQuery)) { - assert(pTableQueryInfo->win.ekey >= pTableQueryInfo->lastKey + step); - } else { - assert(pTableQueryInfo->win.ekey <= pTableQueryInfo->lastKey + step); - } + + // TODO validate the assertion +// if (!QUERY_IS_ASC_QUERY(pQuery)) { +// assert(pTableQueryInfo->win.ekey >= pTableQueryInfo->lastKey + step); +// } else { +// assert(pTableQueryInfo->win.ekey <= pTableQueryInfo->lastKey + step); +// } pTableQueryInfo->win.ekey = pTableQueryInfo->lastKey + step; @@ -3108,7 +3115,7 @@ void disableFuncInReverseScan(SQInfo *pQInfo) { void switchCtxOrder(SQueryRuntimeEnv *pRuntimeEnv) { SQuery *pQuery = pRuntimeEnv->pQuery; for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - SWITCH_ORDER(pRuntimeEnv->pCtx[i] .order); + SWITCH_ORDER(pRuntimeEnv->pCtx[i].order); } } @@ -3194,30 +3201,38 @@ void skipResults(SQueryRuntimeEnv *pRuntimeEnv) { } if (pQuery->rec.rows <= pQuery->limit.offset) { + qTrace("QInfo:%p skip rows:%d, new offset:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.rows, + pQuery->limit.offset - pQuery->rec.rows); + pQuery->limit.offset -= pQuery->rec.rows; pQuery->rec.rows = 0; resetCtxOutputBuf(pRuntimeEnv); - // clear the buffer is full flag if exists - pQuery->status &= (~QUERY_RESBUF_FULL); + // clear the buffer full flag if exists + CLEAR_QUERY_STATUS(pQuery, QUERY_RESBUF_FULL); } else { - int32_t numOfSkip = (int32_t) pQuery->limit.offset; + int64_t numOfSkip = pQuery->limit.offset; pQuery->rec.rows -= numOfSkip; - + pQuery->limit.offset = 0; + + qTrace("QInfo:%p skip row:%"PRId64", new offset:%d, numOfRows remain:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), numOfSkip, + 0, pQuery->rec.rows); + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t functionId = pQuery->pSelectExpr[i].base.functionId; int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes; - memmove(pQuery->sdata[i]->data, pQuery->sdata[i]->data + bytes * numOfSkip, pQuery->rec.rows * bytes); - pRuntimeEnv->pCtx[i].aOutputBuf += bytes * numOfSkip; + memmove(pQuery->sdata[i]->data, (char*) pQuery->sdata[i]->data + bytes * numOfSkip, pQuery->rec.rows * bytes); + pRuntimeEnv->pCtx[i].aOutputBuf = ((char*) pQuery->sdata[i]->data) + pQuery->rec.rows * bytes; if (functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { - pRuntimeEnv->pCtx[i].ptsOutputBuf += TSDB_KEYSIZE * numOfSkip; + pRuntimeEnv->pCtx[i].ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; } } - - pQuery->limit.offset = 0; + + + updateNumOfResult(pRuntimeEnv, pQuery->rec.rows); } } @@ -3226,7 +3241,7 @@ void setQueryStatus(SQuery *pQuery, int8_t status) { pQuery->status = status; } else { // QUERY_NOT_COMPLETED is not compatible with any other status, so clear its position first - pQuery->status &= (~QUERY_NOT_COMPLETED); + CLEAR_QUERY_STATUS(pQuery, QUERY_NOT_COMPLETED); pQuery->status |= status; } } @@ -3276,16 +3291,19 @@ bool needScanDataBlocksAgain(SQueryRuntimeEnv *pRuntimeEnv) { return toContinue; } -static SQueryStatusInfo getQueryStatusInfo(SQueryRuntimeEnv *pRuntimeEnv) { +static SQueryStatusInfo getQueryStatusInfo(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { SQuery *pQuery = pRuntimeEnv->pQuery; STableQueryInfo* pTableQueryInfo = pQuery->current; + assert((start <= pTableQueryInfo->lastKey && QUERY_IS_ASC_QUERY(pQuery)) || + (start >= pTableQueryInfo->lastKey && !QUERY_IS_ASC_QUERY(pQuery))); + SQueryStatusInfo info = { .status = pQuery->status, .windowIndex = pRuntimeEnv->windowResInfo.curIndex, - .lastKey = pTableQueryInfo->lastKey, + .lastKey = start, .w = pQuery->window, - .curWindow = {.skey = pTableQueryInfo->lastKey, .ekey = pTableQueryInfo->win.ekey}, + .curWindow = {.skey = start, .ekey = pTableQueryInfo->win.ekey}, }; return info; @@ -3348,7 +3366,7 @@ static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatus pTableQueryInfo->win = pStatus->w; } -void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { +void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { SQInfo *pQInfo = (SQInfo *) GET_QINFO_ADDR(pRuntimeEnv); SQuery *pQuery = pRuntimeEnv->pQuery; STableQueryInfo *pTableQueryInfo = pQuery->current; @@ -3356,7 +3374,7 @@ void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { setQueryStatus(pQuery, QUERY_NOT_COMPLETED); // store the start query position - SQueryStatusInfo qstatus = getQueryStatusInfo(pRuntimeEnv); + SQueryStatusInfo qstatus = getQueryStatusInfo(pRuntimeEnv, start); SET_MASTER_SCAN_FLAG(pRuntimeEnv); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); @@ -3534,7 +3552,7 @@ void setExecutionContext(SQInfo *pQInfo, STableId* pTableId, int32_t groupIdx, T static void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult) { SQuery *pQuery = pRuntimeEnv->pQuery; - // Note: pResult->pos[i]->numOfElems == 0, there is only fixed number of results for each group + // Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult); @@ -3788,80 +3806,43 @@ void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo updateWindowResNumOfRes(pRuntimeEnv, pTableQueryInfo); } -bool vnodeHasRemainResults(void *handle) { - SQInfo *pQInfo = (SQInfo *)handle; - - if (pQInfo == NULL || pQInfo->runtimeEnv.pQuery->interpoType == TSDB_INTERPO_NONE) { +bool queryHasRemainResults(SQueryRuntimeEnv* pRuntimeEnv) { + SQuery *pQuery = pRuntimeEnv->pQuery; + SFillInfo *pFillInfo = pRuntimeEnv->pFillInfo; + + if (pQuery->fillType == TSDB_FILL_NONE) { + assert(pFillInfo == NULL); return false; } - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - - SInterpolationInfo *pInterpoInfo = &pRuntimeEnv->interpoInfo; if (pQuery->limit.limit > 0 && pQuery->rec.rows >= pQuery->limit.limit) { return false; } - int32_t remain = taosNumOfRemainPoints(pInterpoInfo); + // There are results not returned to client, fill operation applied to the remain result set in the + // first place is required. + int32_t remain = taosNumOfRemainRows(pFillInfo); if (remain > 0) { return true; - } else { - if (pRuntimeEnv->pInterpoBuf == NULL) { - return false; - } - - // query has completed - if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { - /*TSKEY ekey =*/taosGetRevisedEndKey(pQuery->window.ekey, pQuery->order.order, pQuery->intervalTime, - pQuery->slidingTimeUnit, pQuery->precision); - // int32_t numOfTotal = taosGetNumOfResultWithInterpo(pInterpoInfo, (TSKEY - // *)pRuntimeEnv->pInterpoBuf[0]->data, - // remain, pQuery->intervalTime, ekey, - // pQuery->pointsToRead); - // return numOfTotal > 0; - assert(0); - return false; - } - - return false; - } -} - -static UNUSED_FUNC int32_t resultInterpolate(SQInfo *pQInfo, tFilePage **data, tFilePage **pDataSrc, int32_t numOfRows, - int32_t outputRows) { -#if 0 - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery *pQuery = &pRuntimeEnv->pQuery; - - assert(pRuntimeEnv->pCtx[0].outputBytes == TSDB_KEYSIZE); - - // build support structure for performing interpolation - SSchema *pSchema = calloc(1, sizeof(SSchema) * pQuery->numOfOutput); - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - pSchema[i].bytes = pRuntimeEnv->pCtx[i].outputBytes; - pSchema[i].type = pQuery->pSelectExpr[i].type; } -// SColumnModel *pModel = createColumnModel(pSchema, pQuery->numOfOutput, pQuery->pointsToRead); - - char * srcData[TSDB_MAX_COLUMNS] = {0}; - int32_t functions[TSDB_MAX_COLUMNS] = {0}; - - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - srcData[i] = pDataSrc[i]->data; - functions[i] = pQuery->pSelectExpr[i].base.functionId; + /* + * There are no results returned to client now. + * If query is not completed yet, the gaps between two results blocks need to be handled after next data block + * is retrieved from TSDB. + * + * NOTE: If the result set is not the first block, the gap in front of the result set will be filled. If the result + * set is the FIRST result block, the gap between the start time of query time window and the timestamp of the + * first result row in the actual result set will fill nothing. + */ + if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { + TSKEY ekey = taosGetRevisedEndKey(pQuery->window.ekey, pQuery->order.order, pQuery->slidingTime, + pQuery->slidingTimeUnit, pQuery->precision); + int32_t numOfTotal = taosGetNumOfResultWithFill(pFillInfo, remain, ekey, pQuery->rec.capacity); + return numOfTotal > 0; } - - assert(0); -// int32_t numOfRes = taosDoInterpoResult(&pRuntimeEnv->interpoInfo, pQuery->interpoType, data, numOfRows, outputRows, -// pQuery->intervalTime, (int64_t *)pDataSrc[0]->data, pModel, srcData, -// pQuery->defaultVal, functions, pRuntimeEnv->pTabObj->pointsPerFileBlock); - - destroyColumnModel(pModel); - free(pSchema); -#endif - return 0; + + return false; } static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data) { @@ -3887,37 +3868,30 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data // all data returned, set query over if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { - if (pQInfo->runtimeEnv.stableQuery && isIntervalQuery(pQuery)) { + if (pQInfo->runtimeEnv.stableQuery) { if (pQInfo->tableIndex >= pQInfo->groupInfo.numOfTables) { setQueryStatus(pQuery, QUERY_OVER); } } else { - setQueryStatus(pQuery, QUERY_OVER); + if (!queryHasRemainResults(&pQInfo->runtimeEnv)) { + setQueryStatus(pQuery, QUERY_OVER); + } } } } -int32_t vnodeQueryResultInterpolate(SQInfo *pQInfo, tFilePage **pDst, tFilePage **pDataSrc, int32_t numOfRows, - int32_t *numOfInterpo) { -// SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; -// SQuery * pQuery = pRuntimeEnv->pQuery; -#if 0 +int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int32_t numOfRows, int32_t *numOfInterpo) { + SQuery *pQuery = pRuntimeEnv->pQuery; while (1) { - numOfRows = taosNumOfRemainPoints(&pRuntimeEnv->interpoInfo); - - TSKEY ekey = taosGetRevisedEndKey(pQuery->window.skey, pQuery->order.order, pQuery->intervalTime, - pQuery->slidingTimeUnit, pQuery->precision); - int32_t numOfFinalRows = taosGetNumOfResultWithInterpo(&pRuntimeEnv->interpoInfo, (TSKEY *)pDataSrc[0]->data, - numOfRows, pQuery->intervalTime, ekey, pQuery->pointsToRead); - - int32_t ret = resultInterpolate(pQInfo, pDst, pDataSrc, numOfRows, numOfFinalRows); - assert(ret == numOfFinalRows); + taosGenerateDataBlock(pRuntimeEnv->pFillInfo, (tFilePage**) pQuery->sdata, &pQuery->rec.rows, pQuery->rec.capacity); + int32_t ret = pQuery->rec.rows; + // todo apply limit output function /* reached the start position of according to offset value, return immediately */ if (pQuery->limit.offset == 0) { return ret; } - + if (pQuery->limit.offset < ret) { ret -= pQuery->limit.offset; // todo !!!!there exactly number of interpo is not valid. @@ -3932,13 +3906,12 @@ int32_t vnodeQueryResultInterpolate(SQInfo *pQInfo, tFilePage **pDst, tFilePage pQuery->limit.offset -= ret; ret = 0; } - - if (!vnodeHasRemainResults(pQInfo)) { + + if (!queryHasRemainResults(pRuntimeEnv)) { return ret; } } -#endif - + return 0; } @@ -4020,7 +3993,7 @@ static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBloc int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock); - qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, numOfRes:%d", GET_QINFO_ADDR(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes); } @@ -4049,7 +4022,7 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) { pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQuery)) ? blockInfo.window.ekey : blockInfo.window.skey; pTableQueryInfo->lastKey += step; - qTrace("QInfo:%p skip rows:%d, offset:%" PRId64 "", GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows, + qTrace("QInfo:%p skip rows:%d, offset:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows, pQuery->limit.offset); } else { // find the appropriated start position in current block updateOffsetVal(pRuntimeEnv, &blockInfo); @@ -4058,11 +4031,12 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) { } } -static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { +static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) { SQuery *pQuery = pRuntimeEnv->pQuery; + *start = pQuery->current->lastKey; // if queried with value filter, do NOT forward query start position - if (pQuery->limit.offset <= 0 || pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) { + if (pQuery->limit.offset <= 0 || pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || pRuntimeEnv->pFillInfo != NULL) { return true; } @@ -4082,13 +4056,14 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { while (tsdbNextDataBlock(pRuntimeEnv->pQueryHandle)) { SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pRuntimeEnv->pQueryHandle); - if (QUERY_IS_ASC_QUERY(pQuery) && pWindowResInfo->prevSKey == 0) { - getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &skey1, &ekey1, - &w); - pWindowResInfo->startTime = w.skey; - pWindowResInfo->prevSKey = w.skey; + if (QUERY_IS_ASC_QUERY(pQuery)) { + if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) { + getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &skey1, + &ekey1, &w); + pWindowResInfo->startTime = w.skey; + pWindowResInfo->prevSKey = w.skey; + } } else { - // the start position of the first time window in the endpoint that spreads beyond the queried last timestamp getAlignQueryTimeWindow(pQuery, blockInfo.window.ekey, pQuery->window.ekey, blockInfo.window.ekey, &skey1, &ekey1, &w); @@ -4112,7 +4087,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { if (pQuery->limit.offset == 0) { if ((tw.skey <= blockInfo.window.ekey && QUERY_IS_ASC_QUERY(pQuery)) || (tw.ekey >= blockInfo.window.skey && !QUERY_IS_ASC_QUERY(pQuery))) { - // load the data block + // load the data block and check data remaining in current data block + // TODO optimize performance SArray * pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pQueryHandle, NULL); SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); @@ -4123,24 +4099,38 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { // set the abort info pQuery->pos = startPos; - pTableQueryInfo->lastKey = ((TSKEY *)pColInfoData->pData)[startPos]; + + // reset the query start timestamp + pTableQueryInfo->win.skey = ((TSKEY *)pColInfoData->pData)[startPos]; + pQuery->window.skey = pTableQueryInfo->win.skey; + *start = pTableQueryInfo->win.skey; + pWindowResInfo->prevSKey = tw.skey; - + int32_t index = pRuntimeEnv->windowResInfo.curIndex; + int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, NULL, binarySearchForKey, pDataBlock); - - qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", + pRuntimeEnv->windowResInfo.curIndex = index; // restore the window index + + qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, numOfRes:%d", GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes); return true; - } else { - // do nothing, + } else { // do nothing + *start = tw.skey; + pQuery->window.skey = tw.skey; + pWindowResInfo->prevSKey = tw.skey; return true; } } - // next time window starts from current data block + /* + * If the next time window still starts from current data block, + * load the primary timestamp column first, and then find the start position for the next queried time window. + * Note that only the primary timestamp column is required. + * TODO: Optimize for this cases. All data blocks are not needed to be loaded, only if the first actually required + * time window resides in current data block. + */ if ((tw.skey <= blockInfo.window.ekey && QUERY_IS_ASC_QUERY(pQuery)) || (tw.ekey >= blockInfo.window.skey && !QUERY_IS_ASC_QUERY(pQuery))) { - // load the data block, note that only the primary timestamp column is required SArray * pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pQueryHandle, NULL); SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); @@ -4155,7 +4145,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { pWindowResInfo->prevSKey = tw.skey; win = tw; } else { - break; // offset is not 0, and next time window locates in the next block. + break; // offset is not 0, and next time window begins or ends in the next block. } } } @@ -4195,10 +4185,35 @@ static void setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { cond.twindow = pItem->info->win; } - pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableIdGroupInfo); + if (isFirstLastRowQuery(pQuery)) { + pRuntimeEnv->pQueryHandle = tsdbQueryLastRow(tsdb, &cond, &pQInfo->tableIdGroupInfo); + } else { + pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableIdGroupInfo); + } } +static SFillColInfo* taosCreateFillColInfo(SQuery* pQuery) { + int32_t numOfCols = pQuery->numOfOutput; + int32_t offset = 0; + + SFillColInfo* pFillCol = calloc(numOfCols, sizeof(SFillColInfo)); + for(int32_t i = 0; i < numOfCols; ++i) { + SExprInfo* pExprInfo = &pQuery->pSelectExpr[i]; + + pFillCol[i].col.bytes = pExprInfo->bytes; + pFillCol[i].col.type = pExprInfo->type; + pFillCol[i].col.offset = offset; + pFillCol[i].flag = TSDB_COL_NORMAL; // always be ta normal column for table query + pFillCol[i].functionId = pExprInfo->base.functionId; + pFillCol[i].defaultVal.i = pQuery->defaultVal[i]; + + offset += pExprInfo->bytes; + } + + return pFillCol; +} + int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool isSTableQuery) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; @@ -4290,16 +4305,12 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool // pointInterpSupporterSetData(pQInfo, &interpInfo); // pointInterpSupporterDestroy(&interpInfo); -// int64_t rs = taosGetIntervalStartTimestamp(pQuery->window.skey, pQuery->intervalTime, pQuery->slidingTimeUnit, -// pQuery->precision); -// taosInitInterpoInfo(&pRuntimeEnv->interpoInfo, pQuery->order.order, rs, 0, 0); - // allocMemForInterpo(pQInfo, pQuery, pMeterObj); - -// if (!isPointInterpoQuery(pQuery)) { - // assert(pQuery->pos >= 0 && pQuery->slot >= 0); -// } - - // the pQuery->window.skey is changed during normalizedFirstQueryRange, so set the newest lastkey value + if (pQuery->fillType != TSDB_FILL_NONE) { + SFillColInfo* pColInfo = taosCreateFillColInfo(pQuery); + pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, 0, 0, pQuery->rec.capacity, pQuery->numOfOutput, + pQuery->slidingTime, pQuery->fillType, pColInfo); + } + return TSDB_CODE_SUCCESS; } @@ -4375,10 +4386,11 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) { SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis); - TSKEY nextKey = blockInfo.window.skey; if (!isIntervalQuery(pQuery)) { - setExecutionContext(pQInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIdx, nextKey); + int32_t step = QUERY_IS_ASC_QUERY(pQuery)? 1:-1; + setExecutionContext(pQInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIdx, blockInfo.window.ekey + step); } else { // interval query + TSKEY nextKey = blockInfo.window.skey; setIntervalQueryRange(pQInfo, nextKey); int32_t ret = setAdditionalInfo(pQInfo, &pTableQueryInfo->id, pTableQueryInfo); @@ -4451,41 +4463,6 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { return true; } -static UNUSED_FUNC int64_t doCheckTables(SQInfo *pQInfo, SArray* pTableList) { - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - - if (!multiTableMultioutputHelper(pQInfo, 0)) { - return 0; - } - - SPointInterpoSupporter pointInterpSupporter = {0}; - pointInterpSupporterInit(pQuery, &pointInterpSupporter); - - /* - * here we set the value for before and after the specified time into the - * parameter for interpolation query - */ - pointInterpSupporterSetData(pQInfo, &pointInterpSupporter); - pointInterpSupporterDestroy(&pointInterpSupporter); - - scanAllDataBlocks(pRuntimeEnv); - - // first/last_row query, do not invoke the finalize for super table query - finalizeQueryResult(pRuntimeEnv); - - int64_t numOfRes = getNumOfResult(pRuntimeEnv); - assert(numOfRes == 1 || numOfRes == 0); - - // accumulate the point interpolation result - if (numOfRes > 0) { - pQuery->rec.rows += numOfRes; - forwardCtxOutputBuf(pRuntimeEnv, numOfRes); - } - - return numOfRes; -} - /** * super table query handler * 1. super table projection query, group-by on normal columns query, ts-comp query @@ -4536,8 +4513,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) { setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(tx, 0), pQInfo->tsdb); // here we simply set the first table as current table - pRuntimeEnv->pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info; - scanAllDataBlocks(pRuntimeEnv); + pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info; + scanAllDataBlocks(pRuntimeEnv, pQuery->current->lastKey); int64_t numOfRes = getNumOfResult(pRuntimeEnv); if (numOfRes > 0) { @@ -4592,25 +4569,20 @@ static void sequentialTableProcess(SQInfo *pQInfo) { continue; } - // SPointInterpoSupporter pointInterpSupporter = {0}; - // TODO handle the limit offset problem if (pQuery->numOfFilterCols == 0 && pQuery->limit.offset > 0) { // skipBlocks(pRuntimeEnv); - if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { pQInfo->tableIndex++; continue; } } - scanAllDataBlocks(pRuntimeEnv); - - pQuery->rec.rows = getNumOfResult(pRuntimeEnv); + scanAllDataBlocks(pRuntimeEnv, pQuery->current->lastKey); skipResults(pRuntimeEnv); // the limitation of output result is reached, set the query completed - if (limitResults(pQInfo)) { + if (limitResults(pQuery)) { pQInfo->tableIndex = pQInfo->groupInfo.numOfTables; break; } @@ -4639,18 +4611,15 @@ static void sequentialTableProcess(SQInfo *pQInfo) { break; } - } else { // forward query range - pQuery->window.skey = pQuery->current->lastKey; - + } else { // all data in the result buffer are skipped due to the offset, continue to retrieve data from current meter if (pQuery->rec.rows == 0) { assert(!Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)); continue; } else { - // pQInfo->pTableQuerySupporter->pMeterSidExtInfo[k]->key = pQuery->lastKey; - // // buffer is full, wait for the next round to retrieve data from current meter - // assert(Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL)); - // break; + // buffer is full, wait for the next round to retrieve data from current meter + assert(Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)); + break; } } } @@ -4694,10 +4663,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) { copyFromWindowResToSData(pQInfo, pWindowResInfo->pResult); } - pQuery->rec.total += pQuery->rec.rows; - qTrace( - "QInfo %p, numOfTables:%d, index:%d, numOfGroups:%d, %d points returned, total:%"PRId64", offset:%" PRId64, + "QInfo %p numOfTables:%d, index:%d, numOfGroups:%d, %d points returned, total:%"PRId64", offset:%" PRId64, pQInfo, pQInfo->groupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total, pQuery->limit.offset); } @@ -4853,25 +4820,24 @@ static void tableFixedOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery *pQuery = pRuntimeEnv->pQuery; + if (!isTopBottomQuery(pQuery) && pQuery->limit.offset > 0) { // no need to execute, since the output will be ignore. + return; + } + pQuery->current = pTableInfo; // set current query table info - scanAllDataBlocks(pRuntimeEnv); + scanAllDataBlocks(pRuntimeEnv, pTableInfo->lastKey); finalizeQueryResult(pRuntimeEnv); if (isQueryKilled(pQInfo)) { return; } - // since the numOfOutputElems must be identical for all sql functions that are allowed to be executed simutanelously. + // since the numOfRows must be identical for all sql functions that are allowed to be executed simutaneously. pQuery->rec.rows = getNumOfResult(pRuntimeEnv); - // must be top/bottom query if offset > 0 - if (pQuery->limit.offset > 0) { - assert(isTopBottomQuery(pQuery)); - } - skipResults(pRuntimeEnv); - limitResults(pQInfo); + limitResults(pQuery); } static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) { @@ -4893,7 +4859,7 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) } while (1) { - scanAllDataBlocks(pRuntimeEnv); + scanAllDataBlocks(pRuntimeEnv, pQuery->current->lastKey); finalizeQueryResult(pRuntimeEnv); if (isQueryKilled(pQInfo)) { @@ -4919,7 +4885,7 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) resetCtxOutputBuf(pRuntimeEnv); } - limitResults(pQInfo); + limitResults(pQuery); if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) { qTrace("QInfo:%p query paused due to output limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo, pQuery->current->lastKey, pQuery->window.ekey); @@ -4936,11 +4902,11 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) } } -static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv) { +static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { SQuery *pQuery = pRuntimeEnv->pQuery; while (1) { - scanAllDataBlocks(pRuntimeEnv); + scanAllDataBlocks(pRuntimeEnv, start); if (isQueryKilled(GET_QINFO_ADDR(pRuntimeEnv))) { return; @@ -4952,7 +4918,7 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv) { // here we can ignore the records in case of no interpolation // todo handle offset, in case of top/bottom interval query if ((pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) && pQuery->limit.offset > 0 && - pQuery->interpoType == TSDB_INTERPO_NONE) { + pQuery->fillType == TSDB_FILL_NONE) { // maxOutput <= 0, means current query does not generate any results int32_t numOfClosed = numOfClosedTimeWindow(&pRuntimeEnv->windowResInfo); @@ -4971,19 +4937,21 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv) { static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) { SQueryRuntimeEnv *pRuntimeEnv = &(pQInfo->runtimeEnv); - int32_t numOfInterpo = 0; SQuery *pQuery = pRuntimeEnv->pQuery; pQuery->current = pTableInfo; + int32_t numOfInterpo = 0; + TSKEY newStartKey = TSKEY_INITIAL_VAL; + // skip blocks without load the actual data block from file if no filter condition present - skipTimeInterval(pRuntimeEnv); - if (pQuery->limit.offset > 0 && pQuery->numOfFilterCols == 0) { + skipTimeInterval(pRuntimeEnv, &newStartKey); + if (pQuery->limit.offset > 0 && pQuery->numOfFilterCols == 0 && pRuntimeEnv->pFillInfo == NULL) { setQueryStatus(pQuery, QUERY_COMPLETED); return; } while (1) { - tableIntervalProcessImpl(pRuntimeEnv); + tableIntervalProcessImpl(pRuntimeEnv, newStartKey); if (isIntervalQuery(pQuery)) { pQInfo->groupIndex = 0; // always start from 0 @@ -4994,24 +4962,20 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) { } // the offset is handled at prepare stage if no interpolation involved - if (pQuery->interpoType == TSDB_INTERPO_NONE) { - limitResults(pQInfo); + if (pQuery->fillType == TSDB_FILL_NONE || pQuery->rec.rows == 0) { + limitResults(pQuery); break; } else { - taosInterpoSetStartInfo(&pRuntimeEnv->interpoInfo, pQuery->rec.rows, pQuery->interpoType); - SData **pInterpoBuf = pRuntimeEnv->pInterpoBuf; - - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - memcpy(pInterpoBuf[i]->data, pQuery->sdata[i]->data, pQuery->rec.rows * pQuery->pSelectExpr[i].bytes); - } - + TSKEY ekey = taosGetRevisedEndKey(pQuery->window.ekey, pQuery->order.order, pQuery->slidingTime, + pQuery->slidingTimeUnit, pQuery->precision); + taosFillSetStartInfo(pRuntimeEnv->pFillInfo, pQuery->rec.rows, ekey); + taosFillCopyInputDataFromFilePage(pRuntimeEnv->pFillInfo, (tFilePage**) pQuery->sdata); numOfInterpo = 0; - pQuery->rec.rows = vnodeQueryResultInterpolate(pQInfo, (tFilePage **)pQuery->sdata, (tFilePage **)pInterpoBuf, - pQuery->rec.rows, &numOfInterpo); + pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, pQuery->rec.rows, &numOfInterpo); - qTrace("QInfo: %p interpo completed, final:%d", pQInfo, pQuery->rec.rows); + qTrace("QInfo: %p fill results completed, final:%d", pQInfo, pQuery->rec.rows); if (pQuery->rec.rows > 0 || Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { - limitResults(pQInfo); + limitResults(pQuery); break; } @@ -5035,19 +4999,20 @@ static void tableQueryImpl(SQInfo *pQInfo) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery * pQuery = pRuntimeEnv->pQuery; - if (vnodeHasRemainResults(pQInfo)) { + if (queryHasRemainResults(pRuntimeEnv)) { /* * There are remain results that are not returned due to result interpolation * So, we do keep in this procedure instead of launching retrieve procedure for next results. */ int32_t numOfInterpo = 0; - int32_t remain = taosNumOfRemainPoints(&pRuntimeEnv->interpoInfo); - pQuery->rec.rows = vnodeQueryResultInterpolate(pQInfo, (tFilePage **)pQuery->sdata, - (tFilePage **)pRuntimeEnv->pInterpoBuf, remain, &numOfInterpo); - - limitResults(pQInfo); - - pQInfo->pointsInterpo += numOfInterpo; + int32_t remain = taosNumOfRemainRows(pRuntimeEnv->pFillInfo); + pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, remain, &numOfInterpo); + + qTrace("QInfo: %p fill results completed, final:%d", pQInfo, pQuery->rec.rows); + if (pQuery->rec.rows > 0) { + limitResults(pQuery); + } + qTrace("QInfo:%p current:%d returned, total:%d", pQInfo, pQuery->rec.rows, pQuery->rec.total); return; } @@ -5105,8 +5070,6 @@ static void tableQueryImpl(SQInfo *pQInfo) { if (isQueryKilled(pQInfo)) { qTrace("QInfo:%p query is killed", pQInfo); } else {// todo set the table uid and tid in log -// SArray* p = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0); -// SPair* pair = taosArrayGet(p, 0); qTrace("QInfo:%p query paused, %" PRId64 " rows returned, numOfTotal:%" PRId64 " rows", pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows); } @@ -5130,7 +5093,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { // record the total elapsed time pQInfo->elapsedTime += (taosGetTimestampUs() - st); - // taosInterpoSetStartInfo(&pQInfo->runtimeEnv.interpoInfo, pQuery->size, pQInfo->query.interpoType); + // taosFillSetStartInfo(&pQInfo->runtimeEnv.pFillInfo, pQuery->size, pQInfo->query.fillType); if (pQuery->rec.rows == 0) { qTrace("QInfo:%p over, %d tables queried, %d points are returned", pQInfo, pQInfo->groupInfo.numOfTables, @@ -5171,7 +5134,7 @@ bool validateExprColumnInfo(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SC static bool validateQueryMsg(SQueryTableMsg *pQueryMsg) { if (pQueryMsg->intervalTime < 0) { - qError("qmsg:%p illegal value of interval time %" PRId64 "", pQueryMsg, pQueryMsg->intervalTime); + qError("qmsg:%p illegal value of interval time %" PRId64, pQueryMsg, pQueryMsg->intervalTime); return false; } @@ -5377,8 +5340,8 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, pQueryMsg->orderType = htons(pQueryMsg->orderType); } - pQueryMsg->interpoType = htons(pQueryMsg->interpoType); - if (pQueryMsg->interpoType != TSDB_INTERPO_NONE) { + pQueryMsg->fillType = htons(pQueryMsg->fillType); + if (pQueryMsg->fillType != TSDB_FILL_NONE) { pQueryMsg->defaultVal = (uint64_t)(pMsg); int64_t *v = (int64_t *)pMsg; @@ -5422,7 +5385,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, "outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, limit:%" PRId64 ", offset:%" PRId64, pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols, pQueryMsg->order, pQueryMsg->numOfOutput, pQueryMsg->numOfCols, pQueryMsg->intervalTime, - pQueryMsg->interpoType, pQueryMsg->tsLen, pQueryMsg->limit, pQueryMsg->offset); + pQueryMsg->fillType, pQueryMsg->tsLen, pQueryMsg->limit, pQueryMsg->offset); return 0; } @@ -5699,7 +5662,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQuery->intervalTime = pQueryMsg->intervalTime; pQuery->slidingTime = pQueryMsg->slidingTime; pQuery->slidingTimeUnit = pQueryMsg->slidingTimeUnit; - pQuery->interpoType = pQueryMsg->interpoType; + pQuery->fillType = pQueryMsg->fillType; pQuery->numOfTags = pQueryMsg->numOfTags; // todo do not allocate ?? @@ -5729,7 +5692,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, } // prepare the result buffer - pQuery->sdata = (SData **)calloc(pQuery->numOfOutput, POINTER_BYTES); + pQuery->sdata = (tFilePage **)calloc(pQuery->numOfOutput, POINTER_BYTES); if (pQuery->sdata == NULL) { goto _cleanup; } @@ -5742,14 +5705,14 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, assert(pExprs[col].interBytes >= pExprs[col].bytes); // allocate additional memory for interResults that are usually larger then final results - size_t size = (pQuery->rec.capacity + 1) * pExprs[col].bytes + pExprs[col].interBytes + sizeof(SData); - pQuery->sdata[col] = (SData *)calloc(1, size); + size_t size = (pQuery->rec.capacity + 1) * pExprs[col].bytes + pExprs[col].interBytes + sizeof(tFilePage); + pQuery->sdata[col] = (tFilePage *)calloc(1, size); if (pQuery->sdata[col] == NULL) { goto _cleanup; } } - if (pQuery->interpoType != TSDB_INTERPO_NONE) { + if (pQuery->fillType != TSDB_FILL_NONE) { pQuery->defaultVal = malloc(sizeof(int64_t) * pQuery->numOfOutput); if (pQuery->defaultVal == NULL) { goto _cleanup; @@ -6078,6 +6041,8 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi isSTableQuery = TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY); STableIdInfo *id = taosArrayGet(pTableIdList, 0); + qTrace("qmsg:%p query table, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid); + if ((code = tsdbGetOneTableGroup(tsdb, id->uid, &groupInfo)) != TSDB_CODE_SUCCESS) { goto _over; } @@ -6319,10 +6284,10 @@ static void buildTagQueryResult(SQInfo* pQInfo) { memcpy(dst, data, bytes); } } - } } + pQInfo->tableIndex = pQInfo->groupInfo.numOfTables; qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, num); } diff --git a/src/query/src/queryFilterFunc.c b/src/query/src/qFilterFunc.c similarity index 99% rename from src/query/src/queryFilterFunc.c rename to src/query/src/qFilterFunc.c index 41a888e92d6134f004afce614719e07376b8a198..bcc9531c4e888e8a5bf70a363cb4b148df0aac53 100644 --- a/src/query/src/queryFilterFunc.c +++ b/src/query/src/qFilterFunc.c @@ -16,10 +16,10 @@ #define _DEFAULT_SOURCE #include "os.h" +#include "qExecutor.h" #include "taosmsg.h" -#include "tsqlfunction.h" -#include "queryExecutor.h" #include "tcompare.h" +#include "tsqlfunction.h" bool less_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { return (*(int8_t *)minval < pFilter->filterInfo.upperBndi); diff --git a/src/query/src/queryUtil.c b/src/query/src/qUtil.c similarity index 97% rename from src/query/src/queryUtil.c rename to src/query/src/qUtil.c index 9da02f9f0f9d97c5087027309bde844c09589ecd..2d713e127f0acaf16349ebb19fca92719c7d8a26 100644 --- a/src/query/src/queryUtil.c +++ b/src/query/src/qUtil.c @@ -20,11 +20,11 @@ #include "qextbuffer.h" #include "ttime.h" -#include "qinterpolation.h" +#include "qfill.h" #include "ttime.h" -#include "queryExecutor.h" -#include "queryUtil.h" +#include "qExecutor.h" +#include "qUtil.h" int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRuntimeEnv, int32_t size, int32_t threshold, int16_t type) { @@ -37,7 +37,8 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun pWindowResInfo->hashList = taosHashInit(threshold, fn, false); pWindowResInfo->curIndex = -1; - pWindowResInfo->size = 0; + pWindowResInfo->size = 0; + pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL; // use the pointer arraylist pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult)); @@ -96,8 +97,8 @@ void resetTimeWindowInfo(SQueryRuntimeEnv *pRuntimeEnv, SWindowResInfo *pWindowR _hash_fn_t fn = taosGetDefaultHashFunction(pWindowResInfo->type); pWindowResInfo->hashList = taosHashInit(pWindowResInfo->capacity, fn, false); - pWindowResInfo->startTime = 0; - pWindowResInfo->prevSKey = 0; + pWindowResInfo->startTime = TSKEY_INITIAL_VAL; + pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL; } void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) { diff --git a/src/query/src/qast.c b/src/query/src/qast.c index f727acb72096e66bba6f377be20bcc3b46187df0..d784fa4102194558c7e3149d07491c2c6e319d4f 100644 --- a/src/query/src/qast.c +++ b/src/query/src/qast.c @@ -476,44 +476,6 @@ typedef struct { SEndPoint* end; } SQueryCond; -//static void setInitialValueForRangeQueryCondition(tSKipListQueryCond *q, int8_t type) { -// q->lowerBndRelOptr = TSDB_RELATION_GREATER; -// q->upperBndRelOptr = TSDB_RELATION_LESS; -// -// switch (type) { -// case TSDB_DATA_TYPE_BOOL: -// case TSDB_DATA_TYPE_TINYINT: -// case TSDB_DATA_TYPE_SMALLINT: -// case TSDB_DATA_TYPE_INT: -// case TSDB_DATA_TYPE_BIGINT: { -// q->upperBnd.nType = TSDB_DATA_TYPE_BIGINT; -// q->lowerBnd.nType = TSDB_DATA_TYPE_BIGINT; -// -// q->upperBnd.i64Key = INT64_MAX; -// q->lowerBnd.i64Key = INT64_MIN; -// break; -// }; -// case TSDB_DATA_TYPE_FLOAT: -// case TSDB_DATA_TYPE_DOUBLE: { -// q->upperBnd.nType = TSDB_DATA_TYPE_DOUBLE; -// q->lowerBnd.nType = TSDB_DATA_TYPE_DOUBLE; -// q->upperBnd.dKey = DBL_MAX; -// q->lowerBnd.dKey = -DBL_MIN; -// break; -// }; -// case TSDB_DATA_TYPE_NCHAR: -// case TSDB_DATA_TYPE_BINARY: { -// q->upperBnd.nType = type; -// q->upperBnd.pz = NULL; -// q->upperBnd.nLen = -1; -// -// q->lowerBnd.nType = type; -// q->lowerBnd.pz = NULL; -// q->lowerBnd.nLen = -1; -// } -// } -//} - // todo check for malloc failure static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) { int32_t optr = queryColInfo->optr; @@ -788,7 +750,6 @@ static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SExprTravers taosArrayCopy(pResult, array); } - static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSkipList *pSkipList, SExprTraverseSupp *param ) { SSkipListIterator* iter = tSkipListCreateIter(pSkipList); @@ -834,8 +795,6 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, tSkipListDestroyIter(iter); } - - // post-root order traverse syntax tree void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) { if (pExpr == NULL) { @@ -1100,7 +1059,6 @@ static char* exception_strdup(const char* str) { return p; } - static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { int32_t anchor = CLEANUP_GET_ANCHOR(); diff --git a/src/query/src/qextbuffer.c b/src/query/src/qextbuffer.c index adf15d1de0d90e287131bf7b076fa089e4156020..98d830c26fc0507e4ef4391d3b51f29cebb49ae9 100644 --- a/src/query/src/qextbuffer.c +++ b/src/query/src/qextbuffer.c @@ -136,7 +136,7 @@ static bool tExtMemBufferAlloc(tExtMemBuffer *pMemBuffer) { } item->pNext = NULL; - item->item.numOfElems = 0; + item->item.num = 0; if (pMemBuffer->pTail != NULL) { pMemBuffer->pTail->pNext = item; @@ -167,13 +167,13 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow pLast = pMemBuffer->pTail; } - if (pLast->item.numOfElems + numOfRows <= pMemBuffer->numOfElemsPerPage) { // enough space for records + if (pLast->item.num + numOfRows <= pMemBuffer->numOfElemsPerPage) { // enough space for records tColModelAppend(pMemBuffer->pColumnModel, &pLast->item, data, 0, numOfRows, numOfRows); pMemBuffer->numOfElemsInBuffer += numOfRows; pMemBuffer->numOfTotalElems += numOfRows; } else { - int32_t numOfRemainEntries = pMemBuffer->numOfElemsPerPage - pLast->item.numOfElems; + int32_t numOfRemainEntries = pMemBuffer->numOfElemsPerPage - pLast->item.num; tColModelAppend(pMemBuffer->pColumnModel, &pLast->item, data, 0, numOfRemainEntries, numOfRows); pMemBuffer->numOfElemsInBuffer += numOfRemainEntries; @@ -271,7 +271,7 @@ bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) { ret = false; } - pMemBuffer->fileMeta.numOfElemsInFile += first->item.numOfElems; + pMemBuffer->fileMeta.numOfElemsInFile += first->item.num; pMemBuffer->fileMeta.nFileSize += 1; tFilePagesItem *ptmp = first; @@ -985,16 +985,16 @@ void tColModelDisplayEx(SColumnModel *pModel, void *pData, int32_t numOfRows, in //////////////////////////////////////////////////////////////////////////////////////////// void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxElemsCapacity) { - if (inputBuffer->numOfElems == 0 || maxElemsCapacity == inputBuffer->numOfElems) { + if (inputBuffer->num == 0 || maxElemsCapacity == inputBuffer->num) { return; } /* start from the second column */ for (int32_t i = 1; i < pModel->numOfCols; ++i) { SSchemaEx* pSchemaEx = &pModel->pFields[i]; - memmove(inputBuffer->data + pSchemaEx->offset * inputBuffer->numOfElems, + memmove(inputBuffer->data + pSchemaEx->offset * inputBuffer->num, inputBuffer->data + pSchemaEx->offset * maxElemsCapacity, - pSchemaEx->field.bytes * inputBuffer->numOfElems); + pSchemaEx->field.bytes * inputBuffer->num); } } @@ -1009,13 +1009,13 @@ int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index) { } void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockCapacity, int32_t s, int32_t e) { - if (inputBuffer->numOfElems == 0 || (e - s + 1) <= 0) { + if (inputBuffer->num == 0 || (e - s + 1) <= 0) { return; } int32_t removed = e - s + 1; - int32_t remain = inputBuffer->numOfElems - removed; - int32_t secPart = inputBuffer->numOfElems - e - 1; + int32_t remain = inputBuffer->num - removed; + int32_t secPart = inputBuffer->num - e - 1; /* start from the second column */ for (int32_t i = 0; i < pModel->numOfCols; ++i) { @@ -1028,7 +1028,7 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC memmove(startPos, endPos, pSchema->bytes * secPart); } - inputBuffer->numOfElems = remain; + inputBuffer->num = remain; } /* @@ -1040,16 +1040,16 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC */ void tColModelAppend(SColumnModel *dstModel, tFilePage *dstPage, void *srcData, int32_t start, int32_t numOfRows, int32_t srcCapacity) { - assert(dstPage->numOfElems + numOfRows <= dstModel->capacity); + assert(dstPage->num + numOfRows <= dstModel->capacity); for (int32_t col = 0; col < dstModel->numOfCols; ++col) { - char *dst = COLMODEL_GET_VAL(dstPage->data, dstModel, dstModel->capacity, dstPage->numOfElems, col); + char *dst = COLMODEL_GET_VAL(dstPage->data, dstModel, dstModel->capacity, dstPage->num, col); char *src = COLMODEL_GET_VAL((char *)srcData, dstModel, srcCapacity, start, col); memmove(dst, src, dstModel->pFields[col].field.bytes * numOfRows); } - dstPage->numOfElems += numOfRows; + dstPage->num += numOfRows; } tOrderDescriptor *tOrderDesCreate(const int32_t *orderColIdx, int32_t numOfOrderCols, SColumnModel *pModel, diff --git a/src/query/src/qfill.c b/src/query/src/qfill.c new file mode 100644 index 0000000000000000000000000000000000000000..4f69c449401bef1ab6f30a42aaa09c2f3aa14a85 --- /dev/null +++ b/src/query/src/qfill.c @@ -0,0 +1,470 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "qfill.h" +#include "os.h" +#include "qextbuffer.h" +#include "taosdef.h" +#include "taosmsg.h" +#include "tsqlfunction.h" + +#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC) + +int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, char timeUnit, int16_t precision) { + if (slidingTime == 0) { + return startTime; + } + + if (timeUnit == 'a' || timeUnit == 'm' || timeUnit == 's' || timeUnit == 'h') { + return (startTime / slidingTime) * slidingTime; + } else { + /* + * here we revised the start time of day according to the local time zone, + * but in case of DST, the start time of one day need to be dynamically decided. + * + * TODO dynamically decide the start time of a day + */ + + // todo refactor to extract function that is available for Linux/Windows/Mac platform +#if defined(WINDOWS) && _MSC_VER >= 1900 + // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 + int64_t timezone = _timezone; + int32_t daylight = _daylight; + char** tzname = _tzname; +#endif + + int64_t t = (precision == TSDB_TIME_PRECISION_MILLI) ? MILLISECOND_PER_SECOND : MILLISECOND_PER_SECOND * 1000L; + + int64_t revStartime = (startTime / slidingTime) * slidingTime + timezone * t; + int64_t revEndtime = revStartime + slidingTime - 1; + if (revEndtime < startTime) { + revStartime += slidingTime; + } + + return revStartime; + } +} + +SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols, + int64_t slidingTime, int32_t fillType, SFillColInfo* pFillCol) { + if (fillType == TSDB_FILL_NONE) { + return NULL; + } + + SFillInfo* pFillInfo = calloc(1, sizeof(SFillInfo)); + + taosResetFillInfo(pFillInfo, skey); + + pFillInfo->order = order; + pFillInfo->fillType = fillType; + pFillInfo->pFillCol = pFillCol; + pFillInfo->numOfTags = numOfTags; + pFillInfo->numOfCols = numOfCols; + pFillInfo->slidingTime = slidingTime; + + pFillInfo->pData = malloc(POINTER_BYTES * numOfCols); + + int32_t rowsize = 0; + for (int32_t i = 0; i < numOfCols; ++i) { + int32_t bytes = pFillInfo->pFillCol[i].col.bytes; + pFillInfo->pData[i] = calloc(1, sizeof(tFilePage) + bytes * capacity); + + rowsize += bytes; + } + + if (numOfTags > 0) { + pFillInfo->pTags = calloc(1, pFillInfo->numOfTags * POINTER_BYTES + rowsize); + } + + pFillInfo->rowSize = rowsize; + return pFillInfo; +} + +void taosResetFillInfo(SFillInfo* pFillInfo, TSKEY startTimestamp) { + pFillInfo->start = startTimestamp; + pFillInfo->rowIdx = -1; + pFillInfo->numOfRows = 0; + pFillInfo->numOfCurrent = 0; + pFillInfo->numOfTotal = 0; +} + +void taosDestoryFillInfo(SFillInfo* pFillInfo) { + if (pFillInfo == NULL) { + return; + } + + tfree(pFillInfo->prevValues); + tfree(pFillInfo->nextValues); + tfree(pFillInfo->pTags); + tfree(pFillInfo); +} + +void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) { + if (pFillInfo->fillType == TSDB_FILL_NONE) { + return; + } + + pFillInfo->rowIdx = 0; + pFillInfo->numOfRows = numOfRows; + + pFillInfo->endKey = endKey; +} + +void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput) { + // copy the data into source data buffer + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { + memcpy(pFillInfo->pData[i], pInput[i]->data, pFillInfo->numOfRows * pFillInfo->pFillCol[i].col.bytes); + } +} + +void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInput) { + assert(pFillInfo->numOfRows == pInput->num); + for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* s = pInput->data + pCol->col.offset * pInput->num; + memcpy(pFillInfo->pData[i], s, pInput->num * pCol->col.bytes); + + if (pCol->flag == TSDB_COL_TAG) { // copy the tag value + memcpy(pFillInfo->pTags[i], pFillInfo->pData[i], pCol->col.bytes); + } + } +} + +TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision) { + if (order == TSDB_ORDER_ASC) { + return ekey; + } else { + return taosGetIntervalStartTimestamp(ekey, timeInterval, slidingTimeUnit, precision); + } +} + +static int32_t taosGetTotalNumOfFilledRes(SFillInfo* pFillInfo, const TSKEY* tsArray, int32_t remain, + int64_t nInterval, int64_t ekey) { + + if (remain > 0) { // still fill gap within current data block, not generating data after the result set. + TSKEY lastKey = tsArray[pFillInfo->numOfRows - 1]; + int32_t total = (int32_t)(labs(lastKey - pFillInfo->start) / nInterval) + 1; + + assert(total >= remain); + return total; + } else { // reach the end of data + if ((ekey < pFillInfo->start && FILL_IS_ASC_FILL(pFillInfo)) || + (ekey > pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo))) { + return 0; + } else { + return (int32_t)(labs(ekey - pFillInfo->start) / nInterval) + 1; + } + } +} + +int32_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows) { + int32_t numOfRes = taosGetTotalNumOfFilledRes(pFillInfo, (int64_t*) pFillInfo->pData[0], numOfRows, + pFillInfo->slidingTime, ekey); + return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; +} + +int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) { + if (pFillInfo->rowIdx == -1 || pFillInfo->numOfRows == 0) { + return 0; + } + + return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx) + : pFillInfo->rowIdx + 1; +} + +// todo: refactor +static double linearInterpolationImpl(double v1, double v2, double k1, double k2, double k) { + return v1 + (v2 - v1) * (k - k1) / (k2 - k1); +} + +int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoint* point) { + switch (type) { + case TSDB_DATA_TYPE_INT: { + *(int32_t*)point->val = linearInterpolationImpl(*(int32_t*)point1->val, *(int32_t*)point2->val, point1->key, + point2->key, point->key); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + *(float*)point->val = + linearInterpolationImpl(*(float*)point1->val, *(float*)point2->val, point1->key, point2->key, point->key); + break; + }; + case TSDB_DATA_TYPE_DOUBLE: { + *(double*)point->val = + linearInterpolationImpl(*(double*)point1->val, *(double*)point2->val, point1->key, point2->key, point->key); + break; + }; + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: { + *(int64_t*)point->val = linearInterpolationImpl(*(int64_t*)point1->val, *(int64_t*)point2->val, point1->key, + point2->key, point->key); + break; + }; + case TSDB_DATA_TYPE_SMALLINT: { + *(int16_t*)point->val = linearInterpolationImpl(*(int16_t*)point1->val, *(int16_t*)point2->val, point1->key, + point2->key, point->key); + break; + }; + case TSDB_DATA_TYPE_TINYINT: { + *(int8_t*)point->val = + linearInterpolationImpl(*(int8_t*)point1->val, *(int8_t*)point2->val, point1->key, point2->key, point->key); + break; + }; + default: { + // TODO: Deal with interpolation with bool and strings and timestamp + return -1; + } + } + + return 0; +} + +static void setTagsValue(SFillInfo* pColInfo, tFilePage** data, char** pTags, int32_t start, int32_t num) { + for (int32_t j = 0, i = start; i < pColInfo->numOfCols + pColInfo->numOfTags; ++i, ++j) { + SFillColInfo* pCol = &pColInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, num); + assignVal(val1, pTags[j], pCol->col.bytes, pCol->col.type); + } +} + +static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* num, char** srcData, + int64_t ts, char** pTags, bool outOfBound) { + char** prevValues = &pFillInfo->prevValues; + char** nextValues = &pFillInfo->nextValues; + + SPoint point1, point2, point; + + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); + + char* val = elePtrAt(data[0]->data, TSDB_KEYSIZE, *num); + *(TSKEY*) val = pFillInfo->start; + + int32_t numOfValCols = pFillInfo->numOfCols - pFillInfo->numOfTags; + + // set the other values + if (pFillInfo->fillType == TSDB_FILL_PREV) { + char* pInterpolationData = FILL_IS_ASC_FILL(pFillInfo) ? *prevValues : *nextValues; + if (pInterpolationData != NULL) { + for (int32_t i = 1; i < numOfValCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); + if (isNull(pInterpolationData + pCol->col.offset, pCol->col.type)) { + setNull(val1, pCol->col.type, pCol->col.bytes); + } else { + assignVal(val1, pInterpolationData + pCol->col.offset, pCol->col.bytes, pCol->col.type); + } + } + } else { // no prev value yet, set the value for NULL + for (int32_t i = 1; i < numOfValCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); + setNull(val1, pCol->col.type, pCol->col.bytes); + } + } + + setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); + } else if (pFillInfo->fillType == TSDB_FILL_LINEAR) { + // TODO : linear interpolation supports NULL value + if (*prevValues != NULL && !outOfBound) { + for (int32_t i = 1; i < numOfValCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + int16_t type = pCol->col.type; + int16_t bytes = pCol->col.bytes; + + char *val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BOOL) { + setNull(val1, pCol->col.type, bytes); + continue; + } + + point1 = (SPoint){.key = *(TSKEY*)(*prevValues), .val = *prevValues + pCol->col.offset}; + point2 = (SPoint){.key = ts, .val = srcData[i] + pFillInfo->rowIdx * bytes}; + point = (SPoint){.key = pFillInfo->start, .val = val1}; + taosDoLinearInterpolation(type, &point1, &point2, &point); + } + + setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); + + } else { + for (int32_t i = 1; i < numOfValCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); + setNull(val1, pCol->col.type, pCol->col.bytes); + } + + setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); + + } + } else { /* default value interpolation */ + for (int32_t i = 1; i < numOfValCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); + assignVal(val1, (char*)&pCol->defaultVal.i, pCol->col.bytes, pCol->col.type); + } + + setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); + } + + pFillInfo->start += (pFillInfo->slidingTime * step); + pFillInfo->numOfCurrent++; + + (*num) += 1; +} + +static void initBeforeAfterDataBuf(SFillInfo* pFillInfo, char** nextValues) { + if (*nextValues != NULL) { + return; + } + + *nextValues = calloc(1, pFillInfo->rowSize); + for (int i = 1; i < pFillInfo->numOfCols; i++) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + setNull(*nextValues + pCol->col.offset, pCol->col.type, pCol->col.bytes); + } +} + +int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numOfRows, int32_t outputRows, char** srcData) { + int32_t num = 0; + pFillInfo->numOfCurrent = 0; + + char** prevValues = &pFillInfo->prevValues; + char** nextValues = &pFillInfo->nextValues; + + int32_t numOfTags = pFillInfo->numOfTags; + char** pTags = pFillInfo->pTags; + + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); + + if (numOfRows == 0) { + /* + * we need to rebuild whole result set + * NOTE:we need to keep the last saved data, to generated the filled data + */ + while (num < outputRows) { + doInterpoResultImpl(pFillInfo, data, &num, srcData, pFillInfo->start, pTags, true); + } + + pFillInfo->numOfTotal += pFillInfo->numOfCurrent; + return outputRows; + + } else { + while (1) { + int64_t ts = ((int64_t*)pFillInfo->pData[0])[pFillInfo->rowIdx]; + + if ((pFillInfo->start < ts && FILL_IS_ASC_FILL(pFillInfo)) || + (pFillInfo->start > ts && !FILL_IS_ASC_FILL(pFillInfo))) { + /* set the next value for interpolation */ + initBeforeAfterDataBuf(pFillInfo, nextValues); + + int32_t offset = pFillInfo->rowIdx; + for (int32_t i = 0; i < pFillInfo->numOfCols - numOfTags; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + memcpy(*nextValues + pCol->col.offset, srcData[i] + offset * pCol->col.bytes, pCol->col.bytes); + } + } + + if (((pFillInfo->start < ts && FILL_IS_ASC_FILL(pFillInfo)) || + (pFillInfo->start > ts && !FILL_IS_ASC_FILL(pFillInfo))) && num < outputRows) { + + while (((pFillInfo->start < ts && FILL_IS_ASC_FILL(pFillInfo)) || + (pFillInfo->start > ts && !FILL_IS_ASC_FILL(pFillInfo))) && num < outputRows) { + doInterpoResultImpl(pFillInfo, data, &num, srcData, pFillInfo->start, pTags, false); + } + + /* output buffer is full, abort */ + if ((num == outputRows && FILL_IS_ASC_FILL(pFillInfo)) || + (num < 0 && !FILL_IS_ASC_FILL(pFillInfo))) { + pFillInfo->numOfTotal += pFillInfo->numOfCurrent; + return outputRows; + } + } else { + assert(pFillInfo->start == ts); + initBeforeAfterDataBuf(pFillInfo, prevValues); + + // assign rows to dst buffer + int32_t i = 0; + for (; i < pFillInfo->numOfCols - numOfTags; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + + char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, num); + char* src = elePtrAt(srcData[i], pCol->col.bytes, pFillInfo->rowIdx); + + if (i == 0 || + (pCol->functionId != TSDB_FUNC_COUNT && !isNull(src, pCol->col.type)) || + (pCol->functionId == TSDB_FUNC_COUNT && GET_INT64_VAL(src) != 0)) { + assignVal(val1, src, pCol->col.bytes, pCol->col.type); + memcpy(*prevValues + pCol->col.offset, src, pCol->col.bytes); + } else { // i > 0 and data is null , do interpolation + if (pFillInfo->fillType == TSDB_FILL_PREV) { + assignVal(val1, *prevValues + pCol->col.offset, pCol->col.bytes, pCol->col.type); + } else if (pFillInfo->fillType == TSDB_FILL_LINEAR) { + assignVal(val1, src, pCol->col.bytes, pCol->col.type); + memcpy(*prevValues + pCol->col.offset, src, pCol->col.bytes); + } else { + assignVal(val1, (char*) &pCol->defaultVal.i, pCol->col.bytes, pCol->col.type); + } + } + } + + // set the tag value for final result + setTagsValue(pFillInfo, data, pTags, pFillInfo->numOfCols - numOfTags, num); + + pFillInfo->start += (pFillInfo->slidingTime * step); + pFillInfo->rowIdx += 1; + num += 1; + } + + if ((pFillInfo->rowIdx >= pFillInfo->numOfRows && FILL_IS_ASC_FILL(pFillInfo)) || + (pFillInfo->rowIdx < 0 && !FILL_IS_ASC_FILL(pFillInfo)) || num >= outputRows) { + if (pFillInfo->rowIdx >= pFillInfo->numOfRows || pFillInfo->rowIdx < 0) { + pFillInfo->rowIdx = -1; + pFillInfo->numOfRows = 0; + + /* the raw data block is exhausted, next value does not exists */ + tfree(*nextValues); + } + + pFillInfo->numOfTotal += pFillInfo->numOfCurrent; + return num; + } + } + } +} + +void taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int64_t* outputRows, int32_t capacity) { + int32_t remain = taosNumOfRemainRows(pFillInfo); // todo use iterator? + +// TSKEY ekey = taosGetRevisedEndKey(pQuery->window.ekey, pQuery->order.order, pQuery->slidingTime, +// pQuery->slidingTimeUnit, pQuery->precision); +// if (QUERY_IS_ASC_QUERY(pQuery)) { +// assert(ekey >= pQuery->window.ekey); +// } else { +// assert(ekey <= pQuery->window.ekey); +// } + + int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, pFillInfo->endKey, capacity); + + int32_t numOfRes = taosDoInterpoResult(pFillInfo, output, remain, rows, pFillInfo->pData); + *outputRows = rows; + + assert(numOfRes == rows); +} diff --git a/src/query/src/qinterpolation.c b/src/query/src/qinterpolation.c deleted file mode 100644 index 40fcf63c363912ff9f5eefaaf98ecdf91eaebf26..0000000000000000000000000000000000000000 --- a/src/query/src/qinterpolation.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "qinterpolation.h" -#include "os.h" -#include "qextbuffer.h" -#include "taosdef.h" -#include "taosmsg.h" -#include "tsqlfunction.h" - -#define INTERPOL_IS_ASC_INTERPOL(interp) ((interp)->order == TSDB_ORDER_ASC) - -int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char intervalTimeUnit, int16_t precision) { - if (timeRange == 0) { - return startTime; - } - - if (intervalTimeUnit == 'a' || intervalTimeUnit == 'm' || intervalTimeUnit == 's' || intervalTimeUnit == 'h') { - return (startTime / timeRange) * timeRange; - } else { - /* - * here we revised the start time of day according to the local time zone, - * but in case of DST, the start time of one day need to be dynamically decided. - * - * TODO dynamically decide the start time of a day - */ - -#if defined(WINDOWS) && _MSC_VER >= 1900 - // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 - int64_t timezone = _timezone; - int32_t daylight = _daylight; - char** tzname = _tzname; -#endif - - int64_t t = (precision == TSDB_TIME_PRECISION_MILLI) ? MILLISECOND_PER_SECOND : MILLISECOND_PER_SECOND * 1000L; - - int64_t revStartime = (startTime / timeRange) * timeRange + timezone * t; - int64_t revEndtime = revStartime + timeRange - 1; - if (revEndtime < startTime) { - revStartime += timeRange; - } - - return revStartime; - } -} - -void taosInitInterpoInfo(SInterpolationInfo* pInterpoInfo, int32_t order, int64_t startTimestamp, - int32_t numOfGroupbyTags, int32_t rowSize) { - pInterpoInfo->startTimestamp = startTimestamp; - pInterpoInfo->rowIdx = -1; - pInterpoInfo->numOfRawDataInRows = 0; - pInterpoInfo->numOfCurrentInterpo = 0; - pInterpoInfo->numOfTotalInterpo = 0; - pInterpoInfo->order = order; - - pInterpoInfo->numOfTags = numOfGroupbyTags; - if (pInterpoInfo->pTags == NULL && numOfGroupbyTags > 0) { - pInterpoInfo->pTags = calloc(1, numOfGroupbyTags * POINTER_BYTES + rowSize); - } - - // set the previous value to be null - tfree(pInterpoInfo->prevValues); -} - -// the SInterpolationInfo itself will not be released -void taosDestoryInterpoInfo(SInterpolationInfo* pInterpoInfo) { - if (pInterpoInfo == NULL) { - return; - } - - tfree(pInterpoInfo->prevValues); - tfree(pInterpoInfo->nextValues); - - tfree(pInterpoInfo->pTags); -} - -void taosInterpoSetStartInfo(SInterpolationInfo* pInterpoInfo, int32_t numOfRawDataInRows, int32_t type) { - if (type == TSDB_INTERPO_NONE) { - return; - } - - pInterpoInfo->rowIdx = 0; - pInterpoInfo->numOfRawDataInRows = numOfRawDataInRows; -} - -TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int32_t timeInterval, int8_t intervalTimeUnit, int8_t precision) { - if (order == TSDB_ORDER_ASC) { - return ekey; - } else { - return taosGetIntervalStartTimestamp(ekey, timeInterval, intervalTimeUnit, precision); - } -} - -int32_t taosGetNumOfResultWithInterpo(SInterpolationInfo* pInterpoInfo, TSKEY* pPrimaryKeyArray, - int32_t numOfRawDataInRows, int64_t nInterval, int64_t ekey, - int32_t maxNumOfRows) { - int32_t numOfRes = taosGetNumOfResWithoutLimit(pInterpoInfo, pPrimaryKeyArray, numOfRawDataInRows, nInterval, ekey); - return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; -} - -int32_t taosGetNumOfResWithoutLimit(SInterpolationInfo* pInterpoInfo, int64_t* pPrimaryKeyArray, - int32_t numOfAvailRawData, int64_t nInterval, int64_t ekey) { - if (numOfAvailRawData > 0) { - int32_t finalNumOfResult = 0; - - // get last timestamp, calculate the result size - int64_t lastKey = pPrimaryKeyArray[pInterpoInfo->numOfRawDataInRows - 1]; - finalNumOfResult = (int32_t)(labs(lastKey - pInterpoInfo->startTimestamp) / nInterval) + 1; - - assert(finalNumOfResult >= numOfAvailRawData); - return finalNumOfResult; - } else { - /* reach the end of data */ - if ((ekey < pInterpoInfo->startTimestamp && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (ekey > pInterpoInfo->startTimestamp && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo))) { - return 0; - } else { - return (int32_t)(labs(ekey - pInterpoInfo->startTimestamp) / nInterval) + 1; - } - } -} - -bool taosHasRemainsDataForInterpolation(SInterpolationInfo* pInterpoInfo) { - return taosNumOfRemainPoints(pInterpoInfo) > 0; -} - -int32_t taosNumOfRemainPoints(SInterpolationInfo* pInterpoInfo) { - if (pInterpoInfo->rowIdx == -1 || pInterpoInfo->numOfRawDataInRows == 0) { - return 0; - } - - return INTERPOL_IS_ASC_INTERPOL(pInterpoInfo) ? (pInterpoInfo->numOfRawDataInRows - pInterpoInfo->rowIdx) - : pInterpoInfo->rowIdx + 1; -} - -static double doLinearInterpolationImpl(double v1, double v2, double k1, double k2, double k) { - return v1 + (v2 - v1) * (k - k1) / (k2 - k1); -} - -int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoint* point) { - switch (type) { - case TSDB_DATA_TYPE_INT: { - *(int32_t*)point->val = doLinearInterpolationImpl(*(int32_t*)point1->val, *(int32_t*)point2->val, point1->key, - point2->key, point->key); - break; - } - case TSDB_DATA_TYPE_FLOAT: { - *(float*)point->val = - doLinearInterpolationImpl(*(float*)point1->val, *(float*)point2->val, point1->key, point2->key, point->key); - break; - }; - case TSDB_DATA_TYPE_DOUBLE: { - *(double*)point->val = - doLinearInterpolationImpl(*(double*)point1->val, *(double*)point2->val, point1->key, point2->key, point->key); - break; - }; - case TSDB_DATA_TYPE_TIMESTAMP: - case TSDB_DATA_TYPE_BIGINT: { - *(int64_t*)point->val = doLinearInterpolationImpl(*(int64_t*)point1->val, *(int64_t*)point2->val, point1->key, - point2->key, point->key); - break; - }; - case TSDB_DATA_TYPE_SMALLINT: { - *(int16_t*)point->val = doLinearInterpolationImpl(*(int16_t*)point1->val, *(int16_t*)point2->val, point1->key, - point2->key, point->key); - break; - }; - case TSDB_DATA_TYPE_TINYINT: { - *(int8_t*)point->val = - doLinearInterpolationImpl(*(int8_t*)point1->val, *(int8_t*)point2->val, point1->key, point2->key, point->key); - break; - }; - default: { - // TODO: Deal with interpolation with bool and strings and timestamp - return -1; - } - } - - return 0; -} - -static char* getPos(char* data, int32_t bytes, int32_t index) { return data + index * bytes; } - -static void setTagsValueInInterpolation(tFilePage** data, char** pTags, SColumnModel* pModel, int32_t order, - int32_t start, int32_t capacity, int32_t num) { - for (int32_t j = 0, i = start; i < pModel->numOfCols; ++i, ++j) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, num); - assignVal(val1, pTags[j], pSchema->bytes, pSchema->type); - } -} - -static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interpoType, tFilePage** data, - SColumnModel* pModel, int32_t* num, char** srcData, int64_t nInterval, - int64_t* defaultVal, int64_t currentTimestamp, int32_t capacity, int32_t numOfTags, - char** pTags, bool outOfBound) { - char** prevValues = &pInterpoInfo->prevValues; - char** nextValues = &pInterpoInfo->nextValues; - - SPoint point1, point2, point; - - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pInterpoInfo->order); - - char* val = getPos(data[0]->data, TSDB_KEYSIZE, *num); - *(TSKEY*)val = pInterpoInfo->startTimestamp; - - int32_t numOfValCols = pModel->numOfCols - numOfTags; - - // set the other values - if (interpoType == TSDB_INTERPO_PREV) { - char* pInterpolationData = INTERPOL_IS_ASC_INTERPOL(pInterpoInfo) ? *prevValues : *nextValues; - if (pInterpolationData != NULL) { - for (int32_t i = 1; i < numOfValCols; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - int16_t offset = getColumnModelOffset(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, *num); - - if (isNull(pInterpolationData + offset, pSchema->type)) { - setNull(val1, pSchema->type, pSchema->bytes); - } else { - assignVal(val1, pInterpolationData + offset, pSchema->bytes, pSchema->type); - } - } - } else { /* no prev value yet, set the value for null */ - for (int32_t i = 1; i < numOfValCols; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, *num); - setNull(val1, pSchema->type, pSchema->bytes); - } - } - - setTagsValueInInterpolation(data, pTags, pModel, pInterpoInfo->order, numOfValCols, capacity, *num); - } else if (interpoType == TSDB_INTERPO_LINEAR) { - // TODO : linear interpolation supports NULL value - if (*prevValues != NULL && !outOfBound) { - for (int32_t i = 1; i < numOfValCols; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - int16_t offset = getColumnModelOffset(pModel, i); - - int16_t type = pSchema->type; - char* val1 = getPos(data[i]->data, pSchema->bytes, *num); - - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BOOL) { - setNull(val1, type, pSchema->bytes); - continue; - } - - point1 = (SPoint){.key = *(TSKEY*)(*prevValues), .val = *prevValues + offset}; - point2 = (SPoint){.key = currentTimestamp, .val = srcData[i] + pInterpoInfo->rowIdx * pSchema->bytes}; - point = (SPoint){.key = pInterpoInfo->startTimestamp, .val = val1}; - taosDoLinearInterpolation(type, &point1, &point2, &point); - } - - setTagsValueInInterpolation(data, pTags, pModel, pInterpoInfo->order, numOfValCols, capacity, *num); - - } else { - for (int32_t i = 1; i < numOfValCols; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, *num); - setNull(val1, pSchema->type, pSchema->bytes); - } - - setTagsValueInInterpolation(data, pTags, pModel, pInterpoInfo->order, numOfValCols, capacity, *num); - } - } else { /* default value interpolation */ - for (int32_t i = 1; i < numOfValCols; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, *num); - assignVal(val1, (char*)&defaultVal[i], pSchema->bytes, pSchema->type); - } - - setTagsValueInInterpolation(data, pTags, pModel, pInterpoInfo->order, numOfValCols, capacity, *num); - } - - pInterpoInfo->startTimestamp += (nInterval * step); - pInterpoInfo->numOfCurrentInterpo++; - - (*num) += 1; -} - -static void initBeforeAfterDataBuf(SColumnModel* pModel, char** nextValues) { - if (*nextValues != NULL) { - return; - } - - *nextValues = calloc(1, pModel->rowSize); - for (int i = 1; i < pModel->numOfCols; i++) { - int16_t offset = getColumnModelOffset(pModel, i); - SSchema* pSchema = getColumnModelSchema(pModel, i); - - setNull(*nextValues + offset, pSchema->type, pSchema->bytes); - } -} - -int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoType, tFilePage** data, - int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval, - const int64_t* pPrimaryKeyArray, SColumnModel* pModel, char** srcData, int64_t* defaultVal, - const int32_t* functionIDs, int32_t bufSize) { - int32_t num = 0; - pInterpoInfo->numOfCurrentInterpo = 0; - - char** prevValues = &pInterpoInfo->prevValues; - char** nextValues = &pInterpoInfo->nextValues; - - int32_t numOfTags = pInterpoInfo->numOfTags; - char** pTags = pInterpoInfo->pTags; - - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pInterpoInfo->order); - - if (numOfRawDataInRows == 0) { - /* - * we need to rebuild whole data - * NOTE:we need to keep the last saved data, to satisfy the interpolation - */ - while (num < outputRows) { - doInterpoResultImpl(pInterpoInfo, interpoType, data, pModel, &num, srcData, nInterval, defaultVal, - pInterpoInfo->startTimestamp, bufSize, numOfTags, pTags, true); - } - pInterpoInfo->numOfTotalInterpo += pInterpoInfo->numOfCurrentInterpo; - return outputRows; - - } else { - while (1) { - int64_t currentTimestamp = pPrimaryKeyArray[pInterpoInfo->rowIdx]; - - if ((pInterpoInfo->startTimestamp < currentTimestamp && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (pInterpoInfo->startTimestamp > currentTimestamp && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo))) { - /* set the next value for interpolation */ - initBeforeAfterDataBuf(pModel, nextValues); - - int32_t offset = pInterpoInfo->rowIdx; - for (int32_t tlen = 0, i = 0; i < pModel->numOfCols - numOfTags; ++i) { - SSchema* pSchema = getColumnModelSchema(pModel, i); - - memcpy(*nextValues + tlen, srcData[i] + offset * pSchema->bytes, pSchema->bytes); - tlen += pSchema->bytes; - } - } - - if (((pInterpoInfo->startTimestamp < currentTimestamp && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (pInterpoInfo->startTimestamp > currentTimestamp && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo))) && - num < outputRows) { - while (((pInterpoInfo->startTimestamp < currentTimestamp && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (pInterpoInfo->startTimestamp > currentTimestamp && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo))) && - num < outputRows) { - doInterpoResultImpl(pInterpoInfo, interpoType, data, pModel, &num, srcData, nInterval, defaultVal, - currentTimestamp, bufSize, numOfTags, pTags, false); - } - - /* output buffer is full, abort */ - if ((num == outputRows && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (num < 0 && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo))) { - pInterpoInfo->numOfTotalInterpo += pInterpoInfo->numOfCurrentInterpo; - return outputRows; - } - } else { - assert(pInterpoInfo->startTimestamp == currentTimestamp); - - initBeforeAfterDataBuf(pModel, prevValues); - - // assign rows to dst buffer - int32_t i = 0; - for (int32_t tlen = 0; i < pModel->numOfCols - numOfTags; ++i) { - int16_t offset = getColumnModelOffset(pModel, i); - SSchema* pSchema = getColumnModelSchema(pModel, i); - - char* val1 = getPos(data[i]->data, pSchema->bytes, num); - char* src = srcData[i] + pInterpoInfo->rowIdx * pSchema->bytes; - - if (i == 0 || - (functionIDs[i] != TSDB_FUNC_COUNT && !isNull(src, pSchema->type)) || - (functionIDs[i] == TSDB_FUNC_COUNT && *(int64_t*)(src) != 0)) { - assignVal(val1, src, pSchema->bytes, pSchema->type); - memcpy(*prevValues + tlen, src, pSchema->bytes); - } else { // i > 0 and data is null , do interpolation - if (interpoType == TSDB_INTERPO_PREV) { - assignVal(val1, *prevValues + offset, pSchema->bytes, pSchema->type); - } else if (interpoType == TSDB_INTERPO_LINEAR) { - assignVal(val1, src, pSchema->bytes, pSchema->type); - memcpy(*prevValues + tlen, src, pSchema->bytes); - } else { - assignVal(val1, (char*)&defaultVal[i], pSchema->bytes, pSchema->type); - } - } - tlen += pSchema->bytes; - } - - /* set the tag value for final result */ - setTagsValueInInterpolation(data, pTags, pModel, pInterpoInfo->order, pModel->numOfCols - numOfTags, bufSize, - num); - - pInterpoInfo->startTimestamp += (nInterval * step); - pInterpoInfo->rowIdx += 1; - num += 1; - } - - if ((pInterpoInfo->rowIdx >= pInterpoInfo->numOfRawDataInRows && INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || - (pInterpoInfo->rowIdx < 0 && !INTERPOL_IS_ASC_INTERPOL(pInterpoInfo)) || num >= outputRows) { - if (pInterpoInfo->rowIdx >= pInterpoInfo->numOfRawDataInRows || pInterpoInfo->rowIdx < 0) { - pInterpoInfo->rowIdx = -1; - pInterpoInfo->numOfRawDataInRows = 0; - - /* the raw data block is exhausted, next value does not exists */ - tfree(*nextValues); - } - - pInterpoInfo->numOfTotalInterpo += pInterpoInfo->numOfCurrentInterpo; - return num; - } - } - } -} diff --git a/src/query/src/qpercentile.c b/src/query/src/qpercentile.c index 2561bdf284cf8bafa02cd2312b4298c7e43171c1..286171bdab794dde6fdf07d65fbcfa1d6875215b 100644 --- a/src/query/src/qpercentile.c +++ b/src/query/src/qpercentile.c @@ -64,26 +64,26 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx, for (uint32_t j = 0; j < pFlushInfo->numOfPages; ++j) { ret = fread(pPage, pMemBuffer->pageSize, 1, pMemBuffer->file); UNUSED(ret); - assert(pPage->numOfElems > 0); + assert(pPage->num > 0); - tColModelAppend(pDesc->pColumnModel, buffer, pPage->data, 0, pPage->numOfElems, pPage->numOfElems); - printf("id: %d count: %" PRIu64 "\n", j, buffer->numOfElems); + tColModelAppend(pDesc->pColumnModel, buffer, pPage->data, 0, pPage->num, pPage->num); + printf("id: %d count: %" PRIu64 "\n", j, buffer->num); } } tfree(pPage); - assert(buffer->numOfElems == pMemBuffer->fileMeta.numOfElemsInFile); + assert(buffer->num == pMemBuffer->fileMeta.numOfElemsInFile); } // load data in pMemBuffer to buffer tFilePagesItem *pListItem = pMemBuffer->pHead; while (pListItem != NULL) { - tColModelAppend(pDesc->pColumnModel, buffer, pListItem->item.data, 0, pListItem->item.numOfElems, - pListItem->item.numOfElems); + tColModelAppend(pDesc->pColumnModel, buffer, pListItem->item.data, 0, pListItem->item.num, + pListItem->item.num); pListItem = pListItem->pNext; } - tColDataQSort(pDesc, buffer->numOfElems, 0, buffer->numOfElems - 1, buffer->data, TSDB_ORDER_ASC); + tColDataQSort(pDesc, buffer->num, 0, buffer->num - 1, buffer->data, TSDB_ORDER_ASC); pDesc->pColumnModel->capacity = oldCapacity; // restore value return buffer; @@ -881,7 +881,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) for (uint32_t jx = 0; jx < pFlushInfo->numOfPages; ++jx) { ret = fread(pPage, pMemBuffer->pageSize, 1, pMemBuffer->file); UNUSED(ret); - tMemBucketPut(pMemBucket, pPage->data, pPage->numOfElems); + tMemBucketPut(pMemBucket, pPage->data, pPage->num); } fclose(pMemBuffer->file); diff --git a/src/query/src/qtokenizer.c b/src/query/src/qtokenizer.c index fc8e712530464f5cac3536b0c5c8385d3f91d376..e6340cc678f25cc2c82a1da9deae5c01b3504863 100644 --- a/src/query/src/qtokenizer.c +++ b/src/query/src/qtokenizer.c @@ -282,11 +282,7 @@ int tSQLKeywordCode(const char* z, int n) { } SKeyword** pKey = (SKeyword**)taosHashGet(KeywordHashTable, key, n); - if (pKey != NULL) { - return (*pKey)->type; - } else { - return TK_ID; - } + return (pKey != NULL)? (*pKey)->type:TK_ID; } /* @@ -594,31 +590,28 @@ SSQLToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn while (1) { *i += t0.n; - bool hasComma = false; - while ((str[*i] == ' ' || str[*i] == '\n' || str[*i] == '\r' || str[*i] == '\t' || str[*i] == '\f') - || str[*i] == ',') { - if (str[*i] == ',') { - if (false == hasComma) { - hasComma = true; - } else { // comma only allowed once - t0.n = 0; - return t0; - } + int32_t numOfComma = 0; + char t = str[*i]; + while (t == ' ' || t == '\n' || t == '\r' || t == '\t' || t == '\f' || t == ',') { + if (t == ',' && (++numOfComma > 1)) { // comma only allowed once + t0.n = 0; + return t0; } - (*i)++; + + t = str[++(*i)]; } t0.n = tSQLGetToken(&str[*i], &t0.type); - bool ignoreFlag = false; + bool ignore = false; for (uint32_t k = 0; k < numOfIgnoreToken; k++) { if (t0.type == ignoreTokenTypes[k]) { - ignoreFlag = true; + ignore = true; break; } } - if (!ignoreFlag) { + if (!ignore) { break; } } @@ -662,114 +655,4 @@ SSQLToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn return t0; } -FORCE_INLINE bool isKeyWord(const char* z, int32_t len) { return (tSQLKeywordCode((char*)z, len) != TK_ID); } - -FORCE_INLINE bool isNumber(const SSQLToken* pToken) { - return (pToken->type == TK_INTEGER || pToken->type == TK_FLOAT || pToken->type == TK_HEX || pToken->type == TK_BIN); -} - -int32_t isValidNumber(const SSQLToken* pToken) { - const char* z = pToken->z; - int32_t type = TK_ILLEGAL; - - int32_t i = 0; - for(; i < pToken->n; ++i) { - switch (z[i]) { - case '+': - case '-': { - break; - } - case '.': { - /* - * handle the the float number with out integer part - * .123 - * .123e4 - */ - if (!isdigit(z[i+1])) { - return TK_ILLEGAL; - } - - for (i += 2; isdigit(z[i]); i++) { - } - - if ((z[i] == 'e' || z[i] == 'E') && - (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { - i += 2; - while (isdigit(z[i])) { - i++; - } - } - - type = TK_FLOAT; - goto _end; - } - - case '0': { - char next = z[i + 1]; - if (next == 'b') { // bin number - type = TK_BIN; - for (i += 2; (z[i] == '0' || z[i] == '1'); ++i) { - } - - goto _end; - } else if (next == 'x') { //hex number - type = TK_HEX; - for (i += 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) { - } - - goto _end; - } - } - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - type = TK_INTEGER; - for (; isdigit(z[i]); i++) { - } - - int32_t seg = 0; - while (z[i] == '.' && isdigit(z[i + 1])) { - i += 2; - - while (isdigit(z[i])) { - i++; - } - - seg++; - type = TK_FLOAT; - } - - if (seg > 1) { - return TK_ILLEGAL; - } - - if ((z[i] == 'e' || z[i] == 'E') && - (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { - i += 2; - while (isdigit(z[i])) { - i++; - } - - type = TK_FLOAT; - } - - goto _end; - } - default: - return TK_ILLEGAL; - } - } - - _end: - if (i < pToken->n) { - return TK_ILLEGAL; - } else { - return type; - } -} \ No newline at end of file +bool isKeyWord(const char* z, int32_t len) { return (tSQLKeywordCode((char*)z, len) != TK_ID); } \ No newline at end of file diff --git a/src/query/src/tlosertree.c b/src/query/src/tlosertree.c index 4e3063da03c675999c4f00cae4163b3d163baf37..0d81f4604bfde20548a8eedf0e323a5a7125adf0 100644 --- a/src/query/src/tlosertree.c +++ b/src/query/src/tlosertree.c @@ -54,7 +54,7 @@ uint32_t tLoserTreeCreate(SLoserTreeInfo** pTree, int32_t numOfEntries, void* pa (*pTree)->numOfEntries = numOfEntries; (*pTree)->totalEntries = totalEntries; (*pTree)->param = param; - (*pTree)->comparaFn = compareFn; + (*pTree)->comparFn = compareFn; // set initial value for loser tree tLoserTreeInit(*pTree); @@ -95,7 +95,7 @@ void tLoserTreeAdjust(SLoserTreeInfo* pTree, int32_t idx) { return; } - int32_t ret = pTree->comparaFn(&pTree->pNode[parentId], &kLeaf, pTree->param); + int32_t ret = pTree->comparFn(&pTree->pNode[parentId], &kLeaf, pTree->param); if (ret < 0) { SLoserTreeNode t = pTree->pNode[parentId]; pTree->pNode[parentId] = kLeaf; diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 445e542387961cde730943f02a56c2d9fe81d610..a8bb2fd65b2091e33eb26d3f738cbfe4f736f69e 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -867,9 +867,8 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { // underlying UDP layer does not know it is server or client pRecv->connType = pRecv->connType | pRpc->connType; - if (pRecv->ip==0 && pConn) { - rpcProcessBrokenLink(pConn); - tfree(pRecv->msg); + if (pRecv->ip == 0 && pConn) { + rpcProcessBrokenLink(pConn); return NULL; } @@ -889,12 +888,12 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { rpcSendErrorMsgToPeer(pRecv, code); tTrace("%s %p %p, %s is sent with error code:%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType+1], code); } - } else { // parsing OK + } else { // msg is passed to app only parsing is ok rpcProcessIncomingMsg(pConn, pHead); } } - if (code) rpcFreeMsg(pRecv->msg); + if (code) rpcFreeMsg(pRecv->msg); // parsing failed, msg shall be freed return pConn; } @@ -989,6 +988,7 @@ static void rpcSendQuickRsp(SRpcConn *pConn, int32_t code) { pHead->sourceId = pConn->ownId; pHead->destId = pConn->peerId; pHead->linkUid = pConn->linkUid; + pHead->ahandle = (uint64_t)pConn->ahandle; memcpy(pHead->user, pConn->user, tListLen(pHead->user)); pHead->code = htonl(code); @@ -1011,6 +1011,7 @@ static void rpcSendReqHead(SRpcConn *pConn) { pHead->sourceId = pConn->ownId; pHead->destId = pConn->peerId; pHead->linkUid = pConn->linkUid; + pHead->ahandle = (uint64_t)pConn->ahandle; memcpy(pHead->user, pConn->user, tListLen(pHead->user)); pHead->code = 1; diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 38458c71d21fed1b0eadd67afd80a9d542934de6..a7312fadf1139541a41fa24c3809650b600ece18 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -39,8 +39,8 @@ typedef struct SThreadObj { pthread_t thread; SFdObj * pHead; pthread_mutex_t mutex; - pthread_cond_t fdReady; uint32_t ip; + bool stop; int pollFd; int numOfFds; int threadId; @@ -50,6 +50,7 @@ typedef struct SThreadObj { } SThreadObj; typedef struct { + int fd; uint32_t ip; uint16_t port; char label[12]; @@ -63,7 +64,7 @@ static void *taosProcessTcpData(void *param); static SFdObj *taosMallocFdObj(SThreadObj *pThreadObj, int fd); static void taosFreeFdObj(SFdObj *pFdObj); static void taosReportBrokenLink(SFdObj *pFdObj); -static void taosAcceptTcpConnection(void *arg); +static void* taosAcceptTcpConnection(void *arg); void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) { SServerObj *pServerObj; @@ -95,12 +96,6 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread break;; } - code = pthread_cond_init(&(pThreadObj->fdReady), NULL); - if (code != 0) { - tError("%s init TCP condition variable failed(%s)", label, strerror(errno)); - break; - } - pThreadObj->pollFd = epoll_create(10); // size does not matter if (pThreadObj->pollFd < 0) { tError("%s failed to create TCP epoll", label); @@ -144,28 +139,47 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread return (void *)pServerObj; } +static void taosStopTcpThread(SThreadObj* pThreadObj) { + pThreadObj->stop = true; + + // signal the thread to stop, try graceful method first, + // and use pthread_cancel when failed + struct epoll_event event = { .events = EPOLLIN }; + eventfd_t fd = eventfd(1, 0); + if (fd == -1) { + tError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThreadObj->label, strerror(errno)); + pthread_cancel(pThreadObj->thread); + } else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { + tError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThreadObj->label, strerror(errno)); + pthread_cancel(pThreadObj->thread); + } + + pthread_join(pThreadObj->thread, NULL); + close(pThreadObj->pollFd); + if (fd != -1) { + close(fd); + } + + while (pThreadObj->pHead) { + SFdObj *pFdObj = pThreadObj->pHead; + pThreadObj->pHead = pFdObj->next; + taosFreeFdObj(pFdObj); + } +} + + void taosCleanUpTcpServer(void *handle) { SServerObj *pServerObj = handle; SThreadObj *pThreadObj; if (pServerObj == NULL) return; - pthread_cancel(pServerObj->thread); + shutdown(pServerObj->fd, SHUT_RD); pthread_join(pServerObj->thread, NULL); for (int i = 0; i < pServerObj->numOfThreads; ++i) { pThreadObj = pServerObj->pThreadObj + i; - - while (pThreadObj->pHead) { - SFdObj *pFdObj = pThreadObj->pHead; - pThreadObj->pHead = pFdObj->next; - taosFreeFdObj(pFdObj); - } - - close(pThreadObj->pollFd); - pthread_cancel(pThreadObj->thread); - pthread_join(pThreadObj->thread, NULL); - pthread_cond_destroy(&(pThreadObj->fdReady)); + taosStopTcpThread(pThreadObj); pthread_mutex_destroy(&(pThreadObj->mutex)); } @@ -175,31 +189,32 @@ void taosCleanUpTcpServer(void *handle) { tfree(pServerObj); } -static void taosAcceptTcpConnection(void *arg) { +static void* taosAcceptTcpConnection(void *arg) { int connFd = -1; struct sockaddr_in caddr; - int sockFd; int threadId = 0; SThreadObj *pThreadObj; SServerObj *pServerObj; pServerObj = (SServerObj *)arg; - sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); - if (sockFd < 0) return; + pServerObj->fd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); + if (pServerObj->fd < 0) return NULL; tTrace("%s TCP server is ready, ip:0x%x:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); while (1) { socklen_t addrlen = sizeof(caddr); - connFd = accept(sockFd, (struct sockaddr *)&caddr, &addrlen); - - if (connFd < 0) { + connFd = accept(pServerObj->fd, (struct sockaddr *)&caddr, &addrlen); + if (connFd == -1) { + if (errno == EINVAL) { + tTrace("%s TCP server socket was shutdown, exiting...", pServerObj->label); + break; + } tError("%s TCP accept failure(%s)", pServerObj->label, errno, strerror(errno)); continue; } - tTrace("%s TCP connection from ip:%s:%hu", pServerObj->label, inet_ntoa(caddr.sin_addr), caddr.sin_port); taosKeepTcpAlive(connFd); // pick up the thread to handle this connection @@ -213,13 +228,17 @@ static void taosAcceptTcpConnection(void *arg) { inet_ntoa(caddr.sin_addr), pFdObj->port, pFdObj, pThreadObj->numOfFds); } else { close(connFd); - tError("%s failed to malloc FdObj(%s)", pServerObj->label, strerror(errno)); + tError("%s failed to malloc FdObj(%s) for connection from:%s:%hu", pServerObj->label, strerror(errno), + inet_ntoa(caddr.sin_addr), caddr.sin_port); } // pick up next thread for next connection threadId++; threadId = threadId % pServerObj->numOfThreads; } + + close(pServerObj->fd); + return NULL; } void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *fp, void *shandle) { @@ -237,11 +256,6 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void * return NULL; } - if (pthread_cond_init(&(pThreadObj->fdReady), NULL) != 0) { - tError("%s init TCP condition variable failed(%s)", label, strerror(errno)); - return NULL; - } - pThreadObj->pollFd = epoll_create(10); // size does not matter if (pThreadObj->pollFd < 0) { tError("%s failed to create TCP client epoll", label); @@ -268,17 +282,7 @@ void taosCleanUpTcpClient(void *chandle) { SThreadObj *pThreadObj = chandle; if (pThreadObj == NULL) return; - while (pThreadObj->pHead) { - SFdObj *pFdObj = pThreadObj->pHead; - pThreadObj->pHead = pFdObj->next; - taosFreeFdObj(pFdObj); - } - - close(pThreadObj->pollFd); - - pthread_cancel(pThreadObj->thread); - pthread_join(pThreadObj->thread, NULL); - + taosStopTcpThread(pThreadObj); tTrace (":%s, all connections are cleaned up", pThreadObj->label); tfree(pThreadObj); @@ -337,7 +341,9 @@ static void taosReportBrokenLink(SFdObj *pFdObj) { recvInfo.chandle = NULL; recvInfo.connType = RPC_CONN_TCP; (*(pThreadObj->processData))(&recvInfo); - } + } else { + taosFreeFdObj(pFdObj); + } } #define maxEvents 10 @@ -348,15 +354,13 @@ static void *taosProcessTcpData(void *param) { struct epoll_event events[maxEvents]; SRecvInfo recvInfo; SRpcHead rpcHead; - + while (1) { - pthread_mutex_lock(&pThreadObj->mutex); - if (pThreadObj->numOfFds < 1) { - pthread_cond_wait(&pThreadObj->fdReady, &pThreadObj->mutex); - } - pthread_mutex_unlock(&pThreadObj->mutex); - int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, -1); + if (pThreadObj->stop) { + tTrace("%s, tcp thread get stop event, exiting...", pThreadObj->label); + break; + } if (fdNum < 0) continue; for (int i = 0; i < fdNum; ++i) { @@ -444,7 +448,6 @@ static SFdObj *taosMallocFdObj(SThreadObj *pThreadObj, int fd) { if (pThreadObj->pHead) (pThreadObj->pHead)->prev = pFdObj; pThreadObj->pHead = pFdObj; pThreadObj->numOfFds++; - pthread_cond_signal(&pThreadObj->fdReady); pthread_mutex_unlock(&(pThreadObj->mutex)); return pFdObj; @@ -465,7 +468,7 @@ static void taosFreeFdObj(SFdObj *pFdObj) { pFdObj->signature = NULL; epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_DEL, pFdObj->fd, NULL); - close(pFdObj->fd); + taosCloseSocket(pFdObj->fd); pThreadObj->numOfFds--; @@ -492,5 +495,3 @@ static void taosFreeFdObj(SFdObj *pFdObj) { tfree(pFdObj); } - - diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 3a40f27e26f124a5c3caa40c27481f21a187eb14..6f6014b678f6f3440b5193e74abc12710119b956 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -135,14 +135,15 @@ void taosCleanUpUdpConnection(void *handle) { for (int i = 0; i < pSet->threads; ++i) { pConn = pSet->udpConn + i; pConn->signature = NULL; - free(pConn->buffer); - pthread_cancel(pConn->thread); - taosCloseSocket(pConn->fd); + // shutdown to signal the thread to exit + shutdown(pConn->fd, SHUT_RD); } for (int i = 0; i < pSet->threads; ++i) { pConn = pSet->udpConn + i; pthread_join(pConn->thread, NULL); + free(pConn->buffer); + taosCloseSocket(pConn->fd); tTrace("chandle:%p is closed", pConn); } @@ -177,6 +178,11 @@ static void *taosRecvUdpData(void *param) { while (1) { dataLen = recvfrom(pConn->fd, pConn->buffer, RPC_MAX_UDP_SIZE, 0, (struct sockaddr *)&sourceAdd, &addLen); + if(dataLen == 0) { + tTrace("data length is 0, socket was closed, exiting"); + break; + } + port = ntohs(sourceAdd.sin_port); if (dataLen < sizeof(SRpcHead)) { diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c index 958d099027f2072b82aee45fe302f0042c1fd8aa..508f04fbc349ec5485360e70992c6e35b1f8728c 100644 --- a/src/rpc/test/rserver.c +++ b/src/rpc/test/rserver.c @@ -127,6 +127,8 @@ int main(int argc, char *argv[]) { SRpcInit rpcInit; char dataName[20] = "server.data"; + taosBlockSIGPIPE(); + memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 7000; rpcInit.label = "SER"; diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index 8a0a9e1208b7fb45994be95200a3f2a2a0ceb4ff..4225602292726bc3f75253d2e2fa93bc6bd774e7 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -495,11 +495,12 @@ void tsdbSetHelperTable(SRWHelper *pHelper, STable *pTable, STsdbRepo *pRepo); int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError); // --------- For read operations -int tsdbLoadCompIdx(SRWHelper *pHelper, void *target); -int tsdbLoadCompInfo(SRWHelper *pHelper, void *target); -int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target); -int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, int16_t *colIds, int numOfColIds); -int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *target); +int tsdbLoadCompIdx(SRWHelper *pHelper, void *target); +int tsdbLoadCompInfo(SRWHelper *pHelper, void *target); +int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target); +int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, int16_t *colIds, int numOfColIds); +int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *target); +void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols); // --------- For write operations int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols); diff --git a/src/tsdb/src/tsdbCache.c b/src/tsdb/src/tsdbCache.c index 2761ed5e8eadc1f06e1c307685422c019350d35e..be339d28166938a4d9d762555e6651680358b641 100644 --- a/src/tsdb/src/tsdbCache.c +++ b/src/tsdb/src/tsdbCache.c @@ -162,6 +162,7 @@ int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks) { pCache->totalCacheBlocks = totalBlocks; tsdbAdjustCacheBlocks(pCache); } + pRepo->config.totalBlocks = totalBlocks; tsdbUnLockRepo((TsdbRepoT *)pRepo); tsdbTrace("vgId:%d, tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks, totalBlocks); diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 36cb937d331fcb058596f3b3ebef98cb2f2cd717..a9f0d9b6ec490c1b112c189bc75068ad78d66bc3 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -9,8 +9,6 @@ #include "ttime.h" #include -int tsdbDebugFlag = 135; - #define TSDB_DEFAULT_PRECISION TSDB_PRECISION_MILLI // default precision #define IS_VALID_PRECISION(precision) (((precision) >= TSDB_PRECISION_MILLI) && ((precision) <= TSDB_PRECISION_NANO)) #define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP @@ -39,7 +37,8 @@ static TSKEY tsdbNextIterKey(SSkipListIterator *pIter); static int tsdbHasDataToCommit(SSkipListIterator **iters, int nIters, TSKEY minKey, TSKEY maxKey); static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression); static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep); -static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables); +static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables); +static int32_t tsdbSaveConfig(STsdbRepo *pRepo); #define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid] #define TSDB_GET_TABLE_BY_NAME(pRepo, name) @@ -321,10 +320,25 @@ int32_t tsdbConfigRepo(TsdbRepoT *repo, STsdbCfg *pCfg) { ASSERT(pRCfg->maxRowsPerFileBlock == pCfg->maxRowsPerFileBlock); ASSERT(pRCfg->precision == pCfg->precision); - if (pRCfg->compression != pCfg->compression) tsdbAlterCompression(pRepo, pCfg->compression); - if (pRCfg->keep != pCfg->keep) tsdbAlterKeep(pRepo, pCfg->keep); - if (pRCfg->totalBlocks != pCfg->totalBlocks) tsdbAlterCacheTotalBlocks(pRepo, pCfg->totalBlocks); - if (pRCfg->maxTables != pCfg->maxTables) tsdbAlterMaxTables(pRepo, pCfg->maxTables); + bool configChanged = false; + if (pRCfg->compression != pCfg->compression) { + configChanged = true; + tsdbAlterCompression(pRepo, pCfg->compression); + } + if (pRCfg->keep != pCfg->keep) { + configChanged = true; + tsdbAlterKeep(pRepo, pCfg->keep); + } + if (pRCfg->totalBlocks != pCfg->totalBlocks) { + configChanged = true; + tsdbAlterCacheTotalBlocks(pRepo, pCfg->totalBlocks); + } + if (pRCfg->maxTables != pCfg->maxTables) { + configChanged = true; + tsdbAlterMaxTables(pRepo, pCfg->maxTables); + } + + if (configChanged) tsdbSaveConfig(pRepo); return TSDB_CODE_SUCCESS; } @@ -1136,8 +1150,10 @@ static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) { int maxFiles = keep / pCfg->maxTables + 3; if (pRepo->config.keep > keep) { + pRepo->config.keep = keep; pRepo->tsdbFileH->maxFGroups = maxFiles; } else { + pRepo->config.keep = keep; pRepo->tsdbFileH->fGroup = realloc(pRepo->tsdbFileH->fGroup, sizeof(SFileGroup)); if (pRepo->tsdbFileH->fGroup == NULL) { // TODO: deal with the error @@ -1157,6 +1173,8 @@ static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) { pMeta->maxTables = maxTables; pMeta->tables = realloc(pMeta->tables, maxTables * sizeof(STable *)); + memset(&pMeta->tables[oldMaxTables], 0, sizeof(STable *) * (maxTables-oldMaxTables)); + pRepo->config.maxTables = maxTables; tsdbTrace("vgId:%d, tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables); } diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 55162314833f0e018401df593b9f7d3e55f78ad2..95680f95c4565a500a00b14e8dfec9de91d902fe 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -16,7 +16,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbEstimateTableEncodeSize(STable *pTable); -static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable); +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable, bool rmFromIdx); /** * Encode a TSDB table object as a binary content @@ -127,7 +127,7 @@ int tsdbRestoreTable(void *pHandle, void *cont, int contLen) { if (pTable->type == TSDB_SUPER_TABLE) { STColumn* pColSchema = schemaColAt(pTable->tagSchema, 0); pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes, - 1, 0, 0, getTagIndexKey); + 1, 0, 1, getTagIndexKey); } tsdbAddTableToMeta(pMeta, pTable, false); @@ -154,6 +154,7 @@ STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables) { STsdbMeta *pMeta = (STsdbMeta *)malloc(sizeof(STsdbMeta)); if (pMeta == NULL) return NULL; + pMeta->maxTables = maxTables; pMeta->nTables = 0; pMeta->superList = NULL; pMeta->tables = (STable **)calloc(maxTables, sizeof(STable *)); @@ -288,6 +289,13 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { if (tsdbCheckTableCfg(pCfg) < 0) return -1; + STable *pTable = tsdbGetTableByUid(pMeta, pCfg->tableId.uid); + if (pTable != NULL) { + tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, pRepo->config.tsdbId, varDataVal(pTable->name), + pTable->tableId.tid, pTable->tableId.uid); + return TSDB_CODE_TABLE_ALREADY_EXIST; + } + STable *super = NULL; int newSuper = 0; @@ -315,7 +323,7 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { // index the first tag column STColumn* pColSchema = schemaColAt(super->tagSchema, 0); super->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes, - 1, 0, 0, getTagIndexKey); // Allow duplicate key, no lock + 1, 0, 1, getTagIndexKey); // Allow duplicate key, no lock if (super->pIndex == NULL) { tdFreeSchema(super->schema); @@ -410,7 +418,7 @@ int tsdbDropTable(TsdbRepoT *repo, STableId tableId) { tsdbTrace("vgId:%d, table %s is dropped! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, varDataVal(pTable->name), tableId.tid, tableId.uid); - if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1; + if (tsdbRemoveTableFromMeta(pMeta, pTable, true) < 0) return -1; return 0; @@ -439,6 +447,7 @@ static int tsdbFreeTable(STable *pTable) { // Free content if (TSDB_TABLE_IS_SUPER_TABLE(pTable)) { + tdFreeSchema(pTable->tagSchema); tSkipListDestroy(pTable->pIndex); } @@ -499,7 +508,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { return 0; } -static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable, bool rmFromIdx) { if (pTable->type == TSDB_SUPER_TABLE) { SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); while (tSkipListIterNext(pIter)) { @@ -508,7 +517,7 @@ static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE); - tsdbRemoveTableFromMeta(pMeta, tTable); + tsdbRemoveTableFromMeta(pMeta, tTable, false); } tSkipListDestroyIter(pIter); @@ -524,7 +533,7 @@ static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { } } else { pMeta->tables[pTable->tableId.tid] = NULL; - if (pTable->type == TSDB_CHILD_TABLE) { + if (pTable->type == TSDB_CHILD_TABLE && rmFromIdx) { tsdbRemoveTableFromIndex(pMeta, pTable); } @@ -571,9 +580,21 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN]; char* key = tdGetRowDataOfCol(pTable->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); - bool ret = tSkipListRemove(pSTable->pIndex, key); + SArray* res = tSkipListGet(pSTable->pIndex, key); + + size_t size = taosArrayGetSize(res); + assert(size > 0); + + for(int32_t i = 0; i < size; ++i) { + SSkipListNode* pNode = taosArrayGetP(res, i); + + STableIndexElem* pElem = (STableIndexElem*) SL_GET_NODE_DATA(pNode); + if (pElem->pTable == pTable) { // this is the exact what we need + tSkipListRemoveNode(pSTable->pIndex, pNode); + } + } - assert(ret); + taosArrayDestroy(res); return 0; } diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index c5ef00c2332b071e03133c3f1cd21aecccf93365..82584fc5df7e846d7a4ad5eed0e3f07c657cb51e 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -409,7 +409,7 @@ int tsdbWriteCompInfo(SRWHelper *pHelper) { if (pIdx->offset > 0) { pIdx->offset = lseek(pHelper->files.nHeadF.fd, 0, SEEK_END); if (pIdx->offset < 0) return -1; - ASSERT(pIdx->offset >= tsizeof(pHelper->pCompIdx)); + ASSERT(pIdx->offset >= TSDB_FILE_HEAD_SIZE); if (tsendfile(pHelper->files.nHeadF.fd, pHelper->files.headF.fd, NULL, pIdx->len) < pIdx->len) return -1; } @@ -489,6 +489,7 @@ int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) { } ASSERT(((char *)ptr - (char *)pHelper->pBuffer) == (pFile->info.len - sizeof(TSCKSUM))); + if (lseek(fd, TSDB_FILE_HEAD_SIZE, SEEK_SET) < 0) return -1; } } @@ -542,6 +543,34 @@ int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target) { return 0; } +void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols) { + SCompData *pCompData = pHelper->pCompData; + + for (int i = 0, j = 0; i < numOfCols;) { + if (j >= pCompData->numOfCols) { + pStatis[i].numOfNull = -1; + i++; + continue; + } + + if (pStatis[i].colId == pCompData->cols[j].colId) { + pStatis[i].sum = pCompData->cols[j].sum; + pStatis[i].max = pCompData->cols[j].max; + pStatis[i].min = pCompData->cols[j].min; + pStatis[i].maxIndex = pCompData->cols[j].maxIndex; + pStatis[i].minIndex = pCompData->cols[j].minIndex; + pStatis[i].numOfNull = pCompData->cols[j].numOfNull; + i++; + j++; + } else if (pStatis[i].colId < pCompData->cols[j].colId) { + pStatis[i].numOfNull = -1; + i++; + } else { + j++; + } + } +} + static int comparColIdCompCol(const void *arg1, const void *arg2) { return (*(int16_t *)arg1) - ((SCompCol *)arg2)->colId; } @@ -747,7 +776,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa pCompCol->colId = pDataCol->colId; pCompCol->type = pDataCol->type; - if (tDataTypeDesc[pDataCol->type].getStatisFunc) { + if (tDataTypeDesc[pDataCol->type].getStatisFunc && ncol != 0) { (*tDataTypeDesc[pDataCol->type].getStatisFunc)( (TSKEY *)(pDataCols->cols[0].pData), pDataCol->pData, rowsToWrite, &(pCompCol->min), &(pCompCol->max), &(pCompCol->sum), &(pCompCol->minIndex), &(pCompCol->maxIndex), &(pCompCol->numOfNull)); diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index d6a070589dc170fefd463409505932a921022b6e..b5340d4ba9455c128de6979ab21a0ff0952886d8 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -26,7 +26,7 @@ #include "tsdbMain.h" #define EXTRA_BYTES 2 -#define ASCENDING_ORDER_TRAVERSE(o) (o == TSDB_ORDER_ASC) +#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) #define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns))) enum { @@ -49,6 +49,10 @@ typedef struct SQueryFilePos { int32_t slot; int32_t pos; int64_t lastKey; + int32_t rows; + bool mixBlock; + bool blockCompleted; + STimeWindow win; } SQueryFilePos; typedef struct SDataBlockLoadInfo { @@ -61,7 +65,6 @@ typedef struct SDataBlockLoadInfo { typedef struct SLoadCompBlockInfo { int32_t tid; /* table tid */ int32_t fileId; - int32_t fileListIndex; } SLoadCompBlockInfo; typedef struct STableCheckInfo { @@ -71,10 +74,13 @@ typedef struct STableCheckInfo { int32_t start; SCompInfo* pCompInfo; int32_t compSize; - int32_t numOfBlocks; // number of qualified data blocks not the original blocks + int32_t numOfBlocks; // number of qualified data blocks not the original blocks SDataCols* pDataCols; - SSkipListIterator* iter; + SSkipListIterator* iter; // skip list iterator + SSkipListIterator* iiter; // imem iterator + + bool initBuf; // if we should initialize the in-memory skip list iterator } STableCheckInfo; typedef struct { @@ -110,6 +116,7 @@ typedef struct STsdbQueryHandle { SField** pFields; SArray* pColumns; // column list, SColumnInfoData array list bool locateStart; + int32_t outputCapacity; int32_t realNumOfRows; SArray* pTableCheckInfo; //SArray int32_t activeIndex; @@ -134,7 +141,6 @@ static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { static void tsdbInitCompBlockLoadInfo(SLoadCompBlockInfo* pCompBlockLoadInfo) { pCompBlockLoadInfo->tid = -1; pCompBlockLoadInfo->fileId = -1; - pCompBlockLoadInfo->fileListIndex = -1; } TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList) { @@ -149,6 +155,7 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable tsdbInitReadHelper(&pQueryHandle->rhelper, (STsdbRepo*) tsdb); pQueryHandle->cur.fid = -1; + pQueryHandle->cur.win = TSWINDOW_INITIALIZER; size_t sizeOfGroup = taosArrayGetSize(groupList->pGroupList); assert(sizeOfGroup >= 1 && pCond != NULL && pCond->numOfCols > 0); @@ -181,20 +188,20 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable * For ascending timestamp order query, query starts from data files. In contrast, buffer will be checked in the first place * in case of descending timestamp order query. */ - pQueryHandle->checkFiles = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order); + pQueryHandle->checkFiles = true;//ASCENDING_TRAVERSE(pQueryHandle->order); pQueryHandle->activeIndex = 0; // allocate buffer in order to load data blocks from file int32_t numOfCols = pCond->numOfCols; - size_t bufferCapacity = 4096; - + pQueryHandle->outputCapacity = 4096; + pQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); for (int32_t i = 0; i < pCond->numOfCols; ++i) { - SColumnInfoData pDest = {{0}, 0}; - - pDest.info = pCond->colList[i]; - pDest.pData = calloc(1, EXTRA_BYTES + bufferCapacity * pCond->colList[i].bytes); - taosArrayPush(pQueryHandle->pColumns, &pDest); + SColumnInfoData colInfo = {{0}, 0}; + + colInfo.info = pCond->colList[i]; + colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCond->colList[i].bytes); + taosArrayPush(pQueryHandle->pColumns, &colInfo); } tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo); @@ -223,6 +230,72 @@ TsdbQueryHandleT tsdbQueryRowsInExternalWindow(TsdbRepoT *tsdb, STsdbQueryCond* return pQueryHandle; } +static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCheckInfo) { + STable* pTable = pCheckInfo->pTableObj; + assert(pTable != NULL); + + if (pCheckInfo->initBuf) { + return true; + } + + pCheckInfo->initBuf = true; + int32_t order = pHandle->order; + + // no data in buffer, abort + if (pTable->mem == NULL && pTable->imem == NULL) { + return false; + } + + assert(pCheckInfo->iter == NULL && pCheckInfo->iiter == NULL); + + if (pTable->mem) { + pCheckInfo->iter = tSkipListCreateIterFromVal(pTable->mem->pData, (const char*) &pCheckInfo->lastKey, + TSDB_DATA_TYPE_TIMESTAMP, order); + } + + if (pTable->imem) { + pCheckInfo->iiter = tSkipListCreateIterFromVal(pTable->imem->pData, (const char*) &pCheckInfo->lastKey, + TSDB_DATA_TYPE_TIMESTAMP, order); + } + + // both iterators are NULL, no data in buffer right now + if (pCheckInfo->iter == NULL && pCheckInfo->iiter == NULL) { + return false; + } + + bool memEmpty = (pCheckInfo->iter == NULL) || (pCheckInfo->iter != NULL && !tSkipListIterNext(pCheckInfo->iter)); + bool imemEmpty = (pCheckInfo->iiter == NULL) || (pCheckInfo->iiter != NULL && !tSkipListIterNext(pCheckInfo->iiter)); + if (memEmpty && imemEmpty) { // buffer is empty + return false; + } + + if (!memEmpty) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); + assert(node != NULL); + + SDataRow row = SL_GET_NODE_DATA(node); + TSKEY key = dataRowKey(row); // first timestamp in buffer + uTrace("%p uid:%" PRId64", tid:%d check data in mem from skey:%" PRId64 ", order:%d, %p", pHandle, + pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo); + } else { + uTrace("%p uid:%" PRId64 ", tid:%d no data in mem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid); + } + + if (!imemEmpty) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); + assert(node != NULL); + + SDataRow row = SL_GET_NODE_DATA(node); + TSKEY key = dataRowKey(row); // first timestamp in buffer + uTrace("%p uid:%" PRId64", tid:%d check data in imem from skey:%" PRId64 ", order:%d, %p", pHandle, + pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo); + } else { + uTrace("%p uid:%"PRId64", tid:%d no data in imem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid); + } + + return true; +} + static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { size_t size = taosArrayGetSize(pHandle->pTableCheckInfo); assert(pHandle->activeIndex < size && pHandle->activeIndex >= 0 && size >= 1); @@ -245,12 +318,12 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { if (pCheckInfo->iter == NULL) { return false; } - } - if (!tSkipListIterNext(pCheckInfo->iter)) { // buffer is empty - return false; + if (!tSkipListIterNext(pCheckInfo->iter)) { // buffer is empty + return false; + } } - + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); if (node == NULL) { return false; @@ -262,17 +335,16 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qinfo); // all data in mem are checked already. - if ((pCheckInfo->lastKey > pHandle->window.ekey && ASCENDING_ORDER_TRAVERSE(pHandle->order)) || - (pCheckInfo->lastKey < pHandle->window.ekey && !ASCENDING_ORDER_TRAVERSE(pHandle->order))) { + if ((pCheckInfo->lastKey > pHandle->window.ekey && ASCENDING_TRAVERSE(pHandle->order)) || + (pCheckInfo->lastKey < pHandle->window.ekey && !ASCENDING_TRAVERSE(pHandle->order))) { return false; } return true; } -// todo dynamic get the daysperfile -static int32_t getFileIdFromKey(TSKEY key) { - int64_t fid = (int64_t)(key / (10 * tsMsPerDay[0])); // set the starting fileId +static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile) { + int64_t fid = (int64_t)(key / (daysPerFile * tsMsPerDay[0])); // set the starting fileId if (fid > INT32_MAX) { fid = INT32_MAX; } @@ -322,8 +394,10 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); SCompIdx* compIndex = &pQueryHandle->rhelper.pCompIdx[pCheckInfo->tableId.tid]; - if (compIndex->len == 0 || compIndex->numOfBlocks == 0) { // no data block in this file, try next file - continue;//no data blocks in the file belongs to pCheckInfo->pTable + if (compIndex->len == 0 || compIndex->numOfBlocks == 0 || + compIndex->uid != pCheckInfo->tableId.uid) { // no data block in this file, try next file + pCheckInfo->numOfBlocks = 0; + continue; // no data blocks in the file belongs to pCheckInfo->pTable } else { if (pCheckInfo->compSize < compIndex->len) { assert(compIndex->len > 0); @@ -409,9 +483,11 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS return pLocalIdList; } -static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, +static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, SArray* sa); static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); +static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY maxKey, int maxRowsToRead, TSKEY* skey, TSKEY* ekey, + STsdbQueryHandle* pQueryHandle); static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) { STsdbRepo *pRepo = pQueryHandle->pTsdb; @@ -445,34 +521,116 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo return blockLoaded; } +static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){ + SArray* sa = getDefaultLoadColumns(pQueryHandle, true); + + SQueryFilePos* cur = &pQueryHandle->cur; + SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock); + /*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo); + + TSKEY k1 = TSKEY_INITIAL_VAL, k2 = TSKEY_INITIAL_VAL; + if (pCheckInfo->iter != NULL && tSkipListIterGet(pCheckInfo->iter) != NULL) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); + + SDataRow row = SL_GET_NODE_DATA(node); + k1 = dataRowKey(row); + + if (k1 == binfo.window.skey) { + if (tSkipListIterNext(pCheckInfo->iter)) { + node = tSkipListIterGet(pCheckInfo->iter); + row = SL_GET_NODE_DATA(node); + k1 = dataRowKey(row); + } else { + k1 = TSKEY_INITIAL_VAL; + } + } + } + + if (pCheckInfo->iiter != NULL && tSkipListIterGet(pCheckInfo->iiter) != NULL) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); + + SDataRow row = SL_GET_NODE_DATA(node); + k2 = dataRowKey(row); + + if (k2 == binfo.window.skey) { + if (tSkipListIterNext(pCheckInfo->iiter)) { + node = tSkipListIterGet(pCheckInfo->iiter); + row = SL_GET_NODE_DATA(node); + k2 = dataRowKey(row); + } else { + k2 = TSKEY_INITIAL_VAL; + } + } + } + + cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1); + + if ((ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 <= binfo.window.ekey) || (k2 != TSKEY_INITIAL_VAL && k2 <= binfo.window.ekey))) || + (!ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 >= binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 >= binfo.window.skey)))) { + + if ((ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 < binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 < binfo.window.skey))) || + (!ASCENDING_TRAVERSE(pQueryHandle->order) && + (((k1 != TSKEY_INITIAL_VAL && k1 > binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 > binfo.window.skey))))) { + // do not load file block into buffer + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1; + + cur->rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, binfo.window.skey - step, + pQueryHandle->outputCapacity, &cur->win.skey, &cur->win.ekey, pQueryHandle); + pQueryHandle->realNumOfRows = cur->rows; + + // update the last key value + pCheckInfo->lastKey = cur->win.ekey + step; + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { + SWAP(cur->win.skey, cur->win.ekey, TSKEY); + } + + cur->mixBlock = true; + cur->blockCompleted = false; + return; + } + + doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); + } else { + pQueryHandle->realNumOfRows = binfo.rows; + + cur->rows = binfo.rows; + cur->win = binfo.window; + cur->mixBlock = false; + cur->blockCompleted = true; + cur->lastKey = binfo.window.ekey + (ASCENDING_TRAVERSE(pQueryHandle->order)? 1:-1); + } +} + static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) { SArray* sa = getDefaultLoadColumns(pQueryHandle, true); SQueryFilePos* cur = &pQueryHandle->cur; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { // query ended in current block if (pQueryHandle->window.ekey < pBlock->keyLast || pCheckInfo->lastKey > pBlock->keyFirst) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { return false; } - SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; - assert(pCols->numOfPoints == pBlock->numOfPoints); + SDataCols* pTSCol = pQueryHandle->rhelper.pDataCols[0]; + assert(pTSCol->cols->type == TSDB_DATA_TYPE_TIMESTAMP && pTSCol->numOfPoints == pBlock->numOfPoints); if (pCheckInfo->lastKey > pBlock->keyFirst) { cur->pos = - binarySearchForKey(pCols->cols[0].pData, pBlock->numOfPoints, pCheckInfo->lastKey, pQueryHandle->order); + binarySearchForKey(pTSCol->cols[0].pData, pBlock->numOfPoints, pCheckInfo->lastKey, pQueryHandle->order); } else { cur->pos = 0; } - - filterDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); + + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); } else { // the whole block is loaded in to buffer - pQueryHandle->realNumOfRows = pBlock->numOfPoints; - cur->pos = 0; + handleDataMergeIfNeeded(pQueryHandle, pBlock, pCheckInfo); } - } else { - // query ended in current block + } else { //desc order, query ended in current block if (pQueryHandle->window.ekey > pBlock->keyFirst) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { return false; @@ -486,10 +644,9 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock cur->pos = pBlock->numOfPoints - 1; } - filterDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); } else { - pQueryHandle->realNumOfRows = pBlock->numOfPoints; - cur->pos = pBlock->numOfPoints - 1; + handleDataMergeIfNeeded(pQueryHandle, pBlock, pCheckInfo); } } @@ -559,87 +716,297 @@ static int vnodeBinarySearchKey(char* pValue, int num, TSKEY key, int order) { return midPos; } +static int32_t copyDataFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity, int32_t numOfRows, int32_t start, int32_t end) { + char* pData = NULL; + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order)? 1 : -1; + + SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; + TSKEY* tsArray = pCols->cols[0].pData; + + int32_t num = end - start + 1; + int32_t requiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); + + //data in buffer has greater timestamp, copy data in file block + for (int32_t i = 0; i < requiredNumOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); + int32_t bytes = pColInfo->info.bytes; + + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; + } else { + pData = pColInfo->pData + (capacity - numOfRows - num) * pColInfo->info.bytes; + } + + for (int32_t j = 0; j < pCols->numOfCols; ++j) { // todo opt performance + SDataCol* src = &pCols->cols[j]; + + if (pColInfo->info.colId == src->colId) { + + if (pColInfo->info.type != TSDB_DATA_TYPE_BINARY && pColInfo->info.type != TSDB_DATA_TYPE_NCHAR) { + memmove(pData, src->pData + bytes * start, bytes * num); + } else { // handle the var-string + char* dst = pData; + + // todo refactor, only copy one-by-one + for (int32_t k = start; k < num + start; ++k) { + char* p = tdGetColDataOfRow(src, k); + memcpy(dst, p, varDataTLen(p)); + dst += bytes; + } + } + + break; + } + } + } + + pQueryHandle->cur.win.ekey = tsArray[end]; + pQueryHandle->cur.lastKey = tsArray[end] + step; + + return numOfRows + num; +} + +static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, int32_t capacity, + int32_t numOfRows, SDataRow row, STSchema* pSchema) { + int32_t numOfCols = taosArrayGetSize(pQueryHandle->pColumns); + int32_t numOfTableCols = schemaNCols(pSchema); + + char* pData = NULL; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); + + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; + } else { + pData = pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes; + } + + int32_t offset = 0; + for (int32_t j = 0; j < numOfTableCols; ++j) { + if (pColInfo->info.colId == pSchema->columns[j].colId) { + offset = pSchema->columns[j].offset; + break; + } + } + + assert(offset != -1); // todo handle error + void* value = tdGetRowDataOfCol(row, pColInfo->info.type, TD_DATA_ROW_HEAD_SIZE + offset); + + if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) { + memcpy(pData, value, varDataTLen(value)); + } else { + memcpy(pData, value, pColInfo->info.bytes); + } + } +} + // only return the qualified data to client in terms of query time window, data rows in the same block but do not // be included in the query time window will be discarded -static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, +static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, SArray* sa) { SQueryFilePos* cur = &pQueryHandle->cur; SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock); + initTableMemIterator(pQueryHandle, pCheckInfo); SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; int32_t endPos = cur->pos; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { + if (ASCENDING_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { endPos = blockInfo.rows - 1; - pQueryHandle->realNumOfRows = endPos - cur->pos + 1; - pCheckInfo->lastKey = blockInfo.window.ekey + 1; - } else if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey < blockInfo.window.skey) { + cur->mixBlock = (cur->pos != 0); + } else if (!ASCENDING_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey < blockInfo.window.skey) { endPos = 0; - pQueryHandle->realNumOfRows = cur->pos + 1; - pCheckInfo->lastKey = blockInfo.window.ekey - 1; + cur->mixBlock = (cur->pos != blockInfo.rows - 1); } else { int32_t order = (pQueryHandle->order == TSDB_ORDER_ASC)? TSDB_ORDER_DESC:TSDB_ORDER_ASC; endPos = vnodeBinarySearchKey(pCols->cols[0].pData, pCols->numOfPoints, pQueryHandle->window.ekey, order); + cur->mixBlock = true; + } + + // compared with the data from in-memory buffer, to generate the correct timestamp array list + int32_t pos = cur->pos; + + assert(pCols->cols[0].type == TSDB_DATA_TYPE_TIMESTAMP && pCols->cols[0].colId == 0); + TSKEY* tsArray = pCols->cols[0].pData; + + int32_t numOfRows = 0; + pQueryHandle->cur.win = TSWINDOW_INITIALIZER; + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order)? 1:-1; + + // no data in buffer, load data from file directly + if (pCheckInfo->iiter == NULL && pCheckInfo->iter == NULL) { + int32_t start = cur->pos; + int32_t end = endPos; + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { + end = cur->pos; + start = endPos; + } + + cur->win.skey = tsArray[start]; + cur->win.ekey = tsArray[end]; + + // todo opt in case of no data in buffer + numOfRows = copyDataFromFileBlock(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, start, end); + + // if the buffer is not full in case of descending order query, move the data in the front of the buffer + if (!ASCENDING_TRAVERSE(pQueryHandle->order) && numOfRows < pQueryHandle->outputCapacity) { + int32_t emptySize = pQueryHandle->outputCapacity - numOfRows; + int32_t reqNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); + + for(int32_t i = 0; i < reqNumOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); + memmove(pColInfo->pData, pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + } + } + + pos += (end - start + 1) * step; + cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))); + + pCheckInfo->lastKey = cur->lastKey; + pQueryHandle->realNumOfRows = numOfRows; + cur->rows = numOfRows; + return; + } else if (pCheckInfo->iter != NULL && pCheckInfo->iiter == NULL) { + // } else if (pCheckInfo->iter == NULL && pCheckInfo->iiter != NULL) { + // } else { // iter and iiter are all not NULL, three-way merge data block + STSchema* pSchema = tsdbGetTableSchema(tsdbGetMeta(pQueryHandle->pTsdb), pCheckInfo->pTableObj); + SSkipListNode* node = NULL; + + do { + node = tSkipListIterGet(pCheckInfo->iter); + if (node == NULL) { + break; + } - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { - if (endPos < cur->pos) { - pQueryHandle->realNumOfRows = 0; - return; - } else { - pQueryHandle->realNumOfRows = endPos - cur->pos + 1; + SDataRow row = SL_GET_NODE_DATA(node); + TSKEY key = dataRowKey(row); + if ((key > pQueryHandle->window.ekey && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < pQueryHandle->window.ekey && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + break; } - pCheckInfo->lastKey = ((int64_t*)(pCols->cols[0].pData))[endPos] + 1; - } else { - if (endPos > cur->pos) { - pQueryHandle->realNumOfRows = 0; - return; - } else { - pQueryHandle->realNumOfRows = cur->pos - endPos + 1; + if (((tsArray[pos] > pQueryHandle->window.ekey || pos > endPos) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((tsArray[pos] < pQueryHandle->window.ekey || pos < endPos) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + break; } - } - } - int32_t start = MIN(cur->pos, endPos); - -// if (start > 0) { -// tdPopDataColsPoints(pQueryHandle->rhelper.pDataCols[0], start); -// } + if ((key < tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key > tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + copyOneRowFromMem(pQueryHandle, pCheckInfo, pQueryHandle->outputCapacity, numOfRows, row, pSchema); + numOfRows += 1; + if (cur->win.skey == TSKEY_INITIAL_VAL) { + cur->win.skey = key; + } - // move the data block in the front to data block if needed - int32_t numOfCols = pQueryHandle->rhelper.pDataCols[0]->numOfCols; - int32_t reqCols = taosArrayGetSize(pQueryHandle->pColumns); - - for (int32_t i = 0; i < reqCols; ++i) { - SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); - int32_t bytes = pCol->info.bytes; + cur->win.ekey = key; + cur->lastKey = key + step; + cur->mixBlock = true; + + tSkipListIterNext(pCheckInfo->iter); + } else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it + tSkipListIterNext(pCheckInfo->iter); + } else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + if (cur->win.skey == TSKEY_INITIAL_VAL) { + cur->win.skey = tsArray[pos]; + } - for (int32_t j = 0; j < numOfCols; ++j) { //todo opt performance - SDataCol* src = &pQueryHandle->rhelper.pDataCols[0]->cols[j]; + int32_t order = ASCENDING_TRAVERSE(pQueryHandle->order) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; + int32_t end = vnodeBinarySearchKey(pCols->cols[0].pData, pCols->numOfPoints, key, order); + if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it + tSkipListIterNext(pCheckInfo->iter); + } + + int32_t start = -1; + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + int32_t remain = end - pos + 1; + if (remain + numOfRows > pQueryHandle->outputCapacity) { + end = (pQueryHandle->outputCapacity - numOfRows) + pos - 1; + } - if (pCol->info.colId == src->colId) { - if (pCol->info.type != TSDB_DATA_TYPE_BINARY && pCol->info.type != TSDB_DATA_TYPE_NCHAR) { - memmove(pCol->pData, src->pData + bytes * start, bytes * pQueryHandle->realNumOfRows); - } else { // handle the var-string - char* dst = pCol->pData; - - // todo refactor, only copy one-by-one - for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) { - char* p = tdGetColDataOfRow(src, k); - memcpy(dst, p, varDataTLen(p)); - dst += bytes; + start = pos; + } else { + int32_t remain = (pos - end) + 1; + if (remain + numOfRows > pQueryHandle->outputCapacity) { + end = pos + 1 - (pQueryHandle->outputCapacity - numOfRows); } + + start = end; + end = pos; } - - break; + + numOfRows = copyDataFromFileBlock(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, start, end); + pos += (end - start + 1) * step; + } + } while (numOfRows < pQueryHandle->outputCapacity); + + if (numOfRows < pQueryHandle->outputCapacity) { + /** + * if cache is empty, load remain file block data. In contrast, if there are remain data in cache, do NOT + * copy them all to result buffer, since it may be overlapped with file data block. + */ + if (node == NULL || + ((dataRowKey(SL_GET_NODE_DATA(node)) > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((dataRowKey(SL_GET_NODE_DATA(node)) < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + // no data in cache or data in cache is greater than the ekey of time window, load data from file block + if (cur->win.skey == TSKEY_INITIAL_VAL) { + cur->win.skey = tsArray[pos]; + } + + int32_t start = -1; + int32_t end = -1; + + // all remain data are qualified, but check the remain capacity in the first place. + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + int32_t remain = endPos - pos + 1; + if (remain + numOfRows > pQueryHandle->outputCapacity) { + endPos = (pQueryHandle->outputCapacity - numOfRows) + pos - 1; + } + + start = pos; + end = endPos; + } else { + int32_t remain = pos + 1; + if (remain + numOfRows > pQueryHandle->outputCapacity) { + endPos = pos + 1 - (pQueryHandle->outputCapacity - numOfRows); + } + + start = endPos; + end = pos; + } + + numOfRows = copyDataFromFileBlock(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, start, end); + pos += (end - start + 1) * step; } } } + + cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))); - assert(pQueryHandle->realNumOfRows <= blockInfo.rows); + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { + SWAP(cur->win.skey, cur->win.ekey, TSKEY); + + // if the buffer is not full in case of descending order query, move the data in the front of the buffer + if (numOfRows < pQueryHandle->outputCapacity) { + int32_t emptySize = pQueryHandle->outputCapacity - numOfRows; + + int32_t requiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); + for(int32_t i = 0; i < requiredNumOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); + memmove(pColInfo->pData, pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + } + } + } + + pCheckInfo->lastKey = cur->lastKey; + pQueryHandle->realNumOfRows = numOfRows; + cur->rows = numOfRows; + cur->pos = pos; - // forward(backward) the position for cursor - cur->pos = endPos; + uTrace("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" %p", pQueryHandle, cur->win.skey, + cur->win.ekey, cur->rows, pQueryHandle->qinfo); } int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) { @@ -852,7 +1219,7 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) { int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) { - int32_t type = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL; + int32_t type = ASCENDING_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL; if (getFileCompInfo(pQueryHandle, &numOfBlocks, type) != TSDB_CODE_SUCCESS) { break; } @@ -879,19 +1246,16 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) { // no data in file anymore if (pQueryHandle->numOfBlocks <= 0) { assert(pQueryHandle->pFileGroup == NULL); - cur->fid = -1; + cur->fid = -1; // denote that there are no data in file anymore return false; } - cur->slot = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1; + cur->slot = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1; cur->fid = pQueryHandle->pFileGroup->fileId; STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot]; - STableCheckInfo* pCheckInfo = pBlockInfo->pTableCheckInfo; - SCompBlock* pBlock = pBlockInfo->pBlock.compBlock; - - return loadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); + return loadFileDataBlock(pQueryHandle, pBlockInfo->pBlock.compBlock, pBlockInfo->pTableCheckInfo); } static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { @@ -901,30 +1265,37 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { // find the start data block in file if (!pQueryHandle->locateStart) { pQueryHandle->locateStart = true; - - int32_t fid = getFileIdFromKey(pQueryHandle->window.skey); + int32_t fid = getFileIdFromKey(pQueryHandle->window.skey, pQueryHandle->pTsdb->config.daysPerFile); tsdbInitFileGroupIter(pFileHandle, &pQueryHandle->fileIter, pQueryHandle->order); tsdbSeekFileGroupIter(&pQueryHandle->fileIter, fid); return getDataBlocksInFilesImpl(pQueryHandle); } else { - if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (cur->slot == 0 && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { // all blocks - - return getDataBlocksInFilesImpl(pQueryHandle); - } else { // next block of the same file - int32_t step = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 1:-1; - cur->slot += step; - - STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot]; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { - cur->pos = 0; + // check if current file block is all consumed + STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot]; + STableCheckInfo* pCheckInfo = pBlockInfo->pTableCheckInfo; + + // current block is done, try next + if (!cur->mixBlock || cur->blockCompleted) { + if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (cur->slot == 0 && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + // all data blocks in current file has been checked already, try next file if exists + return getDataBlocksInFilesImpl(pQueryHandle); } else { - cur->pos = pBlockInfo->pBlock.compBlock->numOfPoints - 1; + // next block of the same file + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1; + cur->slot += step; + + cur->mixBlock = false; + cur->blockCompleted = false; + + STableBlockInfo* pNext = &pQueryHandle->pDataBlockInfo[cur->slot]; + return loadFileDataBlock(pQueryHandle, pNext->pBlock.compBlock, pNext->pTableCheckInfo); } - - return loadFileDataBlock(pQueryHandle, pBlockInfo->pBlock.compBlock, pBlockInfo->pTableCheckInfo); + } else { + handleDataMergeIfNeeded(pQueryHandle, pBlockInfo->pBlock.compBlock, pCheckInfo); + return pQueryHandle->realNumOfRows > 0; } } } @@ -951,33 +1322,23 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pqHandle) { size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); assert(numOfTables > 0); - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { - if (pQueryHandle->checkFiles) { - if (getDataBlocksInFiles(pQueryHandle)) { - return true; - } - - pQueryHandle->activeIndex = 0; - pQueryHandle->checkFiles = false; - } - - return doHasDataInBuffer(pQueryHandle); - } else { // starts from the buffer in case of descending timestamp order check data blocks - if (!pQueryHandle->checkFiles) { - if (doHasDataInBuffer(pQueryHandle)) { - return true; - } - - pQueryHandle->checkFiles = true; + if (pQueryHandle->checkFiles) { + if (getDataBlocksInFiles(pQueryHandle)) { + return true; } - - return getDataBlocksInFiles(pQueryHandle); + + pQueryHandle->activeIndex = 0; + pQueryHandle->checkFiles = false; } + + // TODO: opt by using lastKeyOnFile + // TODO: opt by consider the scan order + return doHasDataInBuffer(pQueryHandle); } void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pqHandle; - assert(!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)); + assert(!ASCENDING_TRAVERSE(pQueryHandle->order)); // starts from the buffer in case of descending timestamp order check data blocks @@ -1022,6 +1383,8 @@ void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { taosArrayDestroy(pQueryHandle->pTableCheckInfo); pQueryHandle->pTableCheckInfo = taosArrayInit(1, sizeof(STableCheckInfo)); + + info.lastKey = key; taosArrayPush(pQueryHandle->pTableCheckInfo, &info); // update the query time window according to the chosen last timestamp @@ -1032,7 +1395,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY STsdbQueryHandle* pQueryHandle) { int numOfRows = 0; int32_t numOfCols = taosArrayGetSize(pQueryHandle->pColumns); - *skey = INT64_MIN; + *skey = TSKEY_INITIAL_VAL; do { SSkipListNode* node = tSkipListIterGet(pIter); @@ -1043,8 +1406,8 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY SDataRow row = SL_GET_NODE_DATA(node); TSKEY key = dataRowKey(row); - if ((key > maxKey && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (key < maxKey && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if ((key > maxKey && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < maxKey && !ASCENDING_TRAVERSE(pQueryHandle->order))) { uTrace("%p key:%"PRIu64" beyond qrange:%"PRId64" - %"PRId64", no more data in buffer", pQueryHandle, key, pQueryHandle->window.skey, pQueryHandle->window.ekey); @@ -1067,7 +1430,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; } else { pData = pColInfo->pData + (maxRowsToRead - numOfRows - 1) * pColInfo->info.bytes; @@ -1090,8 +1453,8 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY } } - numOfRows++; - if (numOfRows >= maxRowsToRead) { + if (++numOfRows >= maxRowsToRead) { + tSkipListIterNext(pIter); break; } @@ -1100,7 +1463,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY assert(numOfRows <= maxRowsToRead); // if the buffer is not full in case of descending order query, move the data in the front of the buffer - if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && numOfRows < maxRowsToRead) { + if (!ASCENDING_TRAVERSE(pQueryHandle->order) && numOfRows < maxRowsToRead) { int32_t emptySize = maxRowsToRead - numOfRows; for(int32_t i = 0; i < numOfCols; ++i) { @@ -1116,58 +1479,55 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY SDataBlockInfo tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle) { STsdbQueryHandle* pHandle = (STsdbQueryHandle*)pQueryHandle; - STable* pTable = NULL; - - TSKEY skey = 0, ekey = 0; - int32_t rows = 0; - - int32_t step = ASCENDING_ORDER_TRAVERSE(pHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pHandle->order)? 1:-1; - // data in file + // there are data in file if (pHandle->cur.fid >= 0) { STableBlockInfo* pBlockInfo = &pHandle->pDataBlockInfo[pHandle->cur.slot]; + STableCheckInfo* pCheckInfo = pBlockInfo->pTableCheckInfo; + + STable* pTable = pCheckInfo->pTableObj; - pTable = pBlockInfo->pTableCheckInfo->pTableObj; - - SDataBlockInfo binfo = getTrueDataBlockInfo(pBlockInfo->pTableCheckInfo, pBlockInfo->pBlock.compBlock); - if (binfo.rows == pHandle->realNumOfRows) { - pBlockInfo->pTableCheckInfo->lastKey = pBlockInfo->pBlock.compBlock->keyLast + 1; - return binfo; + if (pHandle->cur.mixBlock) { + SDataBlockInfo blockInfo = { + .uid = pTable->tableId.uid, + .tid = pTable->tableId.tid, + .rows = pHandle->cur.rows, + .window = pHandle->cur.win, + }; + + return blockInfo; } else { - /* not a whole disk block, only the qualified rows, so this block is loaded in to buffer during the - * block next function - */ - SColumnInfoData* pColInfoEx = taosArrayGet(pHandle->pColumns, 0); - - rows = pHandle->realNumOfRows; - skey = *(TSKEY*)pColInfoEx->pData; - ekey = *(TSKEY*)((char*)pColInfoEx->pData + TSDB_KEYSIZE * (rows - 1)); - - // update the last key value - pBlockInfo->pTableCheckInfo->lastKey = ekey + step; + return getTrueDataBlockInfo(pCheckInfo, pBlockInfo->pBlock.compBlock); } } else { STableCheckInfo* pCheckInfo = taosArrayGet(pHandle->pTableCheckInfo, pHandle->activeIndex); - pTable = pCheckInfo->pTableObj; - - if (pTable->mem != NULL) { - // create mem table iterator if it is not created yet + + STable* pTable = pCheckInfo->pTableObj; + if (pTable->mem != NULL) { // create mem table iterator if it is not created yet assert(pCheckInfo->iter != NULL); - rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, pHandle->window.ekey, 4000, &skey, &ekey, pHandle); + STimeWindow* win = &pHandle->cur.win; + + pHandle->cur.rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, pHandle->window.ekey, + pHandle->outputCapacity, &win->skey, &win->ekey, pHandle); // todo refactor API // update the last key value - pCheckInfo->lastKey = ekey + step; + pCheckInfo->lastKey = win->ekey + step; } + + if (!ASCENDING_TRAVERSE(pHandle->order)) { + SWAP(pHandle->cur.win.skey, pHandle->cur.win.ekey, TSKEY); + } + + SDataBlockInfo blockInfo = { + .uid = pTable->tableId.uid, + .tid = pTable->tableId.tid, + .rows = pHandle->cur.rows, + .window = pHandle->cur.win, + }; + + return blockInfo; } - - SDataBlockInfo blockInfo = { - .uid = pTable->tableId.uid, - .tid = pTable->tableId.tid, - .rows = rows, - .window = {.skey = MIN(skey, ekey), .ekey = MAX(skey, ekey)} - }; - - return blockInfo; } // return null for data block in cache @@ -1189,26 +1549,36 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) { STableBlockInfo* pBlockInfoEx = &pHandle->pDataBlockInfo[pHandle->cur.slot]; STableCheckInfo* pCheckInfo = pBlockInfoEx->pTableCheckInfo; - SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlockInfoEx->pBlock.compBlock); - assert(pHandle->realNumOfRows <= binfo.rows); - - if (pHandle->realNumOfRows < binfo.rows) { + if (pHandle->cur.mixBlock) { return pHandle->pColumns; } else { + SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlockInfoEx->pBlock.compBlock); + assert(pHandle->realNumOfRows <= binfo.rows); + // data block has been loaded, todo extract method SDataBlockLoadInfo* pBlockLoadInfo = &pHandle->dataBlockLoadInfo; if (pBlockLoadInfo->slot == pHandle->cur.slot && pBlockLoadInfo->fileGroup->fileId == pHandle->cur.fid && pBlockLoadInfo->tid == pCheckInfo->pTableObj->tableId.tid) { return pHandle->pColumns; - } else { + } else { // only load the file block SCompBlock* pBlock = pBlockInfoEx->pBlock.compBlock; doLoadFileDataBlock(pHandle, pBlock, pCheckInfo); - - SArray* sa = getDefaultLoadColumns(pHandle, true); - filterDataInDataBlock(pHandle, pCheckInfo, pBlock, sa); - taosArrayDestroy(sa); - + + // todo refactor + int32_t numOfRows = copyDataFromFileBlock(pHandle, pHandle->outputCapacity, 0, 0, pBlock->numOfPoints - 1); + + // if the buffer is not full in case of descending order query, move the data in the front of the buffer + if (!ASCENDING_TRAVERSE(pHandle->order) && numOfRows < pHandle->outputCapacity) { + int32_t emptySize = pHandle->outputCapacity - numOfRows; + int32_t reqNumOfCols = taosArrayGetSize(pHandle->pColumns); + + for(int32_t i = 0; i < reqNumOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pHandle->pColumns, i); + memmove(pColInfo->pData, pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + } + } + return pHandle->pColumns; } } @@ -1632,7 +2002,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { size_t cols = taosArrayGetSize(pQueryHandle->pColumns); for (int32_t i = 0; i < cols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); - tfree(pColInfo->pData); + tfree(pColInfo->pData); } taosArrayDestroy(pQueryHandle->pColumns); diff --git a/src/util/inc/talgo.h b/src/util/inc/talgo.h index d5e089b687807cf8e028ca721c64959afc92914d..e71e340a213bc4809a4124d4fbab963b900d104c 100644 --- a/src/util/inc/talgo.h +++ b/src/util/inc/talgo.h @@ -26,6 +26,8 @@ extern "C" { #define TD_GE (TD_EQ | TD_GT) #define TD_LE (TD_EQ | TD_LT) +#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx)) + typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void *param); /** diff --git a/src/util/inc/tqueue.h b/src/util/inc/tqueue.h index f4086dcd126e5961383feb5368517f670b561489..8493a64315966aa32b58359652d0f429e8e0916a 100644 --- a/src/util/inc/tqueue.h +++ b/src/util/inc/tqueue.h @@ -39,6 +39,7 @@ void taosResetQitems(taos_qall); taos_qset taosOpenQset(); void taosCloseQset(); +void taosQsetThreadResume(taos_qset param); int taosAddIntoQset(taos_qset, taos_queue, void *ahandle); void taosRemoveFromQset(taos_qset, taos_queue); int taosGetQueueNumber(taos_qset); diff --git a/src/util/inc/tsocket.h b/src/util/inc/tsocket.h index 309aa80ef6c0ae4e04d20e72ebb0d91835bcb66d..97abc16333ae08cec2387045d8ae458de43b3a06 100644 --- a/src/util/inc/tsocket.h +++ b/src/util/inc/tsocket.h @@ -31,7 +31,6 @@ int taosOpenUdpSocket(uint32_t localIp, uint16_t localPort); int taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp); int taosOpenTcpServerSocket(uint32_t ip, uint16_t port); int taosKeepTcpAlive(int sockFd); -void taosCloseTcpSocket(int sockFd); int taosGetFqdn(char *); uint32_t taosGetIpFromFqdn(const char *); diff --git a/src/util/inc/tstoken.h b/src/util/inc/tstoken.h index 13190e800d91213b630d19832a8fcf8316a7786d..60a79f69afe8b7521e1869eea8ae0e96f4660487 100644 --- a/src/util/inc/tstoken.h +++ b/src/util/inc/tstoken.h @@ -21,6 +21,8 @@ extern "C" { #endif #include "os.h" +#include "tutil.h" +#include "ttokendef.h" #define TK_SPACE 200 #define TK_COMMENT 201 @@ -31,7 +33,7 @@ extern "C" { #define TK_FILE 206 #define TK_QUESTION 207 // denoting the placeholder of "?",when invoking statement bind query -#define TSQL_TBNAME "TBNAME" +#define TSQL_TBNAME "TBNAME" #define TSQL_TBNAME_L "tbname" // used to denote the minimum unite in sql parsing @@ -74,14 +76,117 @@ bool isKeyWord(const char *z, int32_t len); * @param pToken * @return */ -bool isNumber(const SSQLToken *pToken); +#define isNumber(tk) \ +((tk)->type == TK_INTEGER || (tk)->type == TK_FLOAT || (tk)->type == TK_HEX || (tk)->type == TK_BIN) + /** * check if it is a token or not * @param pToken - * @return token type, if it is not a number, TK_ILLEGAL will return + * @return token type, if it is not a number, TK_ILLEGAL will return */ -int32_t isValidNumber(const SSQLToken* pToken); +static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) { + const char* z = pToken->z; + int32_t type = TK_ILLEGAL; + + int32_t i = 0; + for(; i < pToken->n; ++i) { + switch (z[i]) { + case '+': + case '-': { + break; + } + + case '.': { + /* + * handle the the float number with out integer part + * .123 + * .123e4 + */ + if (!isdigit(z[i+1])) { + return TK_ILLEGAL; + } + + for (i += 2; isdigit(z[i]); i++) { + } + + if ((z[i] == 'e' || z[i] == 'E') && + (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { + i += 2; + while (isdigit(z[i])) { + i++; + } + } + + type = TK_FLOAT; + goto _end; + } + + case '0': { + char next = z[i + 1]; + if (next == 'b') { // bin number + type = TK_BIN; + for (i += 2; (z[i] == '0' || z[i] == '1'); ++i) { + } + + goto _end; + } else if (next == 'x') { //hex number + type = TK_HEX; + for (i += 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) { + } + + goto _end; + } + } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + type = TK_INTEGER; + for (; isdigit(z[i]); i++) { + } + + int32_t seg = 0; + while (z[i] == '.' && isdigit(z[i + 1])) { + i += 2; + + while (isdigit(z[i])) { + i++; + } + + seg++; + type = TK_FLOAT; + } + + if (seg > 1) { + return TK_ILLEGAL; + } + + if ((z[i] == 'e' || z[i] == 'E') && + (isdigit(z[i + 1]) || ((z[i + 1] == '+' || z[i + 1] == '-') && isdigit(z[i + 2])))) { + i += 2; + while (isdigit(z[i])) { + i++; + } + + type = TK_FLOAT; + } + + goto _end; + } + default: + return TK_ILLEGAL; + } + } + + _end: + return (i < pToken->n)? TK_ILLEGAL:type; +} #ifdef __cplusplus } diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 12f7b43b7900dab5b6d4e191e91f5db8f1f145cc..f19438159da0a46bf5e6fb7a8447aa40236de126 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -102,7 +102,32 @@ static void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode); * @param hashVal hash value by hash function * @return */ -static SHashNode *doGetNodeFromHashTable(SHashObj *pHashObj, const void *key, uint32_t keyLen, uint32_t *hashVal); +FORCE_INLINE SHashNode *doGetNodeFromHashTable(SHashObj *pHashObj, const void *key, uint32_t keyLen, uint32_t *hashVal) { + uint32_t hash = (*pHashObj->hashFp)(key, keyLen); + + int32_t slot = HASH_INDEX(hash, pHashObj->capacity); + SHashEntry *pEntry = pHashObj->hashList[slot]; + + SHashNode *pNode = pEntry->next; + while (pNode) { + if ((pNode->keyLen == keyLen) && (memcmp(pNode->key, key, keyLen) == 0)) { + break; + } + + pNode = pNode->next; + } + + if (pNode) { + assert(HASH_INDEX(pNode->hashVal, pHashObj->capacity) == slot); + } + + // return the calculated hash value, to avoid calculating it again in other functions + if (hashVal != NULL) { + *hashVal = hash; + } + + return pNode; +} /** * Resize the hash list if the threshold is reached @@ -438,33 +463,6 @@ void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode) { } } -SHashNode *doGetNodeFromHashTable(SHashObj *pHashObj, const void *key, uint32_t keyLen, uint32_t *hashVal) { - uint32_t hash = (*pHashObj->hashFp)(key, keyLen); - - int32_t slot = HASH_INDEX(hash, pHashObj->capacity); - SHashEntry *pEntry = pHashObj->hashList[slot]; - - SHashNode *pNode = pEntry->next; - while (pNode) { - if ((pNode->keyLen == keyLen) && (memcmp(pNode->key, key, keyLen) == 0)) { - break; - } - - pNode = pNode->next; - } - - if (pNode) { - assert(HASH_INDEX(pNode->hashVal, pHashObj->capacity) == slot); - } - - // return the calculated hash value, to avoid calculating it again in other functions - if (hashVal != NULL) { - *hashVal = hash; - } - - return pNode; -} - void taosHashTableResize(SHashObj *pHashObj) { if (pHashObj->size < pHashObj->capacity * HASH_DEFAULT_LOAD_FACTOR) { return; diff --git a/src/util/src/talgo.c b/src/util/src/talgo.c index f343912cde267855bc083fbde47f380e9609742e..3a594faeb9bbc20608737c0160cfd0f4373bb9a8 100644 --- a/src/util/src/talgo.c +++ b/src/util/src/talgo.c @@ -23,8 +23,6 @@ memcpy((__right), (__buf), (__size));\ } while (0); -#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx)) - static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) { int32_t mid = ((e - s) >> 1u) + s; diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 4bac669dc07689129a241b7ace45c56ad4485ca4..751bd0fc34f443fde9496a5ee75aa33f35987564 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -216,14 +216,14 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -static UNUSED_FUNC int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { +static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; - const char* pattern = pRight; - const char* str = pLeft; - - int32_t ret = patternMatch(pattern, str, strlen(str), &pInfo); + char pattern[128] = {0}; + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); + assert(varDataLen(pRight) < 128); + int32_t ret = patternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft), &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } @@ -232,14 +232,14 @@ static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) { return taosArraySearchString(arr, pLeft) == NULL ? 0 : 1; } -static UNUSED_FUNC int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { +static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; - const wchar_t* pattern = pRight; - const wchar_t* str = pLeft; - - int32_t ret = WCSPatternMatch(pattern, str, wcslen(str), &pInfo); + wchar_t pattern[128] = {0}; + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)/TSDB_NCHAR_SIZE); + assert(varDataLen(pRight) < 128); + int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } diff --git a/src/util/src/thashutil.c b/src/util/src/thashutil.c index f4b4e9faa262c8f5968cb546138feacce4895c38..33f0d6d4302e0a8744bb0bc80e4d231445315cc4 100644 --- a/src/util/src/thashutil.c +++ b/src/util/src/thashutil.c @@ -10,7 +10,7 @@ #include "hashfunc.h" #include "tutil.h" -#define ROTL32(x, r) ((x) << (r) | (x) >> (32 - (r))) +#define ROTL32(x, r) ((x) << (r) | (x) >> (32u - (r))) #define FMIX32(h) \ do { \ @@ -20,12 +20,12 @@ (h) *= 0xc2b2ae35; \ (h) ^= (h) >> 16; \ } while (0) - -static void MurmurHash3_32_s(const void *key, int len, uint32_t seed, void *out) { + +uint32_t MurmurHash3_32(const char *key, uint32_t len) { const uint8_t *data = (const uint8_t *)key; - const int nblocks = len / 4; + const int nblocks = len >> 2u; - uint32_t h1 = seed; + uint32_t h1 = 0x12345678; const uint32_t c1 = 0xcc9e2d51; const uint32_t c2 = 0x1b873593; @@ -36,11 +36,11 @@ static void MurmurHash3_32_s(const void *key, int len, uint32_t seed, void *out) uint32_t k1 = blocks[i]; k1 *= c1; - k1 = ROTL32(k1, 15); + k1 = ROTL32(k1, 15u); k1 *= c2; h1 ^= k1; - h1 = ROTL32(h1, 13); + h1 = ROTL32(h1, 13u); h1 = h1 * 5 + 0xe6546b64; } @@ -48,7 +48,7 @@ static void MurmurHash3_32_s(const void *key, int len, uint32_t seed, void *out) uint32_t k1 = 0; - switch (len & 3) { + switch (len & 3u) { case 3: k1 ^= tail[2] << 16; case 2: @@ -56,7 +56,7 @@ static void MurmurHash3_32_s(const void *key, int len, uint32_t seed, void *out) case 1: k1 ^= tail[0]; k1 *= c1; - k1 = ROTL32(k1, 15); + k1 = ROTL32(k1, 15u); k1 *= c2; h1 ^= k1; }; @@ -65,16 +65,7 @@ static void MurmurHash3_32_s(const void *key, int len, uint32_t seed, void *out) FMIX32(h1); - *(uint32_t *)out = h1; -} - -uint32_t MurmurHash3_32(const char *key, uint32_t len) { - const int32_t hashSeed = 0x12345678; - - uint32_t val = 0; - MurmurHash3_32_s(key, len, hashSeed, &val); - - return val; + return h1; } uint32_t taosIntHash_32(const char *key, uint32_t UNUSED_PARAM(len)) { return *(uint32_t *)key; } diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c index 8a203ed9176687ecf5ea03973b979bc3607b8630..475941dbdb9fb9dee3d656b841fc286cfd9043ef 100644 --- a/src/util/src/tqueue.c +++ b/src/util/src/tqueue.c @@ -65,6 +65,7 @@ taos_queue taosOpenQueue() { } void taosCloseQueue(taos_queue param) { + if (param == NULL) return; STaosQueue *queue = (STaosQueue *)param; STaosQnode *pTemp; STaosQnode *pNode = queue->head; @@ -224,12 +225,21 @@ taos_qset taosOpenQset() { } void taosCloseQset(taos_qset param) { + if (param == NULL) return; STaosQset *qset = (STaosQset *)param; pthread_mutex_destroy(&qset->mutex); tsem_destroy(&qset->sem); free(qset); } +// tsem_post 'qset->sem', so that reader threads waiting for it +// resumes execution and return, should only be used to signal the +// thread to exit. +void taosQsetThreadResume(taos_qset param) { + STaosQset *qset = (STaosQset *)param; + tsem_post(&qset->sem); +} + int taosAddIntoQset(taos_qset p1, taos_queue p2, void *ahandle) { STaosQueue *queue = (STaosQueue *)p2; STaosQset *qset = (STaosQset *)p1; diff --git a/src/util/src/tsched.c b/src/util/src/tsched.c index 39d8816310edda5d931ade50af03f21e9859931b..25893969e47c69abe11cc5651b1f02eccb5e61bf 100644 --- a/src/util/src/tsched.c +++ b/src/util/src/tsched.c @@ -31,7 +31,7 @@ typedef struct { int numOfThreads; pthread_t * qthread; SSchedMsg * queue; - + bool stop; void* pTmrCtrl; void* pTimer; } SSchedQueue; @@ -85,6 +85,7 @@ void *taosInitScheduler(int queueSize, int numOfThreads, const char *label) { return NULL; } + pSched->stop = false; for (int i = 0; i < numOfThreads; ++i) { pthread_attr_t attr; pthread_attr_init(&attr); @@ -128,6 +129,9 @@ void *taosProcessSchedQueue(void *param) { } uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno)); } + if (pSched->stop) { + break; + } if (pthread_mutex_lock(&pSched->queueMutex) != 0) uError("lock %s queueMutex failed(%s)", pSched->label, strerror(errno)); @@ -185,13 +189,16 @@ void taosCleanUpScheduler(void *param) { SSchedQueue *pSched = (SSchedQueue *)param; if (pSched == NULL) return; + pSched->stop = true; for (int i = 0; i < pSched->numOfThreads; ++i) { - if (pSched->qthread[i]) - pthread_cancel(pSched->qthread[i]); + if (pSched->qthread[i]) { + tsem_post(&pSched->fullSem); + } } for (int i = 0; i < pSched->numOfThreads; ++i) { - if (pSched->qthread[i]) + if (pSched->qthread[i]) { pthread_join(pSched->qthread[i], NULL); + } } tsem_destroy(&pSched->emptySem); diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index b72db6a8d81a9379ad2fb3b4721ecf96c992580e..f1f34818655bd0ca70d62f1dfe81a5fb14238a68 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -573,6 +573,7 @@ bool tSkipListIterNext(SSkipListIterator *iter) { pthread_rwlock_unlock(pSkipList->lock); } + iter->step += 1; return (iter->order == TSDB_ORDER_ASC)? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead); } diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index efdf7529608b272230f804437d71377f1fc6feea..d92228a089785d3c327496a70fd72dd4bc2a7b37 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -305,18 +305,9 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI sockFd = -1; } - return sockFd; -} - -void taosCloseTcpSocket(int sockFd) { - struct linger linger; - linger.l_onoff = 1; - linger.l_linger = 0; - if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) { - uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno)); - } + // taosKeepTcpAlive(sockFd); - taosCloseSocket(sockFd); + return sockFd; } int taosKeepTcpAlive(int sockFd) { @@ -355,6 +346,15 @@ int taosKeepTcpAlive(int sockFd) { return -1; } + struct linger linger = {0}; + linger.l_onoff = 1; + //linger.l_linger = 0; + if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) { + uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno)); + close(sockFd); + return -1; + } + return 0; } diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index 42fd13b2cd780dc650cae0fbdfe0cba0c4d72afc..e6ef73ef57d3da8a8961c9673096e7f6e6a33e1a 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -405,19 +405,19 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) { tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param); return reusable; } - + if (state != TIMER_STATE_EXPIRED) { // timer already stopped or cancelled, has nothing to do in this case return false; } - + if (timer->executedBy == taosGetPthreadId()) { // taosTmrReset is called in the timer callback, should do nothing in this // case to avoid dead lock. note taosTmrReset must be the last statement // of the callback funtion, will be a bug otherwise. return false; } - + // timer callback is executing in another thread, we SHOULD wait it to stop, // BUT this may result in dead lock if current thread are holding a lock which // the timer callback need to acquire. so, we HAVE TO return directly. @@ -501,6 +501,7 @@ static void taosTmrModuleInit(void) { tmr_ctrl_t* ctrl = tmrCtrls + i; ctrl->next = ctrl + 1; } + (tmrCtrls + taosMaxTmrCtrl - 1)->next = NULL; unusedTmrCtrl = tmrCtrls; pthread_mutex_init(&tmrCtrlMutex, NULL); @@ -574,12 +575,12 @@ void taosTmrCleanUp(void* handle) { if (numOfTmrCtrl <=0) { taosUninitTimer(); - + taosCleanUpScheduler(tmrQhandle); for (int i = 0; i < tListLen(wheels); i++) { time_wheel_t* wheel = wheels + i; - pthread_mutex_destroy(&wheel->mutex); + pthread_mutex_destroy(&wheel->mutex); free(wheel->slots); } diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 52f70bdf5e3a4f6bead0f4e93e4c8c2fe342968a..989273e0515e7c1affdd3ff9afe747688923270f 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -416,12 +416,12 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) { #else char *tmpDir = "/tmp/"; #endif - + int64_t ts = taosGetTimestampUs(); strcpy(tmpPath, tmpDir); strcat(tmpPath, tdengineTmpFileNamePrefix); strcat(tmpPath, fileNamePrefix); - strcat(tmpPath, "-%llu-%u"); - snprintf(dstPath, PATH_MAX, tmpPath, taosGetPthreadId(), atomic_add_fetch_32(&tmpFileSerialNum, 1)); + strcat(tmpPath, "-%d-%"PRIu64"-%u-%"PRIu64); + snprintf(dstPath, PATH_MAX, tmpPath, getpid(), taosGetPthreadId(), atomic_add_fetch_32(&tmpFileSerialNum, 1), ts); } int tasoUcs4Compare(void* f1_ucs4, void *f2_ucs4, int bytes) { diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 6dabc98ae829dddce569df8a19ee022cdeac30ec..b8bc29550e3ee810b850b12922debbe06dfbe104 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -35,7 +35,7 @@ static void vnodeCleanUp(SVnodeObj *pVnode); static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg); static int32_t vnodeReadCfg(SVnodeObj *pVnode); static int32_t vnodeSaveVersion(SVnodeObj *pVnode); -static bool vnodeReadVersion(SVnodeObj *pVnode); +static int32_t vnodeReadVersion(SVnodeObj *pVnode); static int vnodeProcessTsdbStatus(void *arg, int status); static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion); static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index); @@ -46,9 +46,9 @@ static pthread_once_t vnodeModuleInit = PTHREAD_ONCE_INIT; #ifndef _SYNC tsync_h syncStart(const SSyncInfo *info) { return NULL; } -int syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle) { return 0; } +int32_t syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype) { return 0; } void syncStop(tsync_h shandle) {} -int syncReconfig(tsync_h shandle, const SSyncCfg * cfg) { return 0; } +int32_t syncReconfig(tsync_h shandle, const SSyncCfg * cfg) { return 0; } int syncGetNodesRole(tsync_h shandle, SNodesRole * cfg) { return 0; } void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code) {} #endif @@ -73,13 +73,18 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { return TSDB_CODE_SUCCESS; } + mkdir(tsVnodeDir, 0755); + char rootDir[TSDB_FILENAME_LEN] = {0}; sprintf(rootDir, "%s/vnode%d", tsVnodeDir, pVnodeCfg->cfg.vgId); if (mkdir(rootDir, 0755) != 0) { + vPrint("vgId:%d, failed to create vnode, reason:%s dir:%s", pVnodeCfg->cfg.vgId, strerror(errno), rootDir); if (errno == EACCES) { return TSDB_CODE_NO_DISK_PERMISSIONS; } else if (errno == ENOSPC) { return TSDB_CODE_SERV_NO_DISKSPACE; + } else if (errno == ENOENT) { + return TSDB_CODE_NOT_SUCH_FILE_OR_DIR; } else if (errno == EEXIST) { } else { return TSDB_CODE_VG_INIT_FAILED; @@ -143,35 +148,20 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { pVnode->status = TAOS_VN_STATUS_UPDATING; int32_t code = vnodeSaveCfg(pVnodeCfg); - if (code != TSDB_CODE_SUCCESS) { - vError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); - return code; - } + if (code != TSDB_CODE_SUCCESS) return code; code = vnodeReadCfg(pVnode); - if (code != TSDB_CODE_SUCCESS) { - vError("vgId:%d, failed to read cfg file", pVnode->vgId); - taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t)); - return code; - } + if (code != TSDB_CODE_SUCCESS) return code; code = syncReconfig(pVnode->sync, &pVnode->syncCfg); - if (code != TSDB_CODE_SUCCESS) { - vTrace("vgId:%d, failed to alter vnode, canot reconfig sync, result:%s", pVnode->vgId, - tstrerror(code)); - return code; - } + if (code != TSDB_CODE_SUCCESS) return code; code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg); - if (code != TSDB_CODE_SUCCESS) { - vTrace("vgId:%d, failed to alter vnode, canot reconfig tsdb, result:%s", pVnode->vgId, - tstrerror(code)); - return code; - } + if (code != TSDB_CODE_SUCCESS) return code; pVnode->status = TAOS_VN_STATUS_READY; - vTrace("vgId:%d, vnode is altered", pVnode->vgId); + return TSDB_CODE_SUCCESS; } @@ -180,26 +170,40 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { pthread_once(&vnodeModuleInit, vnodeInit); SVnodeObj *pVnode = calloc(sizeof(SVnodeObj), 1); + if (pVnode == NULL) { + vError("vgId:%d, failed to open vnode since no enough memory", vnode); + return TAOS_SYSTEM_ERROR(errno); + } + + atomic_add_fetch_32(&tsOpennedVnodes, 1); + atomic_add_fetch_32(&pVnode->refCount, 1); + pVnode->vgId = vnode; pVnode->status = TAOS_VN_STATUS_INIT; - pVnode->refCount = 1; pVnode->version = 0; pVnode->tsdbCfg.tsdbId = pVnode->vgId; pVnode->rootDir = strdup(rootDir); - taosHashPut(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t), (char *)(&pVnode), sizeof(SVnodeObj *)); int32_t code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { - vError("vgId:%d, failed to read cfg file", pVnode->vgId); - taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t)); + vnodeCleanUp(pVnode); + return code; + } + + code = vnodeReadVersion(pVnode); + if (code != TSDB_CODE_SUCCESS) { + vnodeCleanUp(pVnode); return code; } - vnodeReadVersion(pVnode); pVnode->fversion = pVnode->version; pVnode->wqueue = dnodeAllocateWqueue(pVnode); pVnode->rqueue = dnodeAllocateRqueue(pVnode); + if (pVnode->wqueue == NULL || pVnode->rqueue == NULL) { + vnodeCleanUp(pVnode); + return terrno; + } SCqCfg cqCfg = {0}; sprintf(cqCfg.user, "root"); @@ -207,22 +211,29 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { cqCfg.vgId = vnode; cqCfg.cqWrite = vnodeWriteToQueue; pVnode->cq = cqOpen(pVnode, &cqCfg); + if (pVnode->cq == NULL) { + vnodeCleanUp(pVnode); + return terrno; + } STsdbAppH appH = {0}; appH.appH = (void *)pVnode; appH.notifyStatus = vnodeProcessTsdbStatus; appH.cqH = pVnode->cq; - sprintf(temp, "%s/tsdb", rootDir); pVnode->tsdb = tsdbOpenRepo(temp, &appH); if (pVnode->tsdb == NULL) { - vError("vgId:%d, failed to open tsdb at %s(%s)", pVnode->vgId, temp, tstrerror(terrno)); - taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t)); + vnodeCleanUp(pVnode); return terrno; } sprintf(temp, "%s/wal", rootDir); pVnode->wal = walOpen(temp, &pVnode->walCfg); + if (pVnode->wal == NULL) { + vnodeCleanUp(pVnode); + return terrno; + } + walRestore(pVnode->wal, pVnode, vnodeWriteToQueue); SSyncInfo syncInfo; @@ -239,16 +250,25 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { syncInfo.notifyFileSynced = vnodeNotifyFileSynced; pVnode->sync = syncStart(&syncInfo); +#ifndef _SYNC + pVnode->role = TAOS_SYNC_ROLE_MASTER; +#else + if (pVnode->sync == NULL) { + vnodeCleanUp(pVnode); + return terrno; + } +#endif + // start continuous query if (pVnode->role == TAOS_SYNC_ROLE_MASTER) cqStart(pVnode->cq); pVnode->events = NULL; - pVnode->status = TAOS_VN_STATUS_READY; vTrace("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode); - atomic_add_fetch_32(&tsOpennedVnodes, 1); + taosHashPut(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t), (char *)(&pVnode), sizeof(SVnodeObj *)); + return TSDB_CODE_SUCCESS; } @@ -277,13 +297,6 @@ void vnodeRelease(void *pVnodeRaw) { } tfree(pVnode->rootDir); - // remove read queue - dnodeFreeRqueue(pVnode->rqueue); - pVnode->rqueue = NULL; - - // remove write queue - dnodeFreeWqueue(pVnode->wqueue); - pVnode->wqueue = NULL; if (pVnode->status == TAOS_VN_STATUS_DELETING) { char rootDir[TSDB_FILENAME_LEN] = {0}; @@ -378,15 +391,26 @@ static void vnodeCleanUp(SVnodeObj *pVnode) { pVnode->sync = NULL; } - cqClose(pVnode->cq); - pVnode->cq = NULL; + if (pVnode->wal) + walClose(pVnode->wal); + pVnode->wal = NULL; - tsdbCloseRepo(pVnode->tsdb, 1); + if (pVnode->tsdb) + tsdbCloseRepo(pVnode->tsdb, 1); pVnode->tsdb = NULL; - walClose(pVnode->wal); - pVnode->wal = NULL; + if (pVnode->cq) + cqClose(pVnode->cq); + pVnode->cq = NULL; + if (pVnode->wqueue) + dnodeFreeWqueue(pVnode->wqueue); + pVnode->wqueue = NULL; + + if (pVnode->rqueue) + dnodeFreeRqueue(pVnode->rqueue); + pVnode->rqueue = NULL; + vnodeRelease(pVnode); } @@ -429,7 +453,7 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) { static void vnodeNotifyFileSynced(void *ahandle, uint64_t fversion) { SVnodeObj *pVnode = ahandle; - vTrace("vgId:%d, data file is synced, fversion:%" PRId64 "", pVnode->vgId, fversion); + vTrace("vgId:%d, data file is synced, fversion:%" PRId64, pVnode->vgId, fversion); pVnode->fversion = fversion; pVnode->version = fversion; @@ -453,7 +477,8 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { if (!fp) { vError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile, strerror(errno)); - return errno; + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; } int32_t len = 0; @@ -503,27 +528,30 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { } static int32_t vnodeReadCfg(SVnodeObj *pVnode) { - char cfgFile[TSDB_FILENAME_LEN + 30] = {0}; + cJSON *root = NULL; + char *content = NULL; + char cfgFile[TSDB_FILENAME_LEN + 30] = {0}; + int maxLen = 1000; + + terrno = TSDB_CODE_OTHERS; sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(cfgFile, "r"); if (!fp) { - vError("vgId:%d, failed to open vnode cfg file for read, file:%s, error:%s", pVnode->vgId, + vError("vgId:%d, failed to open vnode cfg file:%s to read, error:%s", pVnode->vgId, cfgFile, strerror(errno)); - return errno; + terrno = TAOS_SYSTEM_ERROR(errno); + goto PARSE_OVER; } - int ret = TSDB_CODE_OTHERS; - int maxLen = 1000; - char *content = calloc(1, maxLen + 1); + content = calloc(1, maxLen + 1); + if (content == NULL) goto PARSE_OVER; int len = fread(content, 1, maxLen, fp); if (len <= 0) { - free(content); - fclose(fp); vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId); - return false; + return errno; } - cJSON *root = cJSON_Parse(content); + root = cJSON_Parse(content); if (root == NULL) { vError("vgId:%d, failed to read vnode cfg, invalid json format", pVnode->vgId); goto PARSE_OVER; @@ -682,19 +710,19 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { pVnode->syncCfg.nodeInfo[i].nodePort += TSDB_PORT_SYNC; } - ret = 0; + terrno = TSDB_CODE_SUCCESS; - vPrint("vgId:%d, read vnode cfg successed, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica); + vPrint("vgId:%d, read vnode cfg successfully, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica); for (int32_t i = 0; i < pVnode->syncCfg.replica; i++) { vPrint("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId, pVnode->syncCfg.nodeInfo[i].nodeFqdn, pVnode->syncCfg.nodeInfo[i].nodePort); } PARSE_OVER: - free(content); + tfree(content); cJSON_Delete(root); - fclose(fp); - return ret; + if (fp) fclose(fp); + return terrno; } static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { @@ -704,7 +732,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { if (!fp) { vError("vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode->vgId, versionFile, strerror(errno)); - return errno; + return TAOS_SYSTEM_ERROR(errno); } int32_t len = 0; @@ -724,29 +752,33 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { return 0; } -static bool vnodeReadVersion(SVnodeObj *pVnode) { - char versionFile[TSDB_FILENAME_LEN + 30] = {0}; +static int32_t vnodeReadVersion(SVnodeObj *pVnode) { + char versionFile[TSDB_FILENAME_LEN + 30] = {0}; + char *content = NULL; + cJSON *root = NULL; + int maxLen = 100; + + terrno = TSDB_CODE_OTHERS; sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "r"); if (!fp) { if (errno != ENOENT) { vError("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + } else { + terrno = TSDB_CODE_SUCCESS; } - return false; + goto PARSE_OVER; } - bool ret = false; - int maxLen = 100; - char *content = calloc(1, maxLen + 1); + content = calloc(1, maxLen + 1); int len = fread(content, 1, maxLen, fp); if (len <= 0) { - free(content); - fclose(fp); - vPrint("vgId:%d, failed to read vnode version, content is null", pVnode->vgId); - return false; + vError("vgId:%d, failed to read vnode version, content is null", pVnode->vgId); + goto PARSE_OVER; } - cJSON *root = cJSON_Parse(content); + root = cJSON_Parse(content); if (root == NULL) { vError("vgId:%d, failed to read vnode version, invalid json format", pVnode->vgId); goto PARSE_OVER; @@ -759,13 +791,12 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) { } pVnode->version = version->valueint; - ret = true; - - vPrint("vgId:%d, read vnode version succeed, version:%" PRId64, pVnode->vgId, pVnode->version); + terrno = TSDB_CODE_SUCCESS; + vPrint("vgId:%d, read vnode version successfully, version:%" PRId64, pVnode->vgId, pVnode->version); PARSE_OVER: - free(content); + tfree(content); cJSON_Delete(root); - fclose(fp); - return ret; + if(fp) fclose(fp); + return terrno; } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 635c4669782114fa34c420bd9e7d752fc5f24828..9c415d6af756d6c9f015ef50055a00b2c48a910b 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -72,10 +72,9 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { code = walWrite(pVnode->wal, pHead); if (code < 0) return code; - // forward to peers if data is from RPC or CQ + // forward to peers, even it is WAL/FWD, it shall be called to update version in sync int32_t syncCode = 0; - if (qtype == TAOS_QTYPE_RPC || qtype == TAOS_QTYPE_CQ) - syncCode = syncForwardToPeer(pVnode->sync, pHead, item); + syncCode = syncForwardToPeer(pVnode->sync, pHead, item, qtype); if (syncCode < 0) return syncCode; // write data locally diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index 8d92fac926b2d54ecb7a022376d7ffc441ba454a..ebfc9d98bb159c0eb5929d9326be7b579db4c875 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -25,6 +25,7 @@ #include "tlog.h" #include "tchecksum.h" #include "tutil.h" +#include "taoserror.h" #include "twal.h" #include "tqueue.h" @@ -56,7 +57,10 @@ static int walRemoveWalFiles(const char *path); void *walOpen(const char *path, const SWalCfg *pCfg) { SWal *pWal = calloc(sizeof(SWal), 1); - if (pWal == NULL) return NULL; + if (pWal == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return NULL; + } pWal->fd = -1; pWal->max = pCfg->wals; @@ -75,6 +79,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { walRenew(pWal); if (pWal->fd <0) { + terrno = TAOS_SYSTEM_ERROR(errno); wError("wal:%s, failed to open", path); pthread_mutex_destroy(&pWal->mutex); free(pWal); @@ -112,9 +117,10 @@ void walClose(void *handle) { } int walRenew(void *handle) { + if (handle == NULL) return 0; SWal *pWal = handle; int code = 0; - + pthread_mutex_lock(&pWal->mutex); if (pWal->fd >=0) { @@ -156,6 +162,7 @@ int walRenew(void *handle) { int walWrite(void *handle, SWalHead *pHead) { SWal *pWal = handle; int code = 0; + if (pWal == NULL) return -1; // no wal if (pWal->level == TAOS_WAL_NOLOG) return 0; @@ -178,6 +185,7 @@ int walWrite(void *handle, SWalHead *pHead) { void walFsync(void *handle) { SWal *pWal = handle; + if (pWal == NULL) return; if (pWal->level == TAOS_WAL_FSYNC && pWal->fd >=0) { if (fsync(pWal->fd) < 0) { diff --git a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md index 7c42d47d1b9c95a863539e3dbe1f4b94abf6c753..b285fe815596a55d8e6689aeab1401f4388e94ec 100644 --- a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md +++ b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md @@ -11,6 +11,19 @@ 4. pip install src/connector/python/linux/python2 ; pip3 install src/connector/python/linux/python3 +> Note: Both Python2 and Python3 are currently supported by the Python test +> framework. Since Python2 is no longer officially supported by Python Software +> Foundation since January 1, 2020, it is recommended that subsequent test case +> development be guaranteed to run correctly on Python3. + +> For Python2, please consider being compatible if appropriate without +> additional burden. +> +> If you use some new Linux distribution like Ubuntu 20.04 which already do not +> include Python2, please do not install Python2-related packages. +> +>   + ### How to run Python test suite 1. cd \/tests/pytest @@ -211,13 +224,6 @@ def checkAffectedRows(self, expectAffectedRows): ... -> Note: Both Python2 and Python3 are currently supported by the Python test -> case. Since Python2 is no longer officially supported by January 1, 2020, it -> is recommended that subsequent test case development be guaranteed to run -> correctly on Python3. For Python2, please consider being compatible if -> appropriate without additional -> burden.   - ### CI submission adoption principle. - Every commit / PR compilation must pass. Currently, the warning is treated diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 70b1b2067f43c11a734a6a13dfec997a6971398b..76bfa5949e4a09afecc6f8c3bba5a408551cc84b 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -74,9 +74,8 @@ int main(int argc, char *argv[]) { printf("success to connect to server\n"); doQuery(taos, "create database if not exists test"); - doQuery(taos, "create database if not exists test"); -// doQuery(taos, "use test"); -// doQuery(taos, "select sum(k)*max(k), sum(k), max(k) from tm99"); + doQuery(taos, "use test"); + doQuery(taos, "select count(*) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:1:59' interval(500a) fill(value, 99)"); // doQuery(taos, "create table t1(ts timestamp, k binary(12), f nchar(2))"); // for(int32_t i = 0; i< 100000; ++i) { diff --git a/tests/pytest/account/account_create.py b/tests/pytest/account/account_create.py index 24bcc8df2f2bee27c9b2bde93e0262fa607aeb96..85adfff19994a3fbb12611e28d9872fb6cb1aeca 100644 --- a/tests/pytest/account/account_create.py +++ b/tests/pytest/account/account_create.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): try: diff --git a/tests/pytest/account/account_del.py b/tests/pytest/account/account_del.py index 43690c6e3712f204bda424182778c45fd1479a49..7f05a39765099e896a56af9cfafcfce3957076e1 100644 --- a/tests/pytest/account/account_del.py +++ b/tests/pytest/account/account_del.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): print("==========step1") diff --git a/tests/pytest/alter/alter_stable.py b/tests/pytest/alter/alter_stable.py index 5772edcf7ff52a2ef4113bbea21ed877af4c85e4..6852f4ef4ab6730f6423ba388d4f088ca229312e 100644 --- a/tests/pytest/alter/alter_stable.py +++ b/tests/pytest/alter/alter_stable.py @@ -9,9 +9,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) self.types = [ "int", "bigint", diff --git a/tests/pytest/alter/alter_table.py b/tests/pytest/alter/alter_table.py index 6e0c591da695b5f8f573fe470017e1f4ba31b068..6d4f72556b4d1d4ae1a439ab6a56b2925e3d63aa 100644 --- a/tests/pytest/alter/alter_table.py +++ b/tests/pytest/alter/alter_table.py @@ -9,9 +9,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) self.types = [ "int", "bigint", diff --git a/tests/pytest/alter/file_corrupt.py b/tests/pytest/alter/file_corrupt.py index 51ea8822704829f49b1bcfde882b9055199c838e..28d50cdd38c9e7359f67996713f746fb0c213edb 100644 --- a/tests/pytest/alter/file_corrupt.py +++ b/tests/pytest/alter/file_corrupt.py @@ -19,9 +19,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/dbmgmt/database-name-boundary.py b/tests/pytest/dbmgmt/database-name-boundary.py index ff6dce22ae5751ecf1f353818833a7cdeb40b611..df3b027ba7ea8f315060be2820e8bea2c17fa8cc 100644 --- a/tests/pytest/dbmgmt/database-name-boundary.py +++ b/tests/pytest/dbmgmt/database-name-boundary.py @@ -23,9 +23,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): diff --git a/tests/pytest/dbmgmt/dropDB_memory_test.py b/tests/pytest/dbmgmt/dropDB_memory_test.py index b029945be244fac873e73dcdb6cd1c0a7abfcec3..0f0925c2688f524d88701ec6cf0e3b302e6a519d 100644 --- a/tests/pytest/dbmgmt/dropDB_memory_test.py +++ b/tests/pytest/dbmgmt/dropDB_memory_test.py @@ -19,9 +19,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index efd9f7ce52666450ab88227feccb3722c7e45be7..999332d33bdc838ad77b9276b022ee27b8f47d50 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -1,101 +1,132 @@ #!/bin/bash -python3 ./test.py $1 -f insert/basic.py -python3 ./test.py $1 -f insert/int.py -python3 ./test.py $1 -f insert/float.py -python3 ./test.py $1 -f insert/bigint.py -python3 ./test.py $1 -f insert/bool.py -python3 ./test.py $1 -f insert/double.py -python3 ./test.py $1 -f insert/smallint.py -python3 ./test.py $1 -f insert/tinyint.py -python3 ./test.py $1 -f insert/date.py -python3 ./test.py $1 -f insert/binary.py -python3 ./test.py $1 -f insert/nchar.py -python3 ./test.py $1 -f insert/nchar-boundary.py -python3 ./test.py $1 -f insert/nchar-unicode.py -python3 ./test.py $1 -f insert/multi.py +python3 ./test.py -f insert/basic.py +python3 ./test.py -f insert/int.py +python3 ./test.py -f insert/float.py +python3 ./test.py -f insert/bigint.py +python3 ./test.py -f insert/bool.py +python3 ./test.py -f insert/double.py +python3 ./test.py -f insert/smallint.py +python3 ./test.py -f insert/tinyint.py +python3 ./test.py -f insert/date.py +python3 ./test.py -f insert/binary.py +python3 ./test.py -f insert/nchar.py +python3 ./test.py -f insert/nchar-boundary.py +python3 ./test.py -f insert/nchar-unicode.py +python3 ./test.py -f insert/multi.py +python3 ./test.py -f insert/randomNullCommit.py -python3 ./test.py $1 -f table/column_name.py -python3 ./test.py $1 -f table/column_num.py -python3 ./test.py $1 -f table/db_table.py -python3 ./test.py $1 -f table/tablename-boundary.py +python3 ./test.py -f table/column_name.py +python3 ./test.py -f table/column_num.py +python3 ./test.py -f table/db_table.py +python3 ./test.py -f table/tablename-boundary.py # tag -python3 ./test.py $1 -f tag_lite/filter.py -python3 ./test.py $1 -f tag_lite/create-tags-boundary.py +python3 ./test.py -f tag_lite/filter.py +python3 ./test.py -f tag_lite/create-tags-boundary.py +python3 ./test.py -f tag_lite/3.py +python3 ./test.py -f tag_lite/4.py +python3 ./test.py -f tag_lite/5.py +python3 ./test.py -f tag_lite/6.py +python3 ./test.py -f tag_lite/add.py +python3 ./test.py -f tag_lite/bigint.py +python3 ./test.py -f tag_lite/binary_binary.py +python3 ./test.py -f tag_lite/binary.py +python3 ./test.py -f tag_lite/bool_binary.py +python3 ./test.py -f tag_lite/bool_int.py +python3 ./test.py -f tag_lite/bool.py +python3 ./test.py -f tag_lite/change.py +python3 ./test.py -f tag_lite/column.py +python3 ./test.py -f tag_lite/commit.py +python3 ./test.py -f tag_lite/create.py +python3 ./test.py -f tag_lite/datatype.py +python3 ./test.py -f tag_lite/datatype-without-alter.py +python3 ./test.py -f tag_lite/delete.py +python3 ./test.py -f tag_lite/double.py +python3 ./test.py -f tag_lite/float.py +python3 ./test.py -f tag_lite/int_binary.py +python3 ./test.py -f tag_lite/int_float.py +python3 ./test.py -f tag_lite/int.py +python3 ./test.py -f tag_lite/set.py +python3 ./test.py -f tag_lite/smallint.py +python3 ./test.py -f tag_lite/tinyint.py -python3 ./test.py $1 -f dbmgmt/database-name-boundary.py +python3 ./test.py -f dbmgmt/database-name-boundary.py -python3 ./test.py $1 -f import_merge/importBlock1HO.py -python3 ./test.py $1 -f import_merge/importBlock1HPO.py -python3 ./test.py $1 -f import_merge/importBlock1H.py -python3 ./test.py $1 -f import_merge/importBlock1S.py -python3 ./test.py $1 -f import_merge/importBlock1Sub.py -python3 ./test.py $1 -f import_merge/importBlock1TO.py -python3 ./test.py $1 -f import_merge/importBlock1TPO.py -python3 ./test.py $1 -f import_merge/importBlock1T.py -python3 ./test.py $1 -f import_merge/importBlock2HO.py -python3 ./test.py $1 -f import_merge/importBlock2HPO.py -python3 ./test.py $1 -f import_merge/importBlock2H.py -python3 ./test.py $1 -f import_merge/importBlock2S.py -python3 ./test.py $1 -f import_merge/importBlock2Sub.py -python3 ./test.py $1 -f import_merge/importBlock2TO.py -python3 ./test.py $1 -f import_merge/importBlock2TPO.py -python3 ./test.py $1 -f import_merge/importBlock2T.py -python3 ./test.py $1 -f import_merge/importBlockbetween.py -python3 ./test.py $1 -f import_merge/importCacheFileHO.py -python3 ./test.py $1 -f import_merge/importCacheFileHPO.py -python3 ./test.py $1 -f import_merge/importCacheFileH.py -python3 ./test.py $1 -f import_merge/importCacheFileS.py -python3 ./test.py $1 -f import_merge/importCacheFileSub.py -python3 ./test.py $1 -f import_merge/importCacheFileTO.py -python3 ./test.py $1 -f import_merge/importCacheFileTPO.py -python3 ./test.py $1 -f import_merge/importCacheFileT.py -python3 ./test.py $1 -f import_merge/importDataH2.py -python3 ./test.py $1 -f import_merge/importDataHO2.py -python3 ./test.py $1 -f import_merge/importDataHO.py -python3 ./test.py $1 -f import_merge/importDataHPO.py -python3 ./test.py $1 -f import_merge/importDataLastHO.py -python3 ./test.py $1 -f import_merge/importDataLastHPO.py -python3 ./test.py $1 -f import_merge/importDataLastH.py -python3 ./test.py $1 -f import_merge/importDataLastS.py -python3 ./test.py $1 -f import_merge/importDataLastSub.py -python3 ./test.py $1 -f import_merge/importDataLastTO.py -python3 ./test.py $1 -f import_merge/importDataLastTPO.py -python3 ./test.py $1 -f import_merge/importDataLastT.py -python3 ./test.py $1 -f import_merge/importDataS.py -python3 ./test.py $1 -f import_merge/importDataSub.py -python3 ./test.py $1 -f import_merge/importDataTO.py -python3 ./test.py $1 -f import_merge/importDataTPO.py -python3 ./test.py $1 -f import_merge/importDataT.py -python3 ./test.py $1 -f import_merge/importHeadOverlap.py -python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py -python3 ./test.py $1 -f import_merge/importHead.py -python3 ./test.py $1 -f import_merge/importHORestart.py -python3 ./test.py $1 -f import_merge/importHPORestart.py -python3 ./test.py $1 -f import_merge/importHRestart.py -python3 ./test.py $1 -f import_merge/importLastHO.py -python3 ./test.py $1 -f import_merge/importLastHPO.py -python3 ./test.py $1 -f import_merge/importLastH.py -python3 ./test.py $1 -f import_merge/importLastS.py -python3 ./test.py $1 -f import_merge/importLastSub.py -python3 ./test.py $1 -f import_merge/importLastTO.py -python3 ./test.py $1 -f import_merge/importLastTPO.py -python3 ./test.py $1 -f import_merge/importLastT.py -python3 ./test.py $1 -f import_merge/importSpan.py -python3 ./test.py $1 -f import_merge/importSRestart.py -python3 ./test.py $1 -f import_merge/importSubRestart.py -python3 ./test.py $1 -f import_merge/importTailOverlap.py -python3 ./test.py $1 -f import_merge/importTailPartOverlap.py -python3 ./test.py $1 -f import_merge/importTail.py -python3 ./test.py $1 -f import_merge/importToCommit.py -python3 ./test.py $1 -f import_merge/importTORestart.py -python3 ./test.py $1 -f import_merge/importTPORestart.py -python3 ./test.py $1 -f import_merge/importTRestart.py +python3 ./test.py -f import_merge/importBlock1HO.py +python3 ./test.py -f import_merge/importBlock1HPO.py +python3 ./test.py -f import_merge/importBlock1H.py +python3 ./test.py -f import_merge/importBlock1S.py +python3 ./test.py -f import_merge/importBlock1Sub.py +python3 ./test.py -f import_merge/importBlock1TO.py +python3 ./test.py -f import_merge/importBlock1TPO.py +python3 ./test.py -f import_merge/importBlock1T.py +python3 ./test.py -f import_merge/importBlock2HO.py +python3 ./test.py -f import_merge/importBlock2HPO.py +python3 ./test.py -f import_merge/importBlock2H.py +python3 ./test.py -f import_merge/importBlock2S.py +python3 ./test.py -f import_merge/importBlock2Sub.py +python3 ./test.py -f import_merge/importBlock2TO.py +python3 ./test.py -f import_merge/importBlock2TPO.py +python3 ./test.py -f import_merge/importBlock2T.py +python3 ./test.py -f import_merge/importBlockbetween.py +python3 ./test.py -f import_merge/importCacheFileHO.py +python3 ./test.py -f import_merge/importCacheFileHPO.py +python3 ./test.py -f import_merge/importCacheFileH.py +python3 ./test.py -f import_merge/importCacheFileS.py +python3 ./test.py -f import_merge/importCacheFileSub.py +python3 ./test.py -f import_merge/importCacheFileTO.py +python3 ./test.py -f import_merge/importCacheFileTPO.py +python3 ./test.py -f import_merge/importCacheFileT.py +python3 ./test.py -f import_merge/importDataH2.py +python3 ./test.py -f import_merge/importDataHO2.py +python3 ./test.py -f import_merge/importDataHO.py +python3 ./test.py -f import_merge/importDataHPO.py +python3 ./test.py -f import_merge/importDataLastHO.py +python3 ./test.py -f import_merge/importDataLastHPO.py +python3 ./test.py -f import_merge/importDataLastH.py +python3 ./test.py -f import_merge/importDataLastS.py +python3 ./test.py -f import_merge/importDataLastSub.py +python3 ./test.py -f import_merge/importDataLastTO.py +python3 ./test.py -f import_merge/importDataLastTPO.py +python3 ./test.py -f import_merge/importDataLastT.py +python3 ./test.py -f import_merge/importDataS.py +python3 ./test.py -f import_merge/importDataSub.py +python3 ./test.py -f import_merge/importDataTO.py +python3 ./test.py -f import_merge/importDataTPO.py +python3 ./test.py -f import_merge/importDataT.py +python3 ./test.py -f import_merge/importHeadOverlap.py +python3 ./test.py -f import_merge/importHeadPartOverlap.py +python3 ./test.py -f import_merge/importHead.py +python3 ./test.py -f import_merge/importHORestart.py +python3 ./test.py -f import_merge/importHPORestart.py +python3 ./test.py -f import_merge/importHRestart.py +python3 ./test.py -f import_merge/importLastHO.py +python3 ./test.py -f import_merge/importLastHPO.py +python3 ./test.py -f import_merge/importLastH.py +python3 ./test.py -f import_merge/importLastS.py +python3 ./test.py -f import_merge/importLastSub.py +python3 ./test.py -f import_merge/importLastTO.py +python3 ./test.py -f import_merge/importLastTPO.py +python3 ./test.py -f import_merge/importLastT.py +python3 ./test.py -f import_merge/importSpan.py +python3 ./test.py -f import_merge/importSRestart.py +python3 ./test.py -f import_merge/importSubRestart.py +python3 ./test.py -f import_merge/importTailOverlap.py +python3 ./test.py -f import_merge/importTailPartOverlap.py +python3 ./test.py -f import_merge/importTail.py +python3 ./test.py -f import_merge/importToCommit.py +python3 ./test.py -f import_merge/importTORestart.py +python3 ./test.py -f import_merge/importTPORestart.py +python3 ./test.py -f import_merge/importTRestart.py +python3 ./test.py -f import_merge/importInsertThenImport.py # user -python3 ./test.py $1 -f user/user_create.py -python3 ./test.py $1 -f user/pass_len.py +python3 ./test.py -f user/user_create.py +python3 ./test.py -f user/pass_len.py # table -#python3 ./test.py $1 -f table/del_stable.py +#python3 ./test.py -f table/del_stable.py + +#query +python3 ./test.py -f query/filter.py diff --git a/tests/pytest/import_merge/importBlock1H.py b/tests/pytest/import_merge/importBlock1H.py index a1ba905b173b52a835488a6f0151587729d9e1d7..fca37ff1b1e3a1f9129e9498076fc995ba8f0918 100644 --- a/tests/pytest/import_merge/importBlock1H.py +++ b/tests/pytest/import_merge/importBlock1H.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1HO.py b/tests/pytest/import_merge/importBlock1HO.py index 73aec07a9038f3e10350ef10e3da1d2acfbc2a4f..c853d3a6afe216c9de3bc2f19eabbed56bce2bb2 100644 --- a/tests/pytest/import_merge/importBlock1HO.py +++ b/tests/pytest/import_merge/importBlock1HO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1HPO.py b/tests/pytest/import_merge/importBlock1HPO.py index ad224e5c65ea4703ef54e06bffa33a65f817d705..968f21f50f0d11f7e70c8b4fb809690ab04c6982 100644 --- a/tests/pytest/import_merge/importBlock1HPO.py +++ b/tests/pytest/import_merge/importBlock1HPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1S.py b/tests/pytest/import_merge/importBlock1S.py index 37c2ad663190622520a6e9c4c9a2d7af59c7be44..6a0ce18edfe96512d84c3132b465c253769ff38c 100644 --- a/tests/pytest/import_merge/importBlock1S.py +++ b/tests/pytest/import_merge/importBlock1S.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1Sub.py b/tests/pytest/import_merge/importBlock1Sub.py index 5228563651883ccca70e4132edee055912cf8bbd..2eaf5fc26e0f901ba5dc2b0439f80c00bdada940 100644 --- a/tests/pytest/import_merge/importBlock1Sub.py +++ b/tests/pytest/import_merge/importBlock1Sub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1T.py b/tests/pytest/import_merge/importBlock1T.py index 75f41b98cfbee136d8f147736f8765fa4b82eddb..ffac67a7e11b7e5d26c14fe3b6a97769d9bf8322 100644 --- a/tests/pytest/import_merge/importBlock1T.py +++ b/tests/pytest/import_merge/importBlock1T.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1TO.py b/tests/pytest/import_merge/importBlock1TO.py index b43428da27900e57754f2095d001ea2f80d67acb..5d6c6624d94f21a4ad9252da227dd846e2363e76 100644 --- a/tests/pytest/import_merge/importBlock1TO.py +++ b/tests/pytest/import_merge/importBlock1TO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock1TPO.py b/tests/pytest/import_merge/importBlock1TPO.py index 913ca1cc0230d56c7970b1648a7cdde80cff612e..e7807e892a4f0b889515674a2cde634d6cc7add9 100644 --- a/tests/pytest/import_merge/importBlock1TPO.py +++ b/tests/pytest/import_merge/importBlock1TPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2H.py b/tests/pytest/import_merge/importBlock2H.py index bacd88cbe793d0c0a1139b3ae72f6b294a37b997..eea1e4bcf809a5561fb4f93bf2e92832824f9d74 100644 --- a/tests/pytest/import_merge/importBlock2H.py +++ b/tests/pytest/import_merge/importBlock2H.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2HO.py b/tests/pytest/import_merge/importBlock2HO.py index 01c0f622b62cf25eb9f66b7f95f1e2b829fd6030..99a9662f1c3bc38c1cb08084eeebd9fd9a8cd20a 100644 --- a/tests/pytest/import_merge/importBlock2HO.py +++ b/tests/pytest/import_merge/importBlock2HO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2HPO.py b/tests/pytest/import_merge/importBlock2HPO.py index ee8d580dfe90a5d4ad0cf3f4e198ba63b050325b..54afef6c06d4beff95a8a5e8a5e9048d5b856529 100644 --- a/tests/pytest/import_merge/importBlock2HPO.py +++ b/tests/pytest/import_merge/importBlock2HPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2S.py b/tests/pytest/import_merge/importBlock2S.py index d85074bfeb0e34b81a222fa52c3ebd06c5bd16ab..9d4757709a7b58dcdecbe652c374169381f54112 100644 --- a/tests/pytest/import_merge/importBlock2S.py +++ b/tests/pytest/import_merge/importBlock2S.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2Sub.py b/tests/pytest/import_merge/importBlock2Sub.py index deb1dc83373fdcd03ec758aeb91ff6aab3b17a4d..db43a492bcd5ee5fea81867d1887d47e83cc8f18 100644 --- a/tests/pytest/import_merge/importBlock2Sub.py +++ b/tests/pytest/import_merge/importBlock2Sub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2T.py b/tests/pytest/import_merge/importBlock2T.py index ded698d28c282aa5b304c088e2b11cefb1efcbed..c0d85fa3b07d341f90a32d14cb1a62c7467cc4c2 100644 --- a/tests/pytest/import_merge/importBlock2T.py +++ b/tests/pytest/import_merge/importBlock2T.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2TO.py b/tests/pytest/import_merge/importBlock2TO.py index ffc88c2c999b51e83d6024c6b05e6b36f87ffc14..05692c336de67d48a0f973f5c296cfff6dc0f00e 100644 --- a/tests/pytest/import_merge/importBlock2TO.py +++ b/tests/pytest/import_merge/importBlock2TO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlock2TPO.py b/tests/pytest/import_merge/importBlock2TPO.py index 8b6c70c32be0190b32cc5ccf2f8df64906522b2e..817d2db3827b7484d0134094aa2c6fb6aee61857 100644 --- a/tests/pytest/import_merge/importBlock2TPO.py +++ b/tests/pytest/import_merge/importBlock2TPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importBlockbetween.py b/tests/pytest/import_merge/importBlockbetween.py index c3482b37763a12b8a36e406421cffe22ea724f3b..2e4ac8a7370af0c0645b0ff15aba62ff18be3ced 100644 --- a/tests/pytest/import_merge/importBlockbetween.py +++ b/tests/pytest/import_merge/importBlockbetween.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -34,7 +34,7 @@ class TDTestCase: tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512') + tdSql.execute('create database db cache 128') tdSql.execute('use db') tdLog.info("================= step1") diff --git a/tests/pytest/import_merge/importCacheFileH.py b/tests/pytest/import_merge/importCacheFileH.py index cd2b3a73f10ca63b65bd14559b487ec2da5510e6..3398f7bdad8d7524e223f0a2847b579081686476 100644 --- a/tests/pytest/import_merge/importCacheFileH.py +++ b/tests/pytest/import_merge/importCacheFileH.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileHO.py b/tests/pytest/import_merge/importCacheFileHO.py index 2e65c337b7c2a77f25726ca5806bd0ca02a55a53..19520dc3d048a267c03850b608d47db20394c43d 100644 --- a/tests/pytest/import_merge/importCacheFileHO.py +++ b/tests/pytest/import_merge/importCacheFileHO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileHPO.py b/tests/pytest/import_merge/importCacheFileHPO.py index f01ebd0d60dc5ef1bbcfa4e2e8ea45d75454d627..9e0a57fb462cdb6ae1dee3c8bfee4488c99a76a0 100644 --- a/tests/pytest/import_merge/importCacheFileHPO.py +++ b/tests/pytest/import_merge/importCacheFileHPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileS.py b/tests/pytest/import_merge/importCacheFileS.py index 0bb9107562e72fc2dded3cf918f904920529b94d..2f0af569e564b64cbb88c048762e8d41dcf21cbd 100644 --- a/tests/pytest/import_merge/importCacheFileS.py +++ b/tests/pytest/import_merge/importCacheFileS.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileSub.py b/tests/pytest/import_merge/importCacheFileSub.py index cd5d2509687a9be414b9328d1f66749ffc5138e6..300bb6e8d09f4484e22e64a0f2caf50cab7c8ab4 100644 --- a/tests/pytest/import_merge/importCacheFileSub.py +++ b/tests/pytest/import_merge/importCacheFileSub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileT.py b/tests/pytest/import_merge/importCacheFileT.py index be79e26bc7786387a2f04dadb79616f641812de2..ab33cf6a93c4bbd7f27967f6a70b61fc62230f65 100644 --- a/tests/pytest/import_merge/importCacheFileT.py +++ b/tests/pytest/import_merge/importCacheFileT.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileTO.py b/tests/pytest/import_merge/importCacheFileTO.py index dd17de3adf9fd9bf640c92fd6c53e492467747c6..00e22da976618b4ee870a5702542f669693e3727 100644 --- a/tests/pytest/import_merge/importCacheFileTO.py +++ b/tests/pytest/import_merge/importCacheFileTO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importCacheFileTPO.py b/tests/pytest/import_merge/importCacheFileTPO.py index 948b99ed21d971ea99f347bc7e83adcb63973df8..c6089e1d687fea6ac900931a8171e45f4923f0cb 100644 --- a/tests/pytest/import_merge/importCacheFileTPO.py +++ b/tests/pytest/import_merge/importCacheFileTPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataH2.py b/tests/pytest/import_merge/importDataH2.py index b5e53d862e75935a66303f096374374a298b6a25..a21f0c47be2eb11a57182d22b56d4447ff2d7ab6 100644 --- a/tests/pytest/import_merge/importDataH2.py +++ b/tests/pytest/import_merge/importDataH2.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataHO.py b/tests/pytest/import_merge/importDataHO.py index f6d65a5c53621c52712e0deea8edd9c1eba6c2ae..fdcaedd83c99482914805cb65a067cbcbc78a128 100644 --- a/tests/pytest/import_merge/importDataHO.py +++ b/tests/pytest/import_merge/importDataHO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataHO2.py b/tests/pytest/import_merge/importDataHO2.py index 6246b55b324b5ccbd2543af0d7f68c153a89d0bd..b094701132677d6e72e834b16b7edc106682be14 100644 --- a/tests/pytest/import_merge/importDataHO2.py +++ b/tests/pytest/import_merge/importDataHO2.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataHPO.py b/tests/pytest/import_merge/importDataHPO.py index c749dbd1138ac56942e4a38752e01d18226946e2..9d74c0c3522eba3687618132c27ce95f86f91b91 100644 --- a/tests/pytest/import_merge/importDataHPO.py +++ b/tests/pytest/import_merge/importDataHPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastH.py b/tests/pytest/import_merge/importDataLastH.py index 830711a420428e27dc5edf4b56b71d0dc866ba24..c8e5f62423dc21254d215fac41926aeb9ce5ba40 100644 --- a/tests/pytest/import_merge/importDataLastH.py +++ b/tests/pytest/import_merge/importDataLastH.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastHO.py b/tests/pytest/import_merge/importDataLastHO.py index 037c81f0872517e3343bb46aaa9694a658d38cc8..33215997a4220b65228b630ebc350bf9dae15046 100644 --- a/tests/pytest/import_merge/importDataLastHO.py +++ b/tests/pytest/import_merge/importDataLastHO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastHPO.py b/tests/pytest/import_merge/importDataLastHPO.py index 46a7e5909da922cbc554d4f5c9893346c19e9c87..fa8542f35b8e9639db20dc2e1886fca36140e825 100644 --- a/tests/pytest/import_merge/importDataLastHPO.py +++ b/tests/pytest/import_merge/importDataLastHPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastS.py b/tests/pytest/import_merge/importDataLastS.py index 2dd7cdb744e600c0d2b0508afe4b8ad46b139425..2f595fef542955e616ef2e6ebcce7f23bce71d80 100644 --- a/tests/pytest/import_merge/importDataLastS.py +++ b/tests/pytest/import_merge/importDataLastS.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastSub.py b/tests/pytest/import_merge/importDataLastSub.py index bb9953057e10a29298d613a1e4047d1d6e5d1299..5c2069c90f52b4c786739f4d58e1ce41185c0f93 100644 --- a/tests/pytest/import_merge/importDataLastSub.py +++ b/tests/pytest/import_merge/importDataLastSub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastT.py b/tests/pytest/import_merge/importDataLastT.py index 29f0afaf1a3a003734c1cc42674e9b96b5a7ced2..08e944eb6836a6f7f938639b40a6124f7bb64ec6 100644 --- a/tests/pytest/import_merge/importDataLastT.py +++ b/tests/pytest/import_merge/importDataLastT.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastTO.py b/tests/pytest/import_merge/importDataLastTO.py index 47639130b59f2cc67be66bbf9e2f4a2f35a50112..a82c0541414298accfdfb447c318ffafd88e5852 100644 --- a/tests/pytest/import_merge/importDataLastTO.py +++ b/tests/pytest/import_merge/importDataLastTO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataLastTPO.py b/tests/pytest/import_merge/importDataLastTPO.py index 41908365051586bbe4628582e0bfffa3bb97d838..ff75a1b2ae87891853fa93f0f49fff339cf6e488 100644 --- a/tests/pytest/import_merge/importDataLastTPO.py +++ b/tests/pytest/import_merge/importDataLastTPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataS.py b/tests/pytest/import_merge/importDataS.py index daa4b2e0252920e8f98779f01d81c6a8353c4071..37627e8d6bcc8319805275525ef7874132e0da4d 100644 --- a/tests/pytest/import_merge/importDataS.py +++ b/tests/pytest/import_merge/importDataS.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataSub.py b/tests/pytest/import_merge/importDataSub.py index e946a254c205b94c6a89702d7a037960c124ab99..17e2b141b7014fd2ce4d31f8c335e122aca730ba 100644 --- a/tests/pytest/import_merge/importDataSub.py +++ b/tests/pytest/import_merge/importDataSub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataT.py b/tests/pytest/import_merge/importDataT.py index abb5e312ef5217e3b1b67583d28a09ea07d6a896..b0b7b82b790e81c475c714ba570a9a6f1801cc13 100644 --- a/tests/pytest/import_merge/importDataT.py +++ b/tests/pytest/import_merge/importDataT.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataTO.py b/tests/pytest/import_merge/importDataTO.py index 2a6d9e272b1cbe5c5bb4925538ba54a2d54b2791..c0b57136af7a51c1d184eb5789d95efc0148118c 100644 --- a/tests/pytest/import_merge/importDataTO.py +++ b/tests/pytest/import_merge/importDataTO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importDataTPO.py b/tests/pytest/import_merge/importDataTPO.py index 06d5cf3c1a2ff2d9326065f45b2451807effbe22..8a1c9264b433484e768cdfffbccdb0966e3d15cd 100644 --- a/tests/pytest/import_merge/importDataTPO.py +++ b/tests/pytest/import_merge/importDataTPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHORestart.py b/tests/pytest/import_merge/importHORestart.py index cfbfa61c90ec1521d3db507f7a485b0f609e858d..f74c4c76d616753f8cadc87ba715e473eae0fb46 100644 --- a/tests/pytest/import_merge/importHORestart.py +++ b/tests/pytest/import_merge/importHORestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHPORestart.py b/tests/pytest/import_merge/importHPORestart.py index 7e96d44a1a3390a351a45620ae29f02fdff06d51..e5f79fbe6c2eb686d63f5b7de81651a98072a986 100644 --- a/tests/pytest/import_merge/importHPORestart.py +++ b/tests/pytest/import_merge/importHPORestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHRestart.py b/tests/pytest/import_merge/importHRestart.py index aa1783977ee833418c35803fa4069af9e448a6aa..be67039789dd660ddb0be8d56753737010e47e79 100644 --- a/tests/pytest/import_merge/importHRestart.py +++ b/tests/pytest/import_merge/importHRestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHead.py b/tests/pytest/import_merge/importHead.py index 6971986ebc9bedd41326985ef0848dabc39aa260..80e6d92c69f2328bd35a43af820ca16658daf63b 100644 --- a/tests/pytest/import_merge/importHead.py +++ b/tests/pytest/import_merge/importHead.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHeadOverlap.py b/tests/pytest/import_merge/importHeadOverlap.py index df5f07b5a250116b37e9d67f1e5b1dae28c7242c..535c0c285960c4657dc1cefeb0dd2cf128a2434f 100644 --- a/tests/pytest/import_merge/importHeadOverlap.py +++ b/tests/pytest/import_merge/importHeadOverlap.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importHeadPartOverlap.py b/tests/pytest/import_merge/importHeadPartOverlap.py index 8c9885e22ff9b83ca98207d9dc862b9a7e994cbb..85ddd64f0a66c5b962d1f33d517c1d28f9521d0a 100644 --- a/tests/pytest/import_merge/importHeadPartOverlap.py +++ b/tests/pytest/import_merge/importHeadPartOverlap.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importInsertThenImport.py b/tests/pytest/import_merge/importInsertThenImport.py new file mode 100644 index 0000000000000000000000000000000000000000..292fae8c47b398dcbacdb8b76592826bcc8b6019 --- /dev/null +++ b/tests/pytest/import_merge/importInsertThenImport.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("insert 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'insert into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + + tdLog.info("================= step4") + tdLog.info("import 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + tdLog.info("================= step5") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(10) + + tdLog.info("================= step6") + tdLog.info("import 100 sequential data again") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdLog.info("================= step7") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastH.py b/tests/pytest/import_merge/importLastH.py index a6f9fa087c7db215a03745054ac6f8367d218e2f..17fa233e3723e1d9e6cc4ec97c8eac2716751f00 100644 --- a/tests/pytest/import_merge/importLastH.py +++ b/tests/pytest/import_merge/importLastH.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastHO.py b/tests/pytest/import_merge/importLastHO.py index e6468b243e05941cc82310de2c3dc197ab4da7d9..adb44fc0eab9a4923b0896a1357b24603f1ff3fd 100644 --- a/tests/pytest/import_merge/importLastHO.py +++ b/tests/pytest/import_merge/importLastHO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastHPO.py b/tests/pytest/import_merge/importLastHPO.py index 4a299ed82369a1b81b2a419f3d0f45d0b64404f9..d8ed2d9ef10dbaa52e92ba50625be25c495091ea 100644 --- a/tests/pytest/import_merge/importLastHPO.py +++ b/tests/pytest/import_merge/importLastHPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastS.py b/tests/pytest/import_merge/importLastS.py index 2a5de46eb2d0a55039caddf352af9dba7f258fca..bf222a0d5f3c27c5c7774b384799a6a0aa5e4114 100644 --- a/tests/pytest/import_merge/importLastS.py +++ b/tests/pytest/import_merge/importLastS.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastSub.py b/tests/pytest/import_merge/importLastSub.py index fa1b2387f317560784bb2b0e28cfe6309a408c89..5a6b9f41502970149257b1aef5c7a37824401768 100644 --- a/tests/pytest/import_merge/importLastSub.py +++ b/tests/pytest/import_merge/importLastSub.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastT.py b/tests/pytest/import_merge/importLastT.py index b7a1e58bc5d19356c1228abe2bfb552aa0277f74..2b1be1fe2b37aa5e4d59bb6ecef7d0bb2180cf9d 100644 --- a/tests/pytest/import_merge/importLastT.py +++ b/tests/pytest/import_merge/importLastT.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastTO.py b/tests/pytest/import_merge/importLastTO.py index 541cbd29ca08b61f1a94b0180673552f66452c09..ce189f63718956991982bd33296eb71bd5a82d45 100644 --- a/tests/pytest/import_merge/importLastTO.py +++ b/tests/pytest/import_merge/importLastTO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importLastTPO.py b/tests/pytest/import_merge/importLastTPO.py index 6ec21d0c79e935b7581d7414d3dc098217f76204..627d090855ac320f56a90fb647101e8ccc315acd 100644 --- a/tests/pytest/import_merge/importLastTPO.py +++ b/tests/pytest/import_merge/importLastTPO.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importSRestart.py b/tests/pytest/import_merge/importSRestart.py index 0771b8bf9c3b9d758363f3089dcdee0c8830f4f3..29f5a19b54fb0cbf1eb81a66c66813f3fcdd9982 100644 --- a/tests/pytest/import_merge/importSRestart.py +++ b/tests/pytest/import_merge/importSRestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importSpan.py b/tests/pytest/import_merge/importSpan.py index 736c4bad64038ff92704cbf5a55e922cd99cfe29..4e20e9754f86b287328aacb3e96f9ac0e7c4eee6 100644 --- a/tests/pytest/import_merge/importSpan.py +++ b/tests/pytest/import_merge/importSpan.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importSubRestart.py b/tests/pytest/import_merge/importSubRestart.py index f7f33d32c1a9f149bbcef7174bca0f087caadc40..b1a6f30c436c5aa52d5ee4affa03d18c5475ced7 100644 --- a/tests/pytest/import_merge/importSubRestart.py +++ b/tests/pytest/import_merge/importSubRestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTORestart.py b/tests/pytest/import_merge/importTORestart.py index 194756cd1291f3a9ef2f6c13e896be4e053fc479..07eb6c28cb79c16504f2acab036a3b66c3bccabf 100644 --- a/tests/pytest/import_merge/importTORestart.py +++ b/tests/pytest/import_merge/importTORestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTPORestart.py b/tests/pytest/import_merge/importTPORestart.py index 36d4b64390807c11a51beb36368d2aafa841d3af..10bbf3efced90b6c255326c0e8b8e0c106a3a038 100644 --- a/tests/pytest/import_merge/importTPORestart.py +++ b/tests/pytest/import_merge/importTPORestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTRestart.py b/tests/pytest/import_merge/importTRestart.py index 9308518d8c442c1e18ca39133a352e1659bfed72..63a9368eca2b6a3377b32dc6a3948cf5a0ba1186 100644 --- a/tests/pytest/import_merge/importTRestart.py +++ b/tests/pytest/import_merge/importTRestart.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTail.py b/tests/pytest/import_merge/importTail.py index a80db730a0d0c02bb30d402986a7e0e355f9d046..a552edb2449d8c8360403561398070279b7143c9 100644 --- a/tests/pytest/import_merge/importTail.py +++ b/tests/pytest/import_merge/importTail.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTailOverlap.py b/tests/pytest/import_merge/importTailOverlap.py index 98596d2f77ce679b782a288bc2be1ce0103a070d..78e51f93f92ab510d56b55201c801cc53fbded12 100644 --- a/tests/pytest/import_merge/importTailOverlap.py +++ b/tests/pytest/import_merge/importTailOverlap.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importTailPartOverlap.py b/tests/pytest/import_merge/importTailPartOverlap.py index 0263114a25c3e9e5d56329ad6d52502bf8fcbb9b..e433cb66f37102a085c0faebbd85122b163c9c47 100644 --- a/tests/pytest/import_merge/importTailPartOverlap.py +++ b/tests/pytest/import_merge/importTailPartOverlap.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 diff --git a/tests/pytest/import_merge/importToCommit.py b/tests/pytest/import_merge/importToCommit.py index 3684dde049ff0185c3bde7ff50886c3e24ce55fe..dd2c27918ab7f52d799715b2c14ac02c05fc7aca 100644 --- a/tests/pytest/import_merge/importToCommit.py +++ b/tests/pytest/import_merge/importToCommit.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 1 @@ -33,7 +33,7 @@ class TDTestCase: tdDnodes.start(1) tdSql.execute('reset query cache') tdSql.execute('drop database if exists db') - tdSql.execute('create database db cache 512 maxtables 10') + tdSql.execute('create database db cache 128 maxtables 10') tdSql.execute('use db') tdLog.info("================= step1") @@ -45,7 +45,8 @@ class TDTestCase: tdLog.info("================= step2") tdLog.info('insert data until the first commit') dnodesDir = tdDnodes.getDnodesRootDir() - dataDir = dnodesDir + '/dnode1/data/data' + dataDir = dnodesDir + '/dnode1/data/vnode' + tdLog.info('CBD: dataDir=%s' % dataDir) startTime = self.startTime rid0 = 1 while (True): diff --git a/tests/pytest/insert/basic.py b/tests/pytest/insert/basic.py index 35f830d951d4e6d7ec14eb2a1f5d4b34d0b98b71..dcb5834d559968a964c4057c61d9b6a40cf8ab15 100644 --- a/tests/pytest/insert/basic.py +++ b/tests/pytest/insert/basic.py @@ -18,9 +18,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/bigint.py b/tests/pytest/insert/bigint.py index 214200900a569c9336d5ee05bd088cbd405bb965..7c7d2d0f9507e8688dd73bcefe88632361c80c70 100644 --- a/tests/pytest/insert/bigint.py +++ b/tests/pytest/insert/bigint.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/binary-boundary.py b/tests/pytest/insert/binary-boundary.py index 583217a73261379bcb0101c360a51a7e29cf785d..bb86ddf61c3abcd56d2bb27f7f7da5f1d22069ee 100644 --- a/tests/pytest/insert/binary-boundary.py +++ b/tests/pytest/insert/binary-boundary.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py index 677ae4bf298cd22cefce8f18ee255ea2c982e155..0d583aa2cce26fb400e4a943f49cacee96c933d6 100644 --- a/tests/pytest/insert/binary.py +++ b/tests/pytest/insert/binary.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/bool.py b/tests/pytest/insert/bool.py index c175afd8b556f0a9e82c23c4a6d62eacf45a0f70..1412567cd75721d99308ddadfe7b35032207faaa 100644 --- a/tests/pytest/insert/bool.py +++ b/tests/pytest/insert/bool.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/date.py b/tests/pytest/insert/date.py index fb7f1816c4755f4c5365a2ea01d8893a91623b0c..6e22e5b72ee465bfd32b9fd839c8ab0deba9267c 100644 --- a/tests/pytest/insert/date.py +++ b/tests/pytest/insert/date.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/double.py b/tests/pytest/insert/double.py index 19be9653c0852b541de8d2430640b23c85ee7e86..1b66ed1c44c7cec645be1f0f23866c7f06501ebc 100644 --- a/tests/pytest/insert/double.py +++ b/tests/pytest/insert/double.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/float.py b/tests/pytest/insert/float.py index 414833877ea63fd405b71ced4124438b04c2d699..8b6277d43657c1da3fa5e65ddbaa073fd7a7189e 100644 --- a/tests/pytest/insert/float.py +++ b/tests/pytest/insert/float.py @@ -19,9 +19,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/int.py b/tests/pytest/insert/int.py index 350426a5bde54dcd535577265c6f405cca364f04..4a94a331d63eaf04fd7d8ec37f4814b385017d22 100644 --- a/tests/pytest/insert/int.py +++ b/tests/pytest/insert/int.py @@ -20,9 +20,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/multi.py b/tests/pytest/insert/multi.py index c14d7dc2e0ac5d1317990cd2519671fdfb426b50..5f81f12fdbf471e4680d48c743d64878777788cd 100644 --- a/tests/pytest/insert/multi.py +++ b/tests/pytest/insert/multi.py @@ -20,9 +20,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/nchar-boundary.py b/tests/pytest/insert/nchar-boundary.py index 255cc5b79a57152c9efe1664ff1afbeb7c03abe4..05a66f60661c18de5a4fbf55f9850932d3d36e7a 100644 --- a/tests/pytest/insert/nchar-boundary.py +++ b/tests/pytest/insert/nchar-boundary.py @@ -18,9 +18,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/nchar-unicode.py b/tests/pytest/insert/nchar-unicode.py index 12eef379d39c535c4357e7ce0d27ccdbdb1a0602..152a09723ed262cfa6ceaad15ba89829996182b2 100644 --- a/tests/pytest/insert/nchar-unicode.py +++ b/tests/pytest/insert/nchar-unicode.py @@ -18,9 +18,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/nchar.py b/tests/pytest/insert/nchar.py index d61a44844dae7997721f5cae9e4e38d1f217e05a..b8e365f143abfca2eb39f258078fb59120c168e1 100644 --- a/tests/pytest/insert/nchar.py +++ b/tests/pytest/insert/nchar.py @@ -18,9 +18,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/randomNullCommit.py b/tests/pytest/insert/randomNullCommit.py new file mode 100644 index 0000000000000000000000000000000000000000..f90bb9b3e5e985aa1777899c6e53b261072193aa --- /dev/null +++ b/tests/pytest/insert/randomNullCommit.py @@ -0,0 +1,64 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute('create table tb (ts timestamp, speed int, temp float, note binary(5), flag bool)') + + numOfRecords = 0 + randomList = [10, 50, 100, 500, 1000, 5000] + for i in range(0, 10): + num = random.choice(randomList) + tdLog.info("will insert %d records" % num) + for x in range(0, num): + tdLog.info( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) + tdSql.execute( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) + + numOfRecords = numOfRecords + num + + tdSql.query("select * from tb") + tdSql.checkRows(numOfRecords) + tdSql.checkData(numOfRecords-num, 1, None) + tdSql.checkData(numOfRecords-1, 2, None) + + tdLog.info("stop dnode to commit data to disk") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/smallint.py b/tests/pytest/insert/smallint.py index 0d85e45cfa82866542d2bf465624983155992f7c..16322e9aeb801ae92b75b920922991206a4b2e35 100644 --- a/tests/pytest/insert/smallint.py +++ b/tests/pytest/insert/smallint.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/insert/tinyint.py b/tests/pytest/insert/tinyint.py index 6d7178054e749f99a1ee6f40097f67ecc74a4c63..a10c999e8c2f0fe070347651f9246e3734104eca 100644 --- a/tests/pytest/insert/tinyint.py +++ b/tests/pytest/insert/tinyint.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py new file mode 100644 index 0000000000000000000000000000000000000000..43c8e5bf0aa612079b26fdf9edc9d303023a1405 --- /dev/null +++ b/tests/pytest/query/filter.py @@ -0,0 +1,114 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), + ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), + ('2020-05-13 10:00:00.005', 3, 'third')""") + + # > for timestamp type + tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002'") + tdSql.checkRows(3) + + # > for numeric type + tdSql.query("select * from db.st where tagtype > 2") + tdSql.checkRows(2) + + # < for timestamp type + tdSql.query("select * from db.st where ts < '2020-05-13 10:00:00.002'") + tdSql.checkRows(2) + + # < for numeric type + tdSql.query("select * from db.st where tagtype < 2") + tdSql.checkRows(2) + + # >= for timestamp type + tdSql.query("select * from db.st where ts >= '2020-05-13 10:00:00.002'") + tdSql.checkRows(4) + + # >= for numeric type + tdSql.query("select * from db.st where tagtype >= 2") + tdSql.checkRows(4) + + # <= for timestamp type + tdSql.query("select * from db.st where ts <= '2020-05-13 10:00:00.002'") + tdSql.checkRows(3) + + # <= for numeric type + tdSql.query("select * from db.st where tagtype <= 2") + tdSql.checkRows(4) + + # = for timestamp type + tdSql.query("select * from db.st where ts = '2020-05-13 10:00:00.002'") + tdSql.checkRows(1) + + # = for numeric type + tdSql.query("select * from db.st where tagtype = 2") + tdSql.checkRows(2) + + # = for nchar type + tdSql.query("select * from db.st where name = 'first'") + tdSql.checkRows(2) + + # <> for timestamp type + tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") + #tdSql.checkRows(4) + + # <> for numeric type + tdSql.query("select * from db.st where tagtype <> 2") + tdSql.checkRows(4) + + # <> for nchar type + tdSql.query("select * from db.st where name <> 'first'") + tdSql.checkRows(4) + + # % for nchar type + tdSql.query("select * from db.st where name like 'fi%'") + tdSql.checkRows(2) + + # - for nchar type + tdSql.query("select * from db.st where name like '_econd'") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/query.py b/tests/pytest/query/query.py index 68b8baab64afce7c48eb51a2173e6d1187a1b7b8..da0ef96d0efde77b716ded06cc7efaa96ea3bb7b 100644 --- a/tests/pytest/query/query.py +++ b/tests/pytest/query/query.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/query/tbname.py b/tests/pytest/query/tbname.py index 5ea89fff82a1ef4af0b6f8d9a14671fb97180cd5..08416ba3eda378cce96fcaa8051e1d06a75d6b28 100644 --- a/tests/pytest/query/tbname.py +++ b/tests/pytest/query/tbname.py @@ -19,9 +19,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py index a3f4c00ea5cc68eb187b24bf311074df88c671b6..4e1e6ac2fa803a18c74d3d7e0b563425964a43eb 100644 --- a/tests/pytest/random-test/random-test.py +++ b/tests/pytest/random-test/random-test.py @@ -108,11 +108,23 @@ class Test: tdDnodes.start(1) tdSql.prepare() + def delete_datafiles(self): + tdLog.info("delete data files") + dnodesDir = tdDnodes.getDnodesRootDir() + dataDir = dnodesDir + '/dnode1/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + + self.current_tb = "" + self.last_tb = "" + self.written = 0 + tdDnodes.start(1) + tdSql.prepare() class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() @@ -129,10 +141,11 @@ class TDTestCase: 7: test.drop_table, 8: test.reset_query_cache, 9: test.reset_database, + 10: test.delete_datafiles, } for x in range(1, 100): - r = random.randint(1, 9) + r = random.randint(1, 10) tdLog.notice("iteration %d run func %d" % (x, r)) switch.get(r, lambda: "ERROR")() diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 5f48789d45d6a3a4fd49eecb14be7dac58ec325e..37a68baecf576ef1325e692f3fb5eddcdff590e9 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -46,7 +46,14 @@ python3 ./test.py $1 -f import_merge/importTail.py python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTRestart.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f import_merge/importInsertThenImport.py +python3 ./test.py $1 -s && sleep 1 #tag python3 ./test.py $1 -f tag_lite/filter.py python3 ./test.py $1 -s && sleep 1 + +#query +python3 ./test.py $1 -f query/filter.py +python3 ./test.py $1 -s && sleep 1 + diff --git a/tests/pytest/stable/insert.py b/tests/pytest/stable/insert.py index 9f9e7c6e066db628f66cd2d9e897f471ee5cff56..3d37e6726c965a8963f728fdd1d8dc89e1cee339 100644 --- a/tests/pytest/stable/insert.py +++ b/tests/pytest/stable/insert.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/alter_column.py b/tests/pytest/table/alter_column.py index 15bc9f7aa7ec3264f266f7f1ab0c57eb29f6aa44..73fdbe1ae91c71e0ce9a1574239dbee9ec3fd988 100644 --- a/tests/pytest/table/alter_column.py +++ b/tests/pytest/table/alter_column.py @@ -20,9 +20,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/boundary.py b/tests/pytest/table/boundary.py index faa222231bda5234dd624ffde5bf805b13524928..29fdd5c475b39a375071ab1d24b42ef098e901f3 100644 --- a/tests/pytest/table/boundary.py +++ b/tests/pytest/table/boundary.py @@ -10,140 +10,158 @@ from util.sql import * class TDTestCase: - def init( self, conn ): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) - - def getLimitFromSourceCode( self, name ): + def getLimitFromSourceCode(self, name): cmd = "grep -w '#define %s' ../../src/inc/taosdef.h|awk '{print $3}'" % name return int(subprocess.check_output(cmd, shell=True)) - - def generateString( self, length ): + def generateString(self, length): chars = string.ascii_uppercase + string.ascii_lowercase v = "" - for i in range( length ): - v += random.choice( chars ) + for i in range(length): + v += random.choice(chars) return v - - def checkTagBoundaries( self ): - tdLog.debug( "checking tag boundaries" ) + def checkTagBoundaries(self): + tdLog.debug("checking tag boundaries") tdSql.prepare() - maxTags = self.getLimitFromSourceCode( 'TSDB_MAX_TAGS' ) - totalTagsLen = self.getLimitFromSourceCode( 'TSDB_MAX_TAGS_LEN' ) - tdLog.notice( "max tags is %d" % maxTags ) - tdLog.notice( "max total tag length is %d" % totalTagsLen ) + maxTags = self.getLimitFromSourceCode('TSDB_MAX_TAGS') + totalTagsLen = self.getLimitFromSourceCode('TSDB_MAX_TAGS_LEN') + tdLog.notice("max tags is %d" % maxTags) + tdLog.notice("max total tag length is %d" % totalTagsLen) # for binary tags, 2 bytes are used for length tagLen = (totalTagsLen - maxTags * 2) // maxTags firstTagLen = totalTagsLen - 2 * maxTags - tagLen * (maxTags - 1) sql = "create table cars(ts timestamp, f int) tags(t0 binary(%d)" % firstTagLen - for i in range( 1, maxTags ): + for i in range(1, maxTags): sql += ", t%d binary(%d)" % (i, tagLen) sql += ");" - tdLog.debug( "creating super table: " + sql ) - tdSql.execute( sql ) - tdSql.query( 'show stables' ) - tdSql.checkRows( 1 ) + tdLog.debug("creating super table: " + sql) + tdSql.execute(sql) + tdSql.query('show stables') + tdSql.checkRows(1) - for i in range( 10 ): + for i in range(10): sql = "create table car%d using cars tags('%d'" % (i, i) sql += ", '0'" * (maxTags - 1) + ");" - tdLog.debug( "creating table: " + sql ) - tdSql.execute( sql ) + tdLog.debug("creating table: " + sql) + tdSql.execute(sql) sql = "insert into car%d values(now, 0);" % i - tdLog.debug( "inserting data: " + sql ) - tdSql.execute( sql ) - - tdSql.query( 'show tables' ) - tdLog.info( 'tdSql.checkRow(10)' ) - tdSql.checkRows( 10 ) + tdLog.debug("inserting data: " + sql) + tdSql.execute(sql) - tdSql.query( 'select * from cars;' ) - tdSql.checkRows( 10 ) + tdSql.query('show tables') + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + tdSql.query('select * from cars;') + tdSql.checkRows(10) - def checkColumnBoundaries( self ): - tdLog.debug( "checking column boundaries" ) + def checkColumnBoundaries(self): + tdLog.debug("checking column boundaries") tdSql.prepare() # one column is for timestamp - maxCols = self.getLimitFromSourceCode( 'TSDB_MAX_COLUMNS' ) - 1 + maxCols = self.getLimitFromSourceCode('TSDB_MAX_COLUMNS') - 1 sql = "create table cars (ts timestamp" - for i in range( maxCols ): + for i in range(maxCols): sql += ", c%d int" % i sql += ");" - tdSql.execute( sql ) - tdSql.query( 'show tables' ) - tdSql.checkRows( 1 ) + tdSql.execute(sql) + tdSql.query('show tables') + tdSql.checkRows(1) sql = "insert into cars values (now" - for i in range( maxCols ): + for i in range(maxCols): sql += ", %d" % i sql += ");" - tdSql.execute( sql ) - tdSql.query( 'select * from cars' ) - tdSql.checkRows( 1 ) + tdSql.execute(sql) + tdSql.query('select * from cars') + tdSql.checkRows(1) - - def checkTableNameBoundaries( self ): - tdLog.debug( "checking table name boundaries" ) + def checkTableNameBoundaries(self): + tdLog.debug("checking table name boundaries") tdSql.prepare() - maxTableNameLen = self.getLimitFromSourceCode( 'TSDB_TABLE_NAME_LEN' ) - tdLog.notice( "table name max length is %d" % maxTableNameLen ) - - name = self.generateString( maxTableNameLen - 1) - tdLog.info( "table name is '%s'" % name ) - - tdSql.execute( "create table %s (ts timestamp, value int)" % name ) - tdSql.execute( "insert into %s values(now, 0)" % name ) - - tdSql.query( 'show tables' ) - tdSql.checkRows( 1 ) - - tdSql.query( 'select * from %s' % name ) - tdSql.checkRows( 1 ) - - - def checkRowBoundaries( self ): - tdLog.debug( "checking row boundaries" ) + maxTableNameLen = self.getLimitFromSourceCode('TSDB_TABLE_NAME_LEN') + tdLog.notice("table name max length is %d" % maxTableNameLen) + + # create a super table with name exceed max length + sname = self.generateString(maxTableNameLen + 1) + tdLog.info("create a super table with length %d" % len(sname)) + tdSql.error("create table %s (ts timestamp, value int) tags(id int)" % sname) + + # create a super table with name of max length + sname = self.generateString(maxTableNameLen) + tdLog.info("create a super table with length %d" % len(sname)) + tdSql.execute("create table %s (ts timestamp, value int) tags(id int)" % sname) + tdLog.info("check table count, should be one") + tdSql.query('show stables') + tdSql.checkRows(1) + + # create a child table with name exceed max length + name = self.generateString(maxTableNameLen + 1) + tdLog.info("create a child table with length %d" % len(name)) + tdSql.error("create table %s using %s tags(0)" % (name, sname)) + + # create a child table with name of max length + name = self.generateString(maxTableNameLen) + tdLog.info("create a child table with length %d" % len(name)) + tdSql.execute("create table %s using %s tags(0)" % (name, sname)) + tdSql.query('show tables') + tdSql.checkRows(1) + + # insert one row + tdLog.info("insert one row of data") + tdSql.execute("insert into %s values(now, 0)" % name) + tdSql.query("select * from " + name) + tdSql.checkRows(1) + tdSql.query("select * from " + sname) + tdSql.checkRows(1) + + name = name[:len(name) - 1] + tdSql.error("select * from " + name) + tdSql.checkRows(0) + + def checkRowBoundaries(self): + tdLog.debug("checking row boundaries") tdSql.prepare() # 8 bytes for timestamp maxRowSize = 65536 - 8 - maxCols = self.getLimitFromSourceCode( 'TSDB_MAX_COLUMNS' ) - 1 + maxCols = self.getLimitFromSourceCode('TSDB_MAX_COLUMNS') - 1 # for binary cols, 2 bytes are used for length colLen = (maxRowSize - maxCols * 2) // maxCols firstColLen = maxRowSize - 2 * maxCols - colLen * (maxCols - 1) sql = "create table cars (ts timestamp, c0 binary(%d)" % firstColLen - for i in range( 1, maxCols ): + for i in range(1, maxCols): sql += ", c%d binary(%d)" % (i, colLen) sql += ");" - tdSql.execute( sql ) - tdSql.query( 'show tables' ) - tdSql.checkRows( 1 ) + tdSql.execute(sql) + tdSql.query('show tables') + tdSql.checkRows(1) - col = self.generateString( firstColLen ) + col = self.generateString(firstColLen) sql = "insert into cars values (now, '%s'" % col - col = self.generateString( colLen ) - for i in range( 1, maxCols ): - sql += ", '%s'" % col + col = self.generateString(colLen) + for i in range(1, maxCols): + sql += ", '%s'" % col sql += ");" - tdLog.info( sql ); - tdSql.execute( sql ) - tdSql.query( "select * from cars" ) - tdSql.checkRows( 1 ) - + tdLog.info(sql) + tdSql.execute(sql) + tdSql.query("select * from cars") + tdSql.checkRows(1) def run(self): self.checkTagBoundaries() @@ -151,7 +169,6 @@ class TDTestCase: self.checkTableNameBoundaries() self.checkRowBoundaries() - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/table/column_name.py b/tests/pytest/table/column_name.py index aa958fd60c98dc86f031f6980ca476802e5ff805..a180d3f752f36626c1c55adade24584a208dbe8d 100644 --- a/tests/pytest/table/column_name.py +++ b/tests/pytest/table/column_name.py @@ -10,9 +10,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/column_num.py b/tests/pytest/table/column_num.py index 877f0409dc4fa3d723606b62fc939c76809ef054..3abedb083c8b68c3f3f06b094e06a3d9c686b82e 100644 --- a/tests/pytest/table/column_num.py +++ b/tests/pytest/table/column_num.py @@ -8,9 +8,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/create-a-lot.py b/tests/pytest/table/create-a-lot.py new file mode 100644 index 0000000000000000000000000000000000000000..7db4a8eacac9ede3d47e14bee1a4fc901c0ab270 --- /dev/null +++ b/tests/pytest/table/create-a-lot.py @@ -0,0 +1,45 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + print("prepare data") + + for x in range(0, 1000000): + tb_name = "tb%d" % x + tdLog.info("create table %s (ts timestamp, i int)" % tb_name) + tdSql.execute("create table %s (ts timestamp, i int)" % tb_name) + tdLog.info("insert into %s values(now, 1)" % tb_name) + tdSql.execute("insert into %s values(now, 1)" % tb_name) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/create.py b/tests/pytest/table/create.py index b456b444f4b361784b2bb157e453bf5ae1e57c85..8fedd4e92046f58a94db66a1e696edfe5d253982 100644 --- a/tests/pytest/table/create.py +++ b/tests/pytest/table/create.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/db_table.py b/tests/pytest/table/db_table.py index d4a8568375c0d467c195af924058c70c8bbc2ab7..5ead829e26e8e6a64fdb28af6ad34499663df7b2 100644 --- a/tests/pytest/table/db_table.py +++ b/tests/pytest/table/db_table.py @@ -7,9 +7,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/del_stable.py b/tests/pytest/table/del_stable.py index 3932f325362457dbd98838863eafddd94716f2f3..e7fd0f1fb124f60a9bb63d67423ecec5ec358f87 100644 --- a/tests/pytest/table/del_stable.py +++ b/tests/pytest/table/del_stable.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/table/tablename-boundary.py b/tests/pytest/table/tablename-boundary.py index 335073065c5a5b6af82469c967bac1df623d5e5a..ce843c3fe70d0ecd3438c746c5f5b5af273e4e77 100644 --- a/tests/pytest/table/tablename-boundary.py +++ b/tests/pytest/table/tablename-boundary.py @@ -10,9 +10,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/tag_lite/3.py b/tests/pytest/tag_lite/3.py new file mode 100644 index 0000000000000000000000000000000000000000..68d2e6c5baf3a26539e4b97552ef8bcda06cd977 --- /dev/null +++ b/tests/pytest/tag_lite/3.py @@ -0,0 +1,1332 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + dbPrefix = "ta_3_db" + tbPrefix = "ta_3_tb" + mtPrefix = "ta_3_mt" + tbNum = 10 + rowNum = 20 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + i = 0 + db = "%s%d" % (dbPrefix, i) + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, + # tgcol2 int, tgcol3 float) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float)" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float)' % + mt) + # TSIM: + i = 0 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 0, 0, 0 ) + tdLog.info("create table %s using %s tags( 0, 0, 0 )" % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0 )' % + (tb, mt)) + + x = 0 + while (x < rowNum): + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + x = x + 1 + #TSIM: endw + i = i + 1 + #TSIM: endw + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 1, 1, 1 ) + tdLog.info("create table %s using %s tags( 1, 1, 1 )" % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = "%dm" % x + tdLog.info( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + x = x + 1 + #TSIM: endw + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from %s + tdLog.info('select * from %s' % mt) + tdSql.query('select * from %s' % mt) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow(%d)' % totalNum) + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from %s where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % mt) + tdSql.query('select * from %s where ts < now + 4m' % mt) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % mt) + tdSql.query('select * from %s where ts > now + 4m' % mt) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % mt) + tdSql.query('select * from %s where ts = now + 4m' % mt) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + mt) + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = true + tdLog.info('select * from %s where tgcol1 = true' % mt) + tdSql.query('select * from %s where tgcol1 = true' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> true + tdLog.info('select * from %s where tgcol1 <> true' % mt) + tdSql.query('select * from %s where tgcol1 <> true' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = false + tdLog.info('select * from %s where tgcol1 = false' % mt) + tdSql.query('select * from %s where tgcol1 = false' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> false + tdLog.info('select * from %s where tgcol1 <> false' % mt) + tdSql.query('select * from %s where tgcol1 <> false' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from %s where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % mt) + tdSql.query('select * from %s where tgcol2 = 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % mt) + tdSql.query('select * from %s where tgcol2 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % mt) + tdSql.query('select * from %s where tgcol2 = 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % mt) + tdSql.query('select * from %s where tgcol2 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from %s where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % mt) + tdSql.query('select * from %s where tgcol3 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % mt) + tdSql.query('select * from %s where tgcol3 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % mt) + tdSql.query('select * from %s where tgcol3 = 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % mt) + tdSql.query('select * from %s where tgcol3 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = true' % + mt) + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> true' % + mt) + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> false + # and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> false and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> false and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol2 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol2 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol2 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol2 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol2 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol2 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol2 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol3 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol3 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol3 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol3 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol3 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol3 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol3 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 = 1 and + # tgcol1 = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 1 and + # tgcol1 <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 and + # tgcol1 = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol1 = true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 and + # tgcol1 <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true + # group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true and tgcol2 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/4.py b/tests/pytest/tag_lite/4.py new file mode 100644 index 0000000000000000000000000000000000000000..66641f9dfea430ea7a48715e70939bd57fa932d2 --- /dev/null +++ b/tests/pytest/tag_lite/4.py @@ -0,0 +1,1877 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + dbPrefix = "ta_4_db" + tbPrefix = "ta_4_tb" + mtPrefix = "ta_4_mt" + tbNum = 10 + rowNum = 20 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + i = 0 + db = "%s%d" % (dbPrefix, i) + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table %s (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double)" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double)' % + mt) + # TSIM: + i = 0 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 0, 0, 0, 0 ) + tdLog.info( + "create table %s using %s tags( 0, 0, 0, 0 )" % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0, 0 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + x = x + 1 + #TSIM: endw + i = i + 1 + #TSIM: endw + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 1, 1, 1, 1 ) + tdLog.info( + "create table %s using %s tags( 1, 1, 1, 1 )" % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1, 1 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d)" % + (tb, ms, x)) + x = x + 1 + #TSIM: endw + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from %s + tdLog.info('select * from %s' % mt) + tdSql.query('select * from %s' % mt) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from %s where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % mt) + tdSql.query('select * from %s where ts < now + 4m' % mt) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % mt) + tdSql.query('select * from %s where ts > now + 4m' % mt) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % mt) + tdSql.query('select * from %s where ts = now + 4m' % mt) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + mt) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from %s where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % mt) + tdSql.query('select * from %s where tgcol2 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % mt) + tdSql.query('select * from %s where tgcol2 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % mt) + tdSql.query('select * from %s where tgcol2 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % mt) + tdSql.query('select * from %s where tgcol2 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from %s where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % mt) + tdSql.query('select * from %s where tgcol3 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % mt) + tdSql.query('select * from %s where tgcol3 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % mt) + tdSql.query('select * from %s where tgcol3 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % mt) + tdSql.query('select * from %s where tgcol3 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from %s where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % mt) + tdSql.query('select * from %s where tgcol4 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % mt) + tdSql.query('select * from %s where tgcol4 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % mt) + tdSql.query('select * from %s where tgcol4 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % mt) + tdSql.query('select * from %s where tgcol4 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol1 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol1 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol1 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol1 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol1 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol1 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol1 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol2 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol2 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol2 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol2 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol2 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol2 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol2 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol3 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol3 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol3 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol3 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol3 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol3 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol3 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol4 = 1' % mt) + tdSql.query('select * from %s where ts > now + 4m and tgcol4 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol4 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol4 = 0' % mt) + tdSql.query('select * from %s where ts < now + 4m and tgcol4 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 <> 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol4 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 = 0 + tdLog.info('select * from %s where ts <= now + 4m and tgcol4 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol2 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol3 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol1 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from %s where ts > now + 4m and tgcol4 <> 0 and ts + # < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/5.py b/tests/pytest/tag_lite/5.py new file mode 100644 index 0000000000000000000000000000000000000000..6e94e692cd6db96e271deb4902908a001235d8cd --- /dev/null +++ b/tests/pytest/tag_lite/5.py @@ -0,0 +1,2306 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_5_db + # TSIM: $tbPrefix = ta_5_tb + tbPrefix = "ta_5_tb" + # TSIM: $mtPrefix = ta_5_mt + mtPrefix = "ta_5_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + tdLog.info( + 'create table %s using %s tags( 0, 0, 0, 0, 0 )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0, 0, 0 )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s, %d)' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s, %d)' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + tdLog.info( + 'create table %s using %s tags( 1, 1, 1, 1, 1 )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1, 1, 1 )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s, %d)' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s, %d)' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % (mt)) + tdSql.query('select * from %s where tgcol3 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % (mt)) + tdSql.query('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % (mt)) + tdSql.query('select * from %s where tgcol4 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where tgcol5 = 0 + tdLog.info('select * from %s where tgcol5 = 0' % (mt)) + tdSql.query('select * from %s where tgcol5 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 0 + tdLog.info('select * from %s where tgcol5 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 1 + tdLog.info('select * from %s where tgcol5 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol5 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by + # tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/6.py b/tests/pytest/tag_lite/6.py new file mode 100644 index 0000000000000000000000000000000000000000..52f6fe1b3764f1bee4da38c8616445cfc8d0f465 --- /dev/null +++ b/tests/pytest/tag_lite/6.py @@ -0,0 +1,2754 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_6_db + # TSIM: $tbPrefix = ta_6_tb + tbPrefix = "ta_6_tb" + # TSIM: $mtPrefix = ta_6_mt + mtPrefix = "ta_6_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 + # binary(30), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' + # ) + tdLog.info( + 'create table %s using %s tags( "0", 0, 0, 0, "0", "0" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "0", 0, 0, 0, "0", "0" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' + # ) + tdLog.info( + 'create table %s using %s tags( "1", 1, 1, 1, "1", "1" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 1, 1, 1, "1", "1" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % (mt)) + tdSql.query('select * from %s where tgcol3 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % (mt)) + tdSql.query('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % (mt)) + tdSql.query('select * from %s where tgcol4 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where tgcol5 = 0 + tdLog.info('select * from %s where tgcol5 = 0' % (mt)) + tdSql.query('select * from %s where tgcol5 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 0 + tdLog.info('select * from %s where tgcol5 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 1 + tdLog.info('select * from %s where tgcol5 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from $mt where tgcol6 = 0 + tdLog.info('select * from %s where tgcol6 = 0' % (mt)) + tdSql.query('select * from %s where tgcol6 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 <> 0 + tdLog.info('select * from %s where tgcol6 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol6 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = 1 + tdLog.info('select * from %s where tgcol6 = 1' % (mt)) + tdSql.query('select * from %s where tgcol6 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 <> 1 + tdLog.info('select * from %s where tgcol6 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol6 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol6 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol6 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol6 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol5 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 = 1 and + # tgcol6 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and + # tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 = 0 and + # tgcol6 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and + # tgcol6 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = + # 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and + # tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = + # 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = + # 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 and tgcol6 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step28 + tdLog.info('=============== step28') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol6' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol6' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step29 + tdLog.info('=============== step29') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by + # tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step30 + tdLog.info('=============== step30') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 and tgcol6 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step31 + tdLog.info('=============== step31') + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: 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 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/add.py b/tests/pytest/tag_lite/add.py new file mode 100644 index 0000000000000000000000000000000000000000..e9e3675485d6b25e302e13beb6579ee0c24e64f1 --- /dev/null +++ b/tests/pytest/tag_lite/add.py @@ -0,0 +1,1767 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ad_db + # TSIM: $tbPrefix = ta_ad_tb + tbPrefix = "ta_ad_tb" + # TSIM: $mtPrefix = ta_ad_mt + mtPrefix = "ta_ad_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4 =4 + tdLog.info('alter table %s set tag tgcol4 =4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4 =4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 tinyint + tdLog.info('alter table %s add tag tgcol4 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 tinyint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, 1)') + tdSql.checkData(2, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data33 != 2.000000 then + tdLog.info('tdSql.checkData(3, 3, 2.000000)') + tdSql.checkData(3, 3, 2.000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 float + tdLog.info('alter table %s add tag tgcol4 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 float' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 smallint + tdLog.info('alter table %s add tag tgcol4 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 smallint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = '1' -x step5 + tdLog.info('select * from %s where tgcol3 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol3 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(10) + tdLog.info('alter table %s add tag tgcol5 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=false + tdLog.info('alter table %s set tag tgcol4=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 tinyint + tdLog.info('alter table %s add tag tgcol6 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 tinyint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(17) + tdLog.info('alter table %s add tag tgcol5 binary(17)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(17)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bool + tdLog.info('alter table %s add tag tgcol6 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bool' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print select * from $mt where tgcol5 = 5 + tdLog.info('select * from $mt where tgcol5 = 5') + # TSIM: print $data01 $data02 $data03 $data04 + tdLog.info('$data01 $data02 $data03 $data04') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 float + tdLog.info('alter table %s add tag tgcol6 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 float' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=1 + tdLog.info('alter table %s set tag tgcol5=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=1' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step103 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step103' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol403' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=false + tdLog.info('alter table %s set tag tgcol5=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=false' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 101' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 102' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step114 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step114' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol414' % (mt)) + # TSIM: return -1 + # TSIM: step114: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 int + tdLog.info('alter table %s add tag tgcol5 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 smallint + tdLog.info('alter table %s add tag tgcol8 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol8 smallint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql alter table $tb set tag tgcol7=7 + tdLog.info('alter table %s set tag tgcol7=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol7=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol8=8 + tdLog.info('alter table %s set tag tgcol8=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol8=8' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, 6)') + tdSql.checkData(0, 5, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 111' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 112' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol9 = 1 -x step113 + tdLog.info('select * from %s where tgcol9 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol9 = 113' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol3 int + tdLog.info('alter table %s add tag tgcol3 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=5 + tdLog.info('alter table %s set tag tgcol2=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=4 + tdLog.info('alter table %s set tag tgcol3=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=3 + tdLog.info('alter table %s set tag tgcol4=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=2 + tdLog.info('alter table %s set tag tgcol5=2' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=2' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, 3)') + tdSql.checkData(0, 6, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=7 + tdLog.info('alter table %s set tag tgcol1=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=9 + tdLog.info('alter table %s set tag tgcol3=9' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=9' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=10 + tdLog.info('alter table %s set tag tgcol4=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=11 + tdLog.info('alter table %s set tag tgcol5=11' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=11' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=12 + tdLog.info('alter table %s set tag tgcol6=12' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=12' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, 8)') + tdSql.checkData(0, 5, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: + # TSIM: sql alter table $mt add tag tgcol3 binary(10) + tdLog.info('alter table %s add tag tgcol3 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: return + # TSIM: sql alter table $mt add tag tgcol7 bigint -x step141 + tdLog.info('alter table %s add tag tgcol7 bigint -x step141' % (mt)) + tdSql.error('alter table %s add tag tgcol7 bigint41' % (mt)) + # TSIM: return -1 + # TSIM: step141: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 bigint -x step142 + tdLog.info('alter table %s add tag tgcol8 bigint -x step142' % (mt)) + tdSql.error('alter table %s add tag tgcol8 bigint42' % (mt)) + # TSIM: return -1 + # TSIM: step142: + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('sql drop database $db') + tdSql.execute('sql drop database $db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bigint.py b/tests/pytest/tag_lite/bigint.py new file mode 100644 index 0000000000000000000000000000000000000000..77a161c5bc7bf77e14a2f28197dca8729ee79c15 --- /dev/null +++ b/tests/pytest/tag_lite/bigint.py @@ -0,0 +1,584 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bi_db + # TSIM: $tbPrefix = ta_bi_tb + tbPrefix = "ta_bi_tb" + # TSIM: $mtPrefix = ta_bi_mt + mtPrefix = "ta_bi_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/binary.py b/tests/pytest/tag_lite/binary.py new file mode 100644 index 0000000000000000000000000000000000000000..543b00b34e9d760502a1095e102d8afa96b14e63 --- /dev/null +++ b/tests/pytest/tag_lite/binary.py @@ -0,0 +1,588 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_by_db + # TSIM: $tbPrefix = ta_by_tb + tbPrefix = "ta_by_tb" + # TSIM: $mtPrefix = ta_by_mt + mtPrefix = "ta_by_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0' ) + tdLog.info('create table %s using %s tags( "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1' ) + tdLog.info('create table %s using %s tags( "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '0' and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> "0" and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> "0" and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/binary_binary.py b/tests/pytest/tag_lite/binary_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..c0d1c0bfe7ad6d460d33fb7f6b8cbd30c05af2dc --- /dev/null +++ b/tests/pytest/tag_lite/binary_binary.py @@ -0,0 +1,799 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bib_db + # TSIM: $tbPrefix = ta_bib_tb + tbPrefix = "ta_bib_tb" + # TSIM: $mtPrefix = ta_bib_mt + mtPrefix = "ta_bib_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(5), tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0', '0' ) + tdLog.info('create table %s using %s tags( "0", "0" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "0", "0" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1', '1' ) + tdLog.info('create table %s using %s tags( "1", "1" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "1" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '1' + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '0' and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> "0" and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> "0" and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' and + # tgcol = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and + # tgcol <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' and + # tgcol = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and + # tgcol = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + # and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' and tgcol <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m and ts < now + 5m and tgcol <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool.py b/tests/pytest/tag_lite/bool.py new file mode 100644 index 0000000000000000000000000000000000000000..c43d5b2ee5da8b576e079073cbaeabf2d91440e5 --- /dev/null +++ b/tests/pytest/tag_lite/bool.py @@ -0,0 +1,583 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bo_db + # TSIM: $tbPrefix = ta_bo_tb + tbPrefix = "ta_bo_tb" + # TSIM: $mtPrefix = ta_bo_mt + mtPrefix = "ta_bo_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: print expect 100, actual:$rows + tdLog.info('expect 100, actual:$rows') + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false + # and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol') + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool_binary.py b/tests/pytest/tag_lite/bool_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..7105cc4e7874802e108c2a1cf6416773048cf9bb --- /dev/null +++ b/tests/pytest/tag_lite/bool_binary.py @@ -0,0 +1,793 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bob_db + # TSIM: $tbPrefix = ta_bob_tb + tbPrefix = "ta_bob_tb" + # TSIM: $mtPrefix = ta_bob_mt + mtPrefix = "ta_bob_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, '1' ) + tdLog.info('create table %s using %s tags( 1, "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> "1" + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false + # and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' and + # tgcol = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and + # tgcol <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' and + # tgcol = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and + # tgcol <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and + # tgcol = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + # and tgcol <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' and tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m and ts < now + 5m and tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool_int.py b/tests/pytest/tag_lite/bool_int.py new file mode 100644 index 0000000000000000000000000000000000000000..b7504b1127edd27c36394aa92d329393dd003065 --- /dev/null +++ b/tests/pytest/tag_lite/bool_int.py @@ -0,0 +1,825 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_boi_db + # TSIM: $tbPrefix = ta_boi_tb + tbPrefix = "ta_boi_tb" + # TSIM: $mtPrefix = ta_boi_mt + mtPrefix = "ta_boi_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0 ) + tdLog.info('create table %s using %s tags( 0, 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = true + tdLog.info('select * from %s where tgcol2 = true' % (mt)) + tdSql.query('select * from %s where tgcol2 = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> true + tdLog.info('select * from %s where tgcol2 <> true' % (mt)) + tdSql.query('select * from %s where tgcol2 <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = false + tdLog.info('select * from %s where tgcol2 = false' % (mt)) + tdSql.query('select * from %s where tgcol2 = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> false + tdLog.info('select * from %s where tgcol2 <> false' % (mt)) + tdSql.query('select * from %s where tgcol2 <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false + # and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 and + # tgcol = true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and + # tgcol <> true + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 and + # tgcol = false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and + # tgcol = false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol <> false + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = 1 group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/change.py b/tests/pytest/tag_lite/change.py new file mode 100644 index 0000000000000000000000000000000000000000..e1df901d5b98b0619ceb55b04888845b89d41a3a --- /dev/null +++ b/tests/pytest/tag_lite/change.py @@ -0,0 +1,874 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ch_db + # TSIM: $tbPrefix = ta_ch_tb + # TSIM: $mtPrefix = ta_ch_mt + # TSIM: $tbNum = 10 + # TSIM: $rowNum = 20 + # TSIM: $totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + "create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)") + tdSql.execute( + 'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb2 using $mt tags( 1, 2 )") + tdSql.execute('create table tb2 using $mt tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb2 values(now, 1)") + tdSql.execute("insert into tb2 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from $mt where tgcol1 = 1') + tdSql.query('select * from $mt where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tagcx tgcol3 -x step21 + # TSIM: return -1 + # TSIM: step21: + # TSIM: sql alter table $mt change tag tgcol1 tgcol2 -x step22 + # TSIM: return -1 + # TSIM: step22: + # TSIM: sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 + # TSIM: return -1 + # TSIM: step20: + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + # TSIM: sql alter table $mt change tag tgcol4 tgcol3 -x step23 + # TSIM: return -1 + # TSIM: step23: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + "create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)") + tdSql.execute( + 'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb3 using $mt tags( 1, 2 )") + tdSql.execute('create table tb3 using $mt tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb3 values(now, 1)") + tdSql.execute("insert into tb3 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from $mt where tgcol1 = 1') + tdSql.query('select * from $mt where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + "create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)") + tdSql.execute( + 'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb4 using $mt tags( 1, 2 )") + tdSql.execute('create table tb4 using $mt tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb4 values(now, 1)") + tdSql.execute("insert into tb4 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from $mt where tgcol1 = 1') + tdSql.query('select * from $mt where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + "create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))") + tdSql.execute( + 'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))') + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info("create table tb5 using $mt tags( 1, '2' )") + tdSql.execute('create table tb5 using $mt tags( 1, '2' )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb5 values(now, 1)") + tdSql.execute("insert into tb5 values(now, 1)") + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from $mt where tgcol2 = '2'') + tdSql.query('select * from $mt where tgcol2 = '2'') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info("create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))") + tdSql.execute( + 'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))') + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info("create table tb6 using $mt tags( '1', 2, 3, '4', 5, '6' )") + tdSql.execute('create table tb6 using $mt tags( '1', 2, 3, '4', 5, '6' )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb6 values(now, 1)") + tdSql.execute("insert into tb6 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from $mt where tgcol1 = '1'') + tdSql.query('select * from $mt where tgcol1 = '1'') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + # TSIM: sql reset query cache + # TSIM: sql alter table $mt change tag tgcol4 tgcol3 + # TSIM: sql alter table $mt change tag tgcol1 tgcol7 + # TSIM: sql alter table $mt change tag tgcol2 tgcol8 + # TSIM: sql reset query cache + # TSIM: sql alter table $mt change tag tgcol3 tgcol9 + # TSIM: sql alter table $mt change tag tgcol5 tgcol10 + # TSIM: sql alter table $mt change tag tgcol6 tgcol11 + # TSIM: + # TSIM: sleep 5000 + # TSIM: sql reset query cache + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step24 + tdLog.info('select * from $mt where tgcol1 = 1 -x step24') + tdSql.error('select * from $mt where tgcol1 = 14') + # TSIM: return -1 + # TSIM: step24: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step25 + tdLog.info('select * from $mt where tgcol2 = 1 -x step25') + tdSql.error('select * from $mt where tgcol2 = 15') + # TSIM: return -1 + # TSIM: step25: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from $mt where tgcol3 = 1') + tdSql.query('select * from $mt where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from $mt where tgcol4 = 2') + tdSql.query('select * from $mt where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step31 + tdLog.info('select * from $mt where tgcol1 = 1 -x step31') + tdSql.error('select * from $mt where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step31: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step32 + tdLog.info('select * from $mt where tgcol2 = 1 -x step32') + tdSql.error('select * from $mt where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step32: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from $mt where tgcol3 = 1') + tdSql.query('select * from $mt where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from $mt where tgcol4 = 2') + tdSql.query('select * from $mt where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step41 + tdLog.info('select * from $mt where tgcol1 = 1 -x step41') + tdSql.error('select * from $mt where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step41: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step42 + tdLog.info('select * from $mt where tgcol2 = 1 -x step42') + tdSql.error('select * from $mt where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step42: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from $mt where tgcol3 = 1') + tdSql.query('select * from $mt where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from $mt where tgcol4 = 2') + tdSql.query('select * from $mt where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step51 + tdLog.info('select * from $mt where tgcol1 = 1 -x step51') + tdSql.error('select * from $mt where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step51: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step52 + tdLog.info('select * from $mt where tgcol2 = 1 -x step52') + tdSql.error('select * from $mt where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from $mt where tgcol3 = 1') + tdSql.query('select * from $mt where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '2' + tdLog.info('select * from $mt where tgcol4 = '2'') + tdSql.query('select * from $mt where tgcol4 = '2'') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step61 + tdLog.info('select * from $mt where tgcol1 = 1 -x step61') + tdSql.error('select * from $mt where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step61: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step62 + tdLog.info('select * from $mt where tgcol2 = 1 -x step62') + tdSql.error('select * from $mt where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step62: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step63 + tdLog.info('select * from $mt where tgcol3 = 1 -x step63') + tdSql.error('select * from $mt where tgcol3 = 13') + # TSIM: return -1 + # TSIM: step63: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step64 + tdLog.info('select * from $mt where tgcol4 = 1 -x step64') + tdSql.error('select * from $mt where tgcol4 = 14') + # TSIM: return -1 + # TSIM: step64: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step65 + tdLog.info('select * from $mt where tgcol5 = 1 -x step65') + tdSql.error('select * from $mt where tgcol5 = 15') + # TSIM: return -1 + # TSIM: step65: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step66 + tdLog.info('select * from $mt where tgcol6 = 1 -x step66') + tdSql.error('select * from $mt where tgcol6 = 16') + # TSIM: return -1 + # TSIM: step66: + # TSIM: + # TSIM: sql select * from $mt where tgcol7 = '1' + tdLog.info('select * from $mt where tgcol7 = '1'') + tdSql.query('select * from $mt where tgcol7 = '1'') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, 4)') + tdSql.checkData(0, 4, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, 6)') + tdSql.checkData(0, 6, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol8 = 2 + tdLog.info('select * from $mt where tgcol8 = 2') + tdSql.query('select * from $mt where tgcol8 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, 4)') + tdSql.checkData(0, 4, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, 6)') + tdSql.checkData(0, 6, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol9 = '4' + tdLog.info('select * from $mt where tgcol9 = '4'') + tdSql.query('select * from $mt where tgcol9 = '4'') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, 4)') + tdSql.checkData(0, 4, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, 6)') + tdSql.checkData(0, 6, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol10 = 5 + tdLog.info('select * from $mt where tgcol10 = 5') + tdSql.query('select * from $mt where tgcol10 = 5') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, 4)') + tdSql.checkData(0, 4, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, 6)') + tdSql.checkData(0, 6, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol11 = '6' + tdLog.info('select * from $mt where tgcol11 = '6'') + tdSql.query('select * from $mt where tgcol11 = '6'') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, 4)') + tdSql.checkData(0, 4, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, 6)') + tdSql.checkData(0, 6, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/column.py b/tests/pytest/tag_lite/column.py new file mode 100644 index 0000000000000000000000000000000000000000..4669f7449815b30ecc71b2367e259dc1b052547a --- /dev/null +++ b/tests/pytest/tag_lite/column.py @@ -0,0 +1,197 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_co_db + # TSIM: $tbPrefix = ta_co_tb + tbPrefix = "ta_co_tb" + # TSIM: $mtPrefix = ta_co_mt + mtPrefix = "ta_co_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: sql create table $mt (ts timestamp, tbcol int, tbcol2 + # binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' % + (mt)) + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: + # TSIM: $i = 1 + i = 1 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: + # TSIM: $i = 2 + i = 2 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '2', '2' ) + tdLog.info('create table %s using %s tags( "2", "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "2", "2" )' % (tb, mt)) + # TSIM: + # TSIM: $i = 3 + i = 3 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '3', 3 ) + tdLog.info('create table %s using %s tags( "3", 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "3", 3 )' % (tb, mt)) + # TSIM: + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 4 then + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, 0, '0') + tdLog.info('insert into %s values(now, 0, "0")' % (tb)) + tdSql.execute('insert into %s values(now, 0, "0")' % (tb)) + # TSIM: + # TSIM: $i = 1 + i = 1 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, 1, 1 ) + tdLog.info('insert into %s values(now, 1, 1 )' % (tb)) + tdSql.execute('insert into %s values(now, 1, 1 )' % (tb)) + # TSIM: + # TSIM: $i = 2 + i = 2 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, '2', '2') + tdLog.info('insert into %s values(now, "2", "2")' % (tb)) + tdSql.execute('insert into %s values(now, "2", "2")' % (tb)) + # TSIM: + # TSIM: $i = 3 + i = 3 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, '3', 3) + tdLog.info('insert into %s values(now, "3", 3)' % (tb)) + tdSql.execute('insert into %s values(now, "3", 3)' % (tb)) + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != 4 then + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/commit.py b/tests/pytest/tag_lite/commit.py new file mode 100644 index 0000000000000000000000000000000000000000..4ad2ecf8f9ec8db219c4275e29326768d0de79c1 --- /dev/null +++ b/tests/pytest/tag_lite/commit.py @@ -0,0 +1,2313 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = db + # TSIM: $tbPrefix = tb + tbPrefix = "tb" + # TSIM: $mtPrefix = mt + mtPrefix = "mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4 =4 + tdLog.info('alter table %s set tag tgcol4 =4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4 =4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 tinyint + tdLog.info('alter table %s add tag tgcol4 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 tinyint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, 1)') + tdSql.checkData(2, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data33 != 2.000000 then + tdLog.info('tdSql.checkData(3, 3, 2.000000)') + tdSql.checkData(3, 3, 2.000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 float + tdLog.info('alter table %s add tag tgcol4 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 float' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 smallint + tdLog.info('alter table %s add tag tgcol4 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 smallint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = '1' -x step5 + tdLog.info('select * from %s where tgcol3 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol3 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(10) + tdLog.info('alter table %s add tag tgcol5 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=false + tdLog.info('alter table %s set tag tgcol4=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 tinyint + tdLog.info('alter table %s add tag tgcol6 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 tinyint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(17) + tdLog.info('alter table %s add tag tgcol5 binary(17)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(17)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bool + tdLog.info('alter table %s add tag tgcol6 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bool' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 float + tdLog.info('alter table %s add tag tgcol6 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 float' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=1 + tdLog.info('alter table %s set tag tgcol5=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=1' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step103 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step103' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol403' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=false + tdLog.info('alter table %s set tag tgcol5=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=false' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 101' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 102' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step114 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step114' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol414' % (mt)) + # TSIM: return -1 + # TSIM: step114: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 int + tdLog.info('alter table %s add tag tgcol5 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 smallint + tdLog.info('alter table %s add tag tgcol8 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol8 smallint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql alter table $tb set tag tgcol7=7 + tdLog.info('alter table %s set tag tgcol7=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol7=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol8=8 + tdLog.info('alter table %s set tag tgcol8=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol8=8' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, 6)') + tdSql.checkData(0, 5, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 111' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 112' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol9 = 1 -x step113 + tdLog.info('select * from %s where tgcol9 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol9 = 113' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol3 int + tdLog.info('alter table %s add tag tgcol3 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=5 + tdLog.info('alter table %s set tag tgcol2=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=4 + tdLog.info('alter table %s set tag tgcol3=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=3 + tdLog.info('alter table %s set tag tgcol4=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=2 + tdLog.info('alter table %s set tag tgcol5=2' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=2' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, 3)') + tdSql.checkData(0, 6, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=7 + tdLog.info('alter table %s set tag tgcol1=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=9 + tdLog.info('alter table %s set tag tgcol3=9' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=9' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=10 + tdLog.info('alter table %s set tag tgcol4=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=11 + tdLog.info('alter table %s set tag tgcol5=11' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=11' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=12 + tdLog.info('alter table %s set tag tgcol6=12' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=12' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, 8)') + tdSql.checkData(0, 5, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT + # TSIM: sleep 5000 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: sleep 3000 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, 6)') + tdSql.checkData(0, 5, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, 3)') + tdSql.checkData(0, 6, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, 8)') + tdSql.checkData(0, 5, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('sql drop database $db') + tdSql.execute('sql drop database $db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/create-tags-boundary.py b/tests/pytest/tag_lite/create-tags-boundary.py index e80f458f0ccdd7d564143058bfd9b059a93877e9..b98ae627c2999e96d233dd63ba8c1ce795531265 100644 --- a/tests/pytest/tag_lite/create-tags-boundary.py +++ b/tests/pytest/tag_lite/create-tags-boundary.py @@ -19,9 +19,9 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() diff --git a/tests/pytest/tag_lite/create.py b/tests/pytest/tag_lite/create.py new file mode 100644 index 0000000000000000000000000000000000000000..39a2d83a31cfab8565f6c36e87623e85204aa077 --- /dev/null +++ b/tests/pytest/tag_lite/create.py @@ -0,0 +1,1398 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_cr_db + # TSIM: $tbPrefix = ta_cr_tb + tbPrefix = "ta_cr_tb" + # TSIM: $mtPrefix = ta_cr_mt + mtPrefix = "ta_cr_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: print expect 0, actual: $rows + tdLog.info('expect 0, actual: $rows') + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1') + tdLog.info('create table %s using %s tags( "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: print expect 1, actual: $rows + tdLog.info('expect 1, actual: $rows') + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: $i = 15 + i = 15 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: $i = 16 + i = 16 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: $i = 17 + i = 17 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: $i = 18 + i = 18 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: $i = 19 + i = 19 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: $i = 20 + i = 20 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: $i = 21 + i = 21 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: $i = 22 + i = 22 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float, tgcol2 double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: $i = 23 + i = 23 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: $i = 24 + i = 24 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 3 + tdLog.info('select * from %s where tgcol3 = 3' % (mt)) + tdSql.query('select * from %s where tgcol3 = 3' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 5 + tdLog.info('select * from %s where tgcol5 = 5' % (mt)) + tdSql.query('select * from %s where tgcol5 = 5' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '0' + tdLog.info('select * from %s where tgcol6 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: $i = 25 + i = 25 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '0' + tdLog.info('select * from %s where tgcol6 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: $i = 26 + i = 26 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), + # tgcol5 binary(10), tgcol6 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4', '5', + # '6' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4", "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4", "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = '0' + tdLog.info('select * from %s where tgcol3 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: $i = 27 + i = 27 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 + # binary(10), tgcol7) -x step27 + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27' % + (mt)) + tdSql.error( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7)7' % + (mt)) + # TSIM: return -1 + # TSIM: step27: + # TSIM: + # TSIM: print =============== step28 + tdLog.info('=============== step28') + # TSIM: $i = 28 + i = 28 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(250), tgcol2 binary(250)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250))' % + (mt)) + # TSIM: sql create table $tb using $mt tags('1', '1') + tdLog.info('create table %s using %s tags("1", "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("1", "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step29 + tdLog.info('=============== step29') + # TSIM: $i = 29 + i = 29 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(25), tgcol2 binary(250)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250))' % + (mt)) + # TSIM: sql create table $tb using $mt tags('1', '1') + tdLog.info('create table %s using %s tags("1", "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("1", "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step30 + tdLog.info('=============== step30') + # TSIM: $i = 30 + i = 30 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30' % + (mt)) + tdSql.error( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30))0' % + (mt)) + # TSIM: return -1 + # TSIM: step30: + # TSIM: + # TSIM: print =============== step31 + tdLog.info('=============== step31') + # TSIM: $i = 31 + i = 31 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5))' % + (mt)) + # TSIM: sql_error create table $tb using $mt tags('1234567') + tdLog.info('create table %s using %s tags("1234567")' % (tb, mt)) + tdSql.error('create table %s using %s tags("1234567")' % (tb, mt)) + # TSIM: sql create table $tb using $mt tags('12345') + tdLog.info('create table %s using %s tags("12345")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("12345")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: print sql select * from $mt + tdLog.info('sql select * from $mt') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print $data00 $data01 $data02 + tdLog.info('$data00 $data01 $data02') + # TSIM: if $data02 != 12345 then + tdLog.info('tdSql.checkData(0, 2, "12345")') + tdSql.checkData(0, 2, "12345") + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/datatype-without-alter.py b/tests/pytest/tag_lite/datatype-without-alter.py index 1a8d05d648a4c0fe7bb28458f15bd4e996ad946c..42bc42bdbf61cc3f88d83b5da04883742ea7ebc6 100644 --- a/tests/pytest/tag_lite/datatype-without-alter.py +++ b/tests/pytest/tag_lite/datatype-without-alter.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 10 diff --git a/tests/pytest/tag_lite/datatype.py b/tests/pytest/tag_lite/datatype.py index 1fcf7ce19eab0409fc28b0eed0222c8d5e3a7f5b..bc99cf74b0be5fc20538c8a1ad0d060854d9cba2 100644 --- a/tests/pytest/tag_lite/datatype.py +++ b/tests/pytest/tag_lite/datatype.py @@ -20,9 +20,9 @@ from util.dnodes import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): self.ntables = 10 diff --git a/tests/pytest/tag_lite/delete.py b/tests/pytest/tag_lite/delete.py new file mode 100644 index 0000000000000000000000000000000000000000..d4a55a4a75b2da33764d700cfd7197b758ee7350 --- /dev/null +++ b/tests/pytest/tag_lite/delete.py @@ -0,0 +1,1597 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_de_db + # TSIM: $tbPrefix = ta_de_tb + tbPrefix = "ta_de_tb" + # TSIM: $mtPrefix = ta_de_mt + mtPrefix = "ta_de_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 < 3 + tdLog.info('select * from %s where tgcol2 < 3' % (mt)) + tdSql.query('select * from %s where tgcol2 < 3' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, 1)') + tdSql.checkData(2, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol1 -x step40 + tdLog.info('alter table %s drop tag tgcol1 -x step40' % (mt)) + tdSql.error('alter table %s drop tag tgcol10' % (mt)) + # TSIM: return -1 + # TSIM: step40: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol1 -x step50 + tdLog.info('alter table %s drop tag tgcol1 -x step50' % (mt)) + tdSql.error('alter table %s drop tag tgcol10' % (mt)) + # TSIM: return -1 + # TSIM: step50: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != SMALLINT then + tdLog.info('tdSql.checkDataType(2, 1, "SMALLINT")') + tdSql.checkDataType(2, 1, "SMALLINT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data31 != TINYINT then + tdLog.info('tdSql.checkDataType(3, 1, "TINYINT")') + tdSql.checkDataType(3, 1, "TINYINT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data41 != BINARY then + tdLog.info('tdSql.checkDataType(4, 1, "BINARY")') + tdSql.checkDataType(4, 1, "BINARY") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data22 != 2 then + tdLog.info('tdSql.checkData(2, 2, 2)') + tdSql.checkData(2, 2, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data32 != 1 then + tdLog.info('tdSql.checkData(3, 2, 1)') + tdSql.checkData(3, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data42 != 10 then + tdLog.info('tdSql.checkData(4, 2, 10)') + tdSql.checkData(4, 2, 10) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, 1)') + tdSql.checkData(2, 3, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data33 != 2 then + tdLog.info('tdSql.checkData(3, 3, 2)') + tdSql.checkData(3, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data43 != 3 then + tdLog.info('tdSql.checkData(4, 3, 3)') + tdSql.checkData(4, 3, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2', '3' ) + tdLog.info('create table %s using %s tags( 1, "2", "3" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, "2", "3" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, 5) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: + # TSIM: sleep 5000 + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '1' -x step5 + tdLog.info('select * from %s where tgcol2 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step51 + tdLog.info('select * from %s where tgcol2 = 1 -x step51' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step51: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + tdSql.checkData(0, 3, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 101' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 102' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step103 + tdLog.info('select * from %s where tgcol4 = 1 -x step103' % (mt)) + tdSql.error('select * from %s where tgcol4 = 103' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4=4 + tdLog.info('select * from %s where tgcol4=4' % (mt)) + tdSql.query('select * from %s where tgcol4=4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL)') + tdSql.checkData(0, 6, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 111' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 112' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step113 + tdLog.info('select * from %s where tgcol5 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol5 = 113' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 3, 4.000000000)') + tdSql.checkData(0, 3, 4.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL)') + tdSql.checkData(0, 4, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL)') + tdSql.checkData(0, 6, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step120 + tdLog.info('select * from %s where tgcol2 = 1 -x step120' % (mt)) + tdSql.error('select * from %s where tgcol2 = 120' % (mt)) + # TSIM: return -1 + # TSIM: step120: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step121 + tdLog.info('select * from %s where tgcol3 = 1 -x step121' % (mt)) + tdSql.error('select * from %s where tgcol3 = 121' % (mt)) + # TSIM: return -1 + # TSIM: step121: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step122 + tdLog.info('select * from %s where tgcol5 = 1 -x step122' % (mt)) + tdSql.error('select * from %s where tgcol5 = 122' % (mt)) + # TSIM: return -1 + # TSIM: step122: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step123 + tdLog.info('select * from %s where tgcol6 = 1 -x step123' % (mt)) + tdSql.error('select * from %s where tgcol6 = 123' % (mt)) + # TSIM: return -1 + # TSIM: step123: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 4, 5.000000000)') + tdSql.checkData(0, 4, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + tdSql.checkData(0, 5, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL)') + tdSql.checkData(0, 6, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step130 + tdLog.info('select * from %s where tgcol3 = 1 -x step130' % (mt)) + tdSql.error('select * from %s where tgcol3 = 130' % (mt)) + # TSIM: return -1 + # TSIM: step130: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step131 + tdLog.info('select * from %s where tgcol4 = 1 -x step131' % (mt)) + tdSql.error('select * from %s where tgcol4 = 131' % (mt)) + # TSIM: return -1 + # TSIM: step131: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step133 + tdLog.info('select * from %s where tgcol6 = 1 -x step133' % (mt)) + tdSql.error('select * from %s where tgcol6 = 133' % (mt)) + # TSIM: return -1 + # TSIM: step133: + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: + # TSIM: sql alter table xxmt drop tag tag1 -x step141 + tdLog.info('alter table xxmt drop tag tag1 -x step141') + tdSql.error('alter table xxmt drop tag tag141') + # TSIM: return -1 + # TSIM: step141: + # TSIM: sql alter table $tb drop tag tag1 -x step142 + tdLog.info('alter table %s drop tag tag1 -x step142' % (tb)) + tdSql.error('alter table %s drop tag tag142' % (tb)) + # TSIM: return -1 + # TSIM: step142: + # TSIM: sql alter table $mt drop tag tag1 -x step143 + tdLog.info('alter table %s drop tag tag1 -x step143' % (mt)) + tdSql.error('alter table %s drop tag tag143' % (mt)) + # TSIM: return -1 + # TSIM: step143: + # TSIM: + # TSIM: sql alter table $mt drop tag tagcol1 -x step144 + tdLog.info('alter table %s drop tag tagcol1 -x step144' % (mt)) + tdSql.error('alter table %s drop tag tagcol144' % (mt)) + # TSIM: return -1 + # TSIM: step144: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol1 -x step145 + tdLog.info('alter table %s drop tag tgcol1 -x step145' % (mt)) + tdSql.error('alter table %s drop tag tgcol145' % (mt)) + # TSIM: return -1 + # TSIM: step145: + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('sql drop database $db') + tdSql.execute('sql drop database $db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/double.py b/tests/pytest/tag_lite/double.py new file mode 100644 index 0000000000000000000000000000000000000000..f70c6871af213e0f78193189af984e7d9b88bbcf --- /dev/null +++ b/tests/pytest/tag_lite/double.py @@ -0,0 +1,584 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_do_db + # TSIM: $tbPrefix = ta_do_tb + tbPrefix = "ta_do_tb" + # TSIM: $mtPrefix = ta_do_mt + mtPrefix = "ta_do_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/filter.py b/tests/pytest/tag_lite/filter.py index 7d160a1b6115b53a1fb0ce53716b6195e9a8fccb..cdba8964ef28360aecde7742dc8e559b3f4e3228 100644 --- a/tests/pytest/tag_lite/filter.py +++ b/tests/pytest/tag_lite/filter.py @@ -18,42 +18,47 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): tdSql.prepare() - #TSIM: system sh/stop_dnodes.sh - #TSIM: system sh/deploy.sh -n dnode1 -i 1 - #TSIM: system sh/exec.sh -n dnode1 -s start - #TSIM: - #TSIM: sleep 3000 - #TSIM: sql connect - #TSIM: - #TSIM: print ======================== dnode1 start + # TSIM: system sh/stop_dnodes.sh + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start tdLog.info('======================== dnode1 start') - #TSIM: + # TSIM: dbPrefix = "ta_fi_db" tbPrefix = "ta_fi_tb" mtPrefix = "ta_fi_mt" - #TSIM: $tbNum = 10 + # TSIM: $tbNum = 10 rowNum = 20 - #TSIM: $totalNum = 200 - #TSIM: - #TSIM: print =============== step1 + # TSIM: $totalNum = 200 + # TSIM: + # TSIM: print =============== step1 tdLog.info('=============== step1') i = 0 - #TSIM: $db = $dbPrefix . $i + # TSIM: $db = $dbPrefix . $i mt = "%s%d" % (mtPrefix, i) - #TSIM: - #TSIM: sql create database $db - #TSIM: sql use $db - #TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) - tdLog.info("create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))" % mt) - tdSql.execute('create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % mt) - #TSIM: + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + mt) + # TSIM: i = 0 while (i < 5): tb = "tbPrefix%d" % i @@ -63,202 +68,299 @@ class TDTestCase: x = 0 while (x < rowNum): ms = "%dm" % x - tdLog.info("insert into %s values (now + %s , %d)" % (tb, ms, x)) - tdSql.execute("insert into %s values (now + %s , %d)" % (tb, ms, x)) + tdLog.info( + "insert into %s values (now + %s , %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s , %d)" % + (tb, ms, x)) x = x + 1 i = i + 1 while (i < 10): - tb = "%s%d" % (tbPrefix , i) - #TSIM: sql create table $tb using $mt tags( '1' ) + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1' ) tdLog.info("create table %s using %s tags( '1' )" % (tb, mt)) tdSql.execute("create table %s using %s tags( '1' )" % (tb, mt)) x = 0 while (x < rowNum): ms = "%dm" % x - #TSIM: sql insert into $tb values (now + $ms , $x ) - tdLog.info("insert into %s values (now + %s, %d )" % (tb, ms, x)) - tdSql.execute("insert into %s values (now + %s, %d )" % (tb, ms, x)) + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + "insert into %s values (now + %s, %d )" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d )" % + (tb, ms, x)) x = x + 1 i = i + 1 - #TSIM: - #TSIM: print =============== step2 + # TSIM: + # TSIM: print =============== step2 tdLog.info('=============== step2') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % mt) - tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % mt) - #TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 - tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) - #TSIM: if $data00 != 100 then + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info( + "%s %s %s %s %s %s %s" % + (tdSql.getData( + 0, 0), tdSql.getData( + 0, 1), tdSql.getData( + 0, 2), tdSql.getData( + 0, 3), tdSql.getData( + 0, 4), tdSql.getData( + 0, 5), tdSql.getData( + 0, 6))) + # TSIM: if $data00 != 100 then tdLog.info('tdSql.checkData(0, 0, 100)') tdSql.checkData(0, 0, 100) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2" % mt) - tdSql.error("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'" % mt) - #TSIM: return -1 - #TSIM: step2: - #TSIM: - #TSIM: print =============== step3 + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x + # step2 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2" % + mt) + tdSql.error( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'" % + mt) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 tdLog.info('=============== step3') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3" % mt) - tdSql.error("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'" % mt) - #TSIM: return -1 - #TSIM: step3: - #TSIM: - #TSIM: print =============== step4 + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x + # step3 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3" % + mt) + tdSql.error( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'" % + mt) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 tdLog.info('=============== step4') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % mt) - tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % mt) - #TSIM: if $rows != 1 then + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % + mt) + # TSIM: if $rows != 1 then tdLog.info('tdSql.checkRow(1)') tdSql.checkRows(1) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: if $data00 != 10 then + # TSIM: if $data00 != 10 then tdLog.info('tdSql.checkData(0, 0, 10)') tdSql.checkData(0, 0, 10) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== step5 + # TSIM: + # TSIM: print =============== step5 tdLog.info('=============== step5') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) - tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) - #TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 - tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0,0), tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0,5 ), tdSql.getData(0, 6))) - #TSIM: if $data00 != 200 then + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info( + "%s %s %s %s %s %s %s" % + (tdSql.getData( + 0, 0), tdSql.getData( + 0, 1), tdSql.getData( + 0, 2), tdSql.getData( + 0, 3), tdSql.getData( + 0, 4), tdSql.getData( + 0, 5), tdSql.getData( + 0, 6))) + # TSIM: if $data00 != 200 then tdLog.info('tdSql.checkData(0, 0, 200)') tdSql.checkData(0, 0, 200) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== step6 + # TSIM: + # TSIM: print =============== step6 tdLog.info('=============== step6') - #TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 - tdLog.info("select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6" % mt) - tdSql.error("select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) - #TSIM: return -1 - #TSIM: step6: - #TSIM: - #TSIM: print =============== step7 + # TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + tdLog.info( + "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6" % + mt) + tdSql.error( + "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + # TSIM: return -1 + # TSIM: step6: + # TSIM: + # TSIM: print =============== step7 tdLog.info('=============== step7') - #TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 - tdLog.info("select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7" % mt) - tdSql.error("select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s" % mt) - #TSIM: return -1 - #TSIM: step7: - #TSIM: - #TSIM: print =============== step8 + # TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), + # max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + tdLog.info( + "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7" % + mt) + tdSql.error( + "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s" % + mt) + # TSIM: return -1 + # TSIM: step7: + # TSIM: + # TSIM: print =============== step8 tdLog.info('=============== step8') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol" % mt) - tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol" % mt) - #TSIM: - #TSIM: print =============== step9 + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol" % + mt) + # TSIM: + # TSIM: print =============== step9 tdLog.info('=============== step9') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 - tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9" % mt) - tdSql.error('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist ' % mt) - #TSIM: return -1 - #TSIM: step9: - #TSIM: - #TSIM: print =============== step10 + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x + # step9 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9" % + mt) + tdSql.error( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist ' % + mt) + # TSIM: return -1 + # TSIM: step9: + # TSIM: + # TSIM: print =============== step10 tdLog.info('=============== step10') - #TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol - tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % mt) - tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % mt) - #TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') - #TSIM: if $data00 != 100 then + # TSIM: if $data00 != 100 then tdLog.info('tdSql.checkData(0, 0, 100)') tdSql.checkData(0, 0, 100) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== step11 + # TSIM: + # TSIM: print =============== step11 tdLog.info('=============== step11') - #TSIM: sql select count(tbcol) as c from $mt group by tbcol + # TSIM: sql select count(tbcol) as c from $mt group by tbcol tdLog.info('select count(tbcol) as c from %s group by tbcol' % mt) tdSql.query('select count(tbcol) as c from %s group by tbcol' % mt) - #TSIM: - #TSIM: print =============== step12 + # TSIM: + # TSIM: print =============== step12 tdLog.info('=============== step12') - #TSIM: sql select count(tbcol) as c from $mt group by noexist -x step12 - tdLog.info('select count(tbcol) as c from %s group by noexist -x step12' % mt) + # TSIM: sql select count(tbcol) as c from $mt group by noexist -x + # step12 + tdLog.info( + 'select count(tbcol) as c from %s group by noexist -x step12' % + mt) tdSql.error('select count(tbcol) as c from %s group by noexist2' % mt) - #TSIM: return -1 - #TSIM: step12: - #TSIM: - #TSIM: print =============== step13 + # TSIM: return -1 + # TSIM: step12: + # TSIM: + # TSIM: print =============== step13 tdLog.info('=============== step13') - #TSIM: sql select count(tbcol) as c from $mt group by tgcol + # TSIM: sql select count(tbcol) as c from $mt group by tgcol tdLog.info('select count(tbcol) as c from %s group by tgcol' % mt) tdSql.query('select count(tbcol) as c from %s group by tgcol' % mt) - #TSIM: print $data00 + # TSIM: print $data00 tdLog.info('$data00') - #TSIM: if $data00 != 100 then + # TSIM: if $data00 != 100 then tdLog.info('tdSql.checkData(0, 0, 100)') tdSql.checkData(0, 0, 100) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== step14 + # TSIM: + # TSIM: print =============== step14 tdLog.info('=============== step14') - #TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol - tdLog.info('select count(tbcol) as c from %s where ts > 1000 group by tgcol' % mt) - tdSql.query('select count(tbcol) as c from %s where ts > 1000 group by tgcol' % mt) - #TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + # TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by + # tgcol + tdLog.info( + 'select count(tbcol) as c from %s where ts > 1000 group by tgcol' % + mt) + tdSql.query( + 'select count(tbcol) as c from %s where ts > 1000 group by tgcol' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 # tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) - #TSIM: if $data00 != 100 then + # TSIM: if $data00 != 100 then tdLog.info('tdSql.checkData(0, 0, 100)') tdSql.checkData(0, 0, 100) - #TSIM: print expect 100, actual $data00 + # TSIM: print expect 100, actual $data00 tdLog.info('expect 100, actual $data00') - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== step15 + # TSIM: + # TSIM: print =============== step15 tdLog.info('=============== step15') - #TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 - tdLog.info('select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15' % mt) - tdSql.error('select count(tbcol) as c from %s where noexist < 1 group by tgcol5' % mt) - #TSIM: return -1 - #TSIM: step15: - #TSIM: - #TSIM: print =============== step16 + # TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group + # by tgcol -x step15 + tdLog.info( + 'select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15' % + mt) + tdSql.error( + 'select count(tbcol) as c from %s where noexist < 1 group by tgcol5' % + mt) + # TSIM: return -1 + # TSIM: step15: + # TSIM: + # TSIM: print =============== step16 tdLog.info('=============== step16') - #TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol - tdLog.info("select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % mt) - tdSql.query("select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % mt) - #TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + # TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group + # by tgcol + tdLog.info( + "select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % + mt) + tdSql.query( + "select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 # tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) - #TSIM: if $data00 != 100 then + # TSIM: if $data00 != 100 then tdLog.info('tdSql.checkData(0, 0, 100)') tdSql.checkData(0, 0, 100) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: print =============== clear + # TSIM: + # TSIM: print =============== clear tdLog.info('=============== clear') - #TSIM: sql drop database $db + # TSIM: sql drop database $db tdLog.info('drop database db') tdSql.execute('drop database db') - #TSIM: sql show databases + # TSIM: sql show databases tdLog.info('show databases') tdSql.query('show databases') - #TSIM: if $rows != 0 then + # TSIM: if $rows != 0 then tdLog.info('tdSql.checkRow(0)') tdSql.checkRows(0) - #TSIM: return -1 + # TSIM: return -1 #TSIM: endi - #TSIM: - #TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT # convert end def stop(self): diff --git a/tests/pytest/tag_lite/float.py b/tests/pytest/tag_lite/float.py new file mode 100644 index 0000000000000000000000000000000000000000..1bfb1ac94d85afcf2e67dad73b44e0e3947798a4 --- /dev/null +++ b/tests/pytest/tag_lite/float.py @@ -0,0 +1,584 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_fl_db + # TSIM: $tbPrefix = ta_fl_tb + tbPrefix = "ta_fl_tb" + # TSIM: $mtPrefix = ta_fl_mt + mtPrefix = "ta_fl_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int.py b/tests/pytest/tag_lite/int.py new file mode 100644 index 0000000000000000000000000000000000000000..b83124479000f2d98ca02d7696aacf245bb4dc58 --- /dev/null +++ b/tests/pytest/tag_lite/int.py @@ -0,0 +1,583 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_in_db + # TSIM: $tbPrefix = ta_in_tb + tbPrefix = "ta_in_tb" + # TSIM: $mtPrefix = ta_in_mt + mtPrefix = "ta_in_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int_binary.py b/tests/pytest/tag_lite/int_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..62d8f2a6041ea67d2853cc45c2d1dbf8ca754414 --- /dev/null +++ b/tests/pytest/tag_lite/int_binary.py @@ -0,0 +1,791 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_inb_db + # TSIM: $tbPrefix = ta_inb_tb + tbPrefix = "ta_inb_tb" + # TSIM: $mtPrefix = ta_inb_mt + mtPrefix = "ta_inb_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, '1' ) + tdLog.info('create table %s using %s tags( 1, "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '1' + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' and + # tgcol = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and + # tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' + # and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> '0' and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and + # ts < now + 5m and ts < now + 5m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int_float.py b/tests/pytest/tag_lite/int_float.py new file mode 100644 index 0000000000000000000000000000000000000000..8a544c6110b217422db950ecbac1509cf357f25d --- /dev/null +++ b/tests/pytest/tag_lite/int_float.py @@ -0,0 +1,827 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_inf_db + # TSIM: $tbPrefix = ta_inf_tb + tbPrefix = "ta_inf_tb" + # TSIM: $mtPrefix = ta_inf_mt + mtPrefix = "ta_inf_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0 ) + tdLog.info('create table %s using %s tags( 0, 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 > 0.5 + tdLog.info('select * from %s where tgcol2 > 0.5' % (mt)) + tdSql.query('select * from %s where tgcol2 > 0.5' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 < 0.5 + tdLog.info('select * from %s where tgcol2 < 0.5' % (mt)) + tdSql.query('select * from %s where tgcol2 < 0.5' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 + tdLog.info( + 'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' % + (mt)) + tdSql.query( + 'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' % + (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 and + # tgcol = 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and + # tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol2 <> 0 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and + # ts < now + 5m and ts < now + 5m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = 1 group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/set.py b/tests/pytest/tag_lite/set.py new file mode 100644 index 0000000000000000000000000000000000000000..44f5a0890dfea91bbafe03e15c9dc580bd862401 --- /dev/null +++ b/tests/pytest/tag_lite/set.py @@ -0,0 +1,876 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_se_db + # TSIM: $tbPrefix = ta_se_tb + tbPrefix = "ta_se_tb" + # TSIM: $mtPrefix = ta_se_mt + mtPrefix = "ta_se_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tagcx 1 -x step21 + tdLog.info('alter table %s set tag tagcx 1 -x step21' % (tb)) + tdSql.error('alter table %s set tag tagcx 11' % (tb)) + # TSIM: return -1 + # TSIM: step21: + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = false + tdLog.info('select * from %s where tgcol1 = false' % (mt)) + tdSql.query('select * from %s where tgcol1 = false' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: print $data21 $data23 $data32 $data33 + tdLog.info('$data21 $data23 $data32 $data33') + # TSIM: if $data21 != BOOL then + tdLog.info('tdSql.checkDataType(2, 1, "BOOL")') + tdSql.checkDataType(2, 1, "BOOL") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data31 != INT then + tdLog.info('tdSql.checkDataType(3, 1, "INT")') + tdSql.checkDataType(3, 1, "INT") + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data23 != false then + tdLog.info('tdSql.checkData(2, 3, false)') + tdSql.checkData(2, 3, false) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data33 != 4 then + tdLog.info('tdSql.checkData(3, 3, 4)') + tdSql.checkData(3, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2='4' + tdLog.info('alter table %s set tag tgcol2="4"' % (tb)) + tdSql.execute('alter table %s set tag tgcol2="4"' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3.000000000 then + tdLog.info('tdSql.checkData(0, 2, 3.000000000)') + tdSql.checkData(0, 2, 3.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '4' + tdLog.info('select * from %s where tgcol2 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 3.000000000 then + tdLog.info('tdSql.checkData(0, 2, 3.000000000)') + tdSql.checkData(0, 2, 3.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, 6) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $tb set tag tgcol1='7' + tdLog.info('alter table %s set tag tgcol1="7"' % (tb)) + tdSql.execute('alter table %s set tag tgcol1="7"' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4='9' + tdLog.info('alter table %s set tag tgcol4="9"' % (tb)) + tdSql.execute('alter table %s set tag tgcol4="9"' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=10 + tdLog.info('alter table %s set tag tgcol5=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6='11' + tdLog.info('alter table %s set tag tgcol6="11"' % (tb)) + tdSql.execute('alter table %s set tag tgcol6="11"' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = '7' + tdLog.info('select * from %s where tgcol1 = "7"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "7"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, 9)') + tdSql.checkData(0, 4, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, 11)') + tdSql.checkData(0, 6, 11) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 8 + tdLog.info('select * from %s where tgcol2 = 8' % (mt)) + tdSql.query('select * from %s where tgcol2 = 8' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, 9)') + tdSql.checkData(0, 4, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, 11)') + tdSql.checkData(0, 6, 11) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '9' + tdLog.info('select * from %s where tgcol4 = "9"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "9"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, 9)') + tdSql.checkData(0, 4, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, 11)') + tdSql.checkData(0, 6, 11) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 10 + tdLog.info('select * from %s where tgcol5 = 10' % (mt)) + tdSql.query('select * from %s where tgcol5 = 10' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, 9)') + tdSql.checkData(0, 4, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, 11)') + tdSql.checkData(0, 6, 11) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '11' + tdLog.info('select * from %s where tgcol6 = "11"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "11"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, 7) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, 9)') + tdSql.checkData(0, 4, 9) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, 11)') + tdSql.checkData(0, 6, 11) + # TSIM: return -1 + #TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + tdSql.checkData(0, 7, None) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('sql drop database $db') + tdSql.execute('sql drop database $db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/smallint.py b/tests/pytest/tag_lite/smallint.py new file mode 100644 index 0000000000000000000000000000000000000000..a047b0afeec156b4d685d6b6cab1d03346ae74cc --- /dev/null +++ b/tests/pytest/tag_lite/smallint.py @@ -0,0 +1,584 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/tinyint.py b/tests/pytest/tag_lite/tinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..6e1820713c3dbdfad6de7cadbed024d91da2c3cb --- /dev/null +++ b/tests/pytest/tag_lite/tinyint.py @@ -0,0 +1,584 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ti_db + # TSIM: $tbPrefix = ta_ti_tb + tbPrefix = "ta_ti_tb" + # TSIM: $mtPrefix = ta_ti_mt + mtPrefix = "ta_ti_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + tdSql.execute( + 'insert into %s values (now + %s , %d )' % + (tb, ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + #TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + #TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (tb)) + tdSql.query('select * from %s where ts < now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts <= now + 4m + tdLog.info('select * from %s where ts <= now + 4m' % (tb)) + tdSql.query('select * from %s where ts <= now + 4m' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (tb)) + tdSql.query('select * from %s where ts > now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts >= now + 4m + tdLog.info('select * from %s where ts >= now + 4m' % (tb)) + tdSql.query('select * from %s where ts >= now + 4m' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m + tdLog.info( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + tdSql.query( + 'select * from %s where ts < now + 4m and ts > now + 5m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 3m' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and + # ts < now + 6m + tdLog.info( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < now + 4m + tdLog.info('select * from %s where ts < now + 4m' % (mt)) + tdSql.query('select * from %s where ts < now + 4m' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m + tdLog.info('select * from %s where ts > now + 4m' % (mt)) + tdSql.query('select * from %s where ts > now + 4m' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts = now + 4m + tdLog.info('select * from %s where ts = now + 4m' % (mt)) + tdSql.query('select * from %s where ts = now + 4m' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > now + 4m and tgcol = 1 + tdLog.info('select * from %s where ts > now + 4m and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 + tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= now + 4m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts + # < now + 5m + tdLog.info( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + tdSql.query( + 'select * from %s where ts > now + 4m and tgcol <> 0 and ts < now + 5m' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < now + 4m group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + #TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 9d76b0a70e56d9a749b8ba5de7ca57c896809aa6..5b35563e1bcb041fdcb2389c4609d91b3fa71e1a 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -31,9 +31,10 @@ if __name__ == "__main__": masterIp = "" testCluster = False valgrind = 0 + logSql = True stop = 0 - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:scgh', [ - 'file=', 'path=', 'master', 'stop', 'cluster', 'valgrind', 'help']) + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scgh', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help']) for key, value in opts: if key in ['-h', '--help']: tdLog.printNoPrefix( @@ -41,8 +42,10 @@ if __name__ == "__main__": tdLog.printNoPrefix('-f Name of test case file written by Python') tdLog.printNoPrefix('-p Deploy Path for Simulator') tdLog.printNoPrefix('-m Master Ip for Simulator') - tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-l logSql Flag') tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-g valgrind Test Flag') sys.exit(0) if key in ['-f', '--file']: @@ -54,6 +57,15 @@ if __name__ == "__main__": if key in ['-m', '--master']: masterIp = value + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + if key in ['-c', '--cluster']: testCluster = True @@ -79,6 +91,9 @@ if __name__ == "__main__": time.sleep(1) processID = subprocess.check_output(psCmd, shell=True) + fuserCmd = "fuser -k -n tcp 6030" + os.system(fuserCmd) + tdLog.info('stop All dnodes') sys.exit(0) @@ -97,6 +112,8 @@ if __name__ == "__main__": tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdCases.logSql(logSql) + if testCluster: tdLog.info("Procedures for testing cluster") if fileName == "all": diff --git a/tests/pytest/user/pass_len.py b/tests/pytest/user/pass_len.py index 40bd1ca5fc48524080434eb109060fac4e203f5b..346b8424fe325a214b798c58b06c3e3cfb0e4d39 100644 --- a/tests/pytest/user/pass_len.py +++ b/tests/pytest/user/pass_len.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): print("==============step1") diff --git a/tests/pytest/user/user_create.py b/tests/pytest/user/user_create.py index f8ac5c67997373e10deb6e2c3f96473fc59a0693..a00f670a36778e5ea2191ac4e7b43930efe64b01 100644 --- a/tests/pytest/user/user_create.py +++ b/tests/pytest/user/user_create.py @@ -19,9 +19,9 @@ from util.sql import tdSql class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def run(self): print("==============step1") diff --git a/tests/pytest/util/cases.py b/tests/pytest/util/cases.py index f65b0dfde3715221b26227f9224656347dc52709..2fc1ac8515e47f9354483ebb590897eea96dcc57 100644 --- a/tests/pytest/util/cases.py +++ b/tests/pytest/util/cases.py @@ -24,6 +24,7 @@ class TDCase: def __init__(self, name, case): self.name = name self.case = case + self._logSql = True class TDCases: @@ -36,6 +37,9 @@ class TDCases: moduleName = fileName.replace(".py", "").replace("/", ".") return importlib.import_module(moduleName, package='..') + def logSql(self, logSql): + self._logSql = logSql + def addWindows(self, name, case): self.windowsCases.append(TDCase(name, case)) @@ -66,7 +70,7 @@ class TDCases: for tmp in self.linuxCases: if tmp.name.find(fileName) != -1: case = testModule.TDTestCase() - case.init(conn) + case.init(conn, self._logSql) try: case.run() except Exception as e: diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 727016adb320e917c4d68b3ed1486577e423b1f9..ea178baf93748ad9655c5bc0477e23e74572644b 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -234,13 +234,15 @@ class TDDnode: if self.running != 0: psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") while(processID): killCmd = "kill -INT %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") self.running = 0 tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) @@ -253,13 +255,15 @@ class TDDnode: if self.running != 0: psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") while(processID): killCmd = "kill -KILL %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") self.running = 0 tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) @@ -310,7 +314,8 @@ class TDDnodes: killCmd = "kill -KILL %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") @@ -318,7 +323,8 @@ class TDDnodes: killCmd = "kill -KILL %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") binPath = os.path.dirname(os.path.realpath(__file__)) binPath = binPath + "/../../../debug/" @@ -416,7 +422,8 @@ class TDDnodes: killCmd = "kill -KILL %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") @@ -424,7 +431,8 @@ class TDDnodes: killCmd = "kill -KILL %s" % processID os.system(killCmd) time.sleep(1) - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") # if os.system(cmd) != 0 : # tdLog.exit(cmd) diff --git a/tests/pytest/util/log.py b/tests/pytest/util/log.py index bcd840999d324ad6cf605645b5cb58815efb9f1c..55cd42a6eb5059b931dc892bdd4eb6101031b730 100644 --- a/tests/pytest/util/log.py +++ b/tests/pytest/util/log.py @@ -23,7 +23,7 @@ class TDLog: self.path = "" def info(self, info): - print("%s %s" % (datetime.datetime.now(), info)) + print("%s %s\n" % (datetime.datetime.now(), info)) def sleep(self, sec): print("%s sleep %d seconds" % (datetime.datetime.now(), sec)) diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 1cc0eddbfc72dd5b266bbf6ac6e975092dc6788e..ec7ac117c07ee6c34ea91ffbb148729ab4c55119 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -25,9 +25,15 @@ class TDSql: self.queryCols = 0 self.affectedRows = 0 - def init(self, cursor): + def init(self, cursor, log=True): self.cursor = cursor + if (log): + frame = inspect.stack()[1] + callerModule = inspect.getmodule(frame[0]) + callerFilename = callerModule.__file__ + self.cursor.log(callerFilename + ".sql") + def close(self): self.cursor.close() @@ -52,6 +58,9 @@ class TDSql: "%s failed: sql:%s, expect error not occured" % (callerFilename, sql)) else: + self.queryRows = 0 + self.queryCols = 0 + self.queryResult = None tdLog.info("sql:%s, expect error occured" % (sql)) def query(self, sql): @@ -77,6 +86,30 @@ class TDSql: tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows)) + def checkDataType(self, row, col, dataType): + frame = inspect.stack()[1] + callerModule = inspect.getmodule(frame[0]) + callerFilename = callerModule.__file__ + + if row < 0: + tdLog.exit( + "%s failed: sql:%s, row:%d is smaller than zero" % + (callerFilename, self.sql, row)) + if col < 0: + tdLog.exit( + "%s failed: sql:%s, col:%d is smaller than zero" % + (callerFilename, self.sql, col)) + if row > self.queryRows: + tdLog.exit( + "%s failed: sql:%s, row:%d is larger than queryRows:%d" % + (callerFilename, self.sql, row, self.queryRows)) + if col > self.queryCols: + tdLog.exit( + "%s failed: sql:%s, col:%d is larger than queryCols:%d" % + (callerFilename, self.sql, col, self.queryCols)) + + return self.cursor.istype(col, dataType) + def checkData(self, row, col, data): frame = inspect.stack()[1] callerModule = inspect.getmodule(frame[0]) @@ -157,8 +190,9 @@ class TDSql: callerModule = inspect.getmodule(frame[0]) callerFilename = callerModule.__file__ - tdLog.exit("%s failed: sql:%s, affectedRows:%d != expect:%d" % ( - callerFilename, self.sql, self.affectedRows, expectAffectedRows)) + tdLog.exit( + "%s failed: sql:%s, affectedRows:%d != expect:%d" % + (callerFilename, self.sql, self.affectedRows, expectAffectedRows)) tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows)) diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim new file mode 100644 index 0000000000000000000000000000000000000000..f871ead11df579494aea818cf186c346932f6bea --- /dev/null +++ b/tests/script/general/db/alter_option.sim @@ -0,0 +1,69 @@ +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 numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +sql create database db maxTables 500 cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +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 $data05 != 10 then + return -1 +endi +if $data06 != 20,20,20 then + return -1 +endi +if $data07 != 500 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi + +print =============== step2 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +return +sql_error alter database db cache 256 +sql_error alter database db blocks 1 +sql_error alter database db maxTables 10 +sql_error alter database db days 10 +sql_error alter database db keep 10 +sql_error alter database db minRows 350 +sql_error alter database db minRows 550 +sql_error alter database db ctime 5000 +sql_error alter database db precision "us" +sql_error alter database db comp 3 +sql_error alter database db wal 1 +sql_error alter database db replica 2 + + +print ============== step3 +sql alter database db maxTables 1000 +sql alter database db comp 1 +sql alter database db blocks 40 +sql alter database db keep 30 + + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/general/db/alter_tables_d2.sim new file mode 100644 index 0000000000000000000000000000000000000000..1fd24f9cec5b54c1be7531f24a3f590d94b28e38 --- /dev/null +++ b/tests/script/general/db/alter_tables_d2.sim @@ -0,0 +1,468 @@ +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 numOfTotalVnodes -v 2 + +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 2 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +sleep 3000 +sql connect +sql create dnode $hostname2 +sleep 1000 + +print ============================ step1 + +sql create database db maxTables 5 +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 + +sql alter database db maxTables 10 +sleep 1000 + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 + +sql alter database db maxTables 15 +sleep 1000 + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t300 using db.st tags(10) +sql show db.tables +if $rows != 60 then + return -1 +endi + +print ============================ step9 + +sql alter database db maxTables 20 +sleep 1000 + +sql create table db.t300 using db.st tags(0) +sql create table db.t301 using db.st tags(1) +sql create table db.t302 using db.st tags(2) +sql create table db.t303 using db.st tags(3) +sql create table db.t304 using db.st tags(4) +sql create table db.t305 using db.st tags(5) +sql create table db.t306 using db.st tags(6) +sql create table db.t307 using db.st tags(7) +sql create table db.t308 using db.st tags(8) +sql create table db.t309 using db.st tags(9) +sql create table db.t310 using db.st tags(0) +sql create table db.t311 using db.st tags(1) +sql create table db.t312 using db.st tags(2) +sql create table db.t313 using db.st tags(3) +sql create table db.t314 using db.st tags(4) +sql create table db.t315 using db.st tags(5) +sql create table db.t316 using db.st tags(6) +sql create table db.t317 using db.st tags(7) +sql create table db.t318 using db.st tags(8) +sql create table db.t319 using db.st tags(9) + +sql insert into db.t300 values(now, 1) +sql insert into db.t301 values(now, 1) +sql insert into db.t302 values(now, 1) +sql insert into db.t303 values(now, 1) +sql insert into db.t304 values(now, 1) +sql insert into db.t305 values(now, 1) +sql insert into db.t306 values(now, 1) +sql insert into db.t307 values(now, 1) +sql insert into db.t308 values(now, 1) +sql insert into db.t309 values(now, 1) +sql insert into db.t310 values(now, 1) +sql insert into db.t311 values(now, 1) +sql insert into db.t312 values(now, 1) +sql insert into db.t313 values(now, 1) +sql insert into db.t314 values(now, 1) +sql insert into db.t315 values(now, 1) +sql insert into db.t316 values(now, 1) +sql insert into db.t317 values(now, 1) +sql insert into db.t318 values(now, 1) +sql insert into db.t319 values(now, 1) + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t400 using db.st tags(10) +sql show db.tables +if $rows != 80 then + return -1 +endi + +print ============================ step9 + +sql alter database db maxTables 25 +sleep 1000 + +sql create table db.t400 using db.st tags(0) +sql create table db.t401 using db.st tags(1) +sql create table db.t402 using db.st tags(2) +sql create table db.t403 using db.st tags(3) +sql create table db.t404 using db.st tags(4) +sql create table db.t405 using db.st tags(5) +sql create table db.t406 using db.st tags(6) +sql create table db.t407 using db.st tags(7) +sql create table db.t408 using db.st tags(8) +sql create table db.t409 using db.st tags(9) +sql create table db.t410 using db.st tags(0) +sql create table db.t411 using db.st tags(1) +sql create table db.t412 using db.st tags(2) +sql create table db.t413 using db.st tags(3) +sql create table db.t414 using db.st tags(4) +sql create table db.t415 using db.st tags(5) +sql create table db.t416 using db.st tags(6) +sql create table db.t417 using db.st tags(7) +sql create table db.t418 using db.st tags(8) +sql create table db.t419 using db.st tags(9) + +sql insert into db.t400 values(now, 1) +sql insert into db.t401 values(now, 1) +sql insert into db.t402 values(now, 1) +sql insert into db.t403 values(now, 1) +sql insert into db.t404 values(now, 1) +sql insert into db.t405 values(now, 1) +sql insert into db.t406 values(now, 1) +sql insert into db.t407 values(now, 1) +sql insert into db.t408 values(now, 1) +sql insert into db.t409 values(now, 1) +sql insert into db.t410 values(now, 1) +sql insert into db.t411 values(now, 1) +sql insert into db.t412 values(now, 1) +sql insert into db.t413 values(now, 1) +sql insert into db.t414 values(now, 1) +sql insert into db.t415 values(now, 1) +sql insert into db.t416 values(now, 1) +sql insert into db.t417 values(now, 1) +sql insert into db.t418 values(now, 1) +sql insert into db.t419 values(now, 1) + +sql show db.tables +if $rows != 100 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.t400 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_tables_v1.sim b/tests/script/general/db/alter_tables_v1.sim new file mode 100644 index 0000000000000000000000000000000000000000..17aa746ce37465d1dfb177de544275cd5c00ca65 --- /dev/null +++ b/tests/script/general/db/alter_tables_v1.sim @@ -0,0 +1,352 @@ +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 numOfTotalVnodes -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ step1 + +sql create database db maxTables 10 +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t0 using db.st tags(0) +sql create table db.t1 using db.st tags(1) +sql create table db.t2 using db.st tags(2) +sql create table db.t3 using db.st tags(3) +sql create table db.t4 using db.st tags(4) +sql create table db.t5 using db.st tags(5) +sql create table db.t6 using db.st tags(6) +sql create table db.t7 using db.st tags(7) +sql create table db.t8 using db.st tags(8) +sql create table db.t9 using db.st tags(9) + +sql show db.tables +if $rows != 10 then + return -1 +endi + +sql insert into db.t0 values(now, 1) +sql insert into db.t1 values(now, 1) +sql insert into db.t2 values(now, 1) +sql insert into db.t3 values(now, 1) +sql insert into db.t4 values(now, 1) +sql insert into db.t5 values(now, 1) +sql insert into db.t6 values(now, 1) +sql insert into db.t7 values(now, 1) +sql insert into db.t8 values(now, 1) +sql insert into db.t9 values(now, 1) + +print ============================ step2 +sql_error create table db.t10 using db.st tags(10) +sql show db.tables +if $rows != 10 then + return -1 +endi + +print ============================ step3 + +sql alter database db maxTables 20 +sleep 1000 + +sql create table db.t10 using db.st tags(0) +sql create table db.t11 using db.st tags(1) +sql create table db.t12 using db.st tags(2) +sql create table db.t13 using db.st tags(3) +sql create table db.t14 using db.st tags(4) +sql create table db.t15 using db.st tags(5) +sql create table db.t16 using db.st tags(6) +sql create table db.t17 using db.st tags(7) +sql create table db.t18 using db.st tags(8) +sql create table db.t19 using db.st tags(9) +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t10 values(now, 1) +sql insert into db.t11 values(now, 1) +sql insert into db.t12 values(now, 1) +sql insert into db.t13 values(now, 1) +sql insert into db.t14 values(now, 1) +sql insert into db.t15 values(now, 1) +sql insert into db.t16 values(now, 1) +sql insert into db.t17 values(now, 1) +sql insert into db.t18 values(now, 1) +sql insert into db.t19 values(now, 1) + +print ============================ step4 +sql_error create table db.t20 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step5 + +sql alter database db maxTables 30 +sleep 1000 + +sql create table db.t20 using db.st tags(0) +sql create table db.t21 using db.st tags(1) +sql create table db.t22 using db.st tags(2) +sql create table db.t23 using db.st tags(3) +sql create table db.t24 using db.st tags(4) +sql create table db.t25 using db.st tags(5) +sql create table db.t26 using db.st tags(6) +sql create table db.t27 using db.st tags(7) +sql create table db.t28 using db.st tags(8) +sql create table db.t29 using db.st tags(9) +sql show db.tables +if $rows != 30 then + return -1 +endi + +sql insert into db.t20 values(now, 1) +sql insert into db.t21 values(now, 1) +sql insert into db.t22 values(now, 1) +sql insert into db.t23 values(now, 1) +sql insert into db.t24 values(now, 1) +sql insert into db.t25 values(now, 1) +sql insert into db.t26 values(now, 1) +sql insert into db.t27 values(now, 1) +sql insert into db.t28 values(now, 1) +sql insert into db.t29 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 1000 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 30 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 30 then + return -1 +endi + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 30 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t30 using db.st tags(10) +sql show db.tables +if $rows != 30 then + return -1 +endi + +print ============================ step9 + +sql alter database db maxTables 40 +sleep 1000 + +sql create table db.t30 using db.st tags(0) +sql create table db.t31 using db.st tags(1) +sql create table db.t32 using db.st tags(2) +sql create table db.t33 using db.st tags(3) +sql create table db.t34 using db.st tags(4) +sql create table db.t35 using db.st tags(5) +sql create table db.t36 using db.st tags(6) +sql create table db.t37 using db.st tags(7) +sql create table db.t38 using db.st tags(8) +sql create table db.t39 using db.st tags(9) + +sql insert into db.t30 values(now, 1) +sql insert into db.t31 values(now, 1) +sql insert into db.t32 values(now, 1) +sql insert into db.t33 values(now, 1) +sql insert into db.t34 values(now, 1) +sql insert into db.t35 values(now, 1) +sql insert into db.t36 values(now, 1) +sql insert into db.t37 values(now, 1) +sql insert into db.t38 values(now, 1) +sql insert into db.t39 values(now, 1) + +sql show db.tables +if $rows != 40 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.t30 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 40 then + return -1 +endi + + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 40 then + return -1 +endi + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 40 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t40 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step12 + +sql alter database db maxTables 50 +sleep 1000 + +sql create table db.t40 using db.st tags(0) +sql create table db.t41 using db.st tags(1) +sql create table db.t42 using db.st tags(2) +sql create table db.t43 using db.st tags(3) +sql create table db.t44 using db.st tags(4) +sql create table db.t45 using db.st tags(5) +sql create table db.t46 using db.st tags(6) +sql create table db.t47 using db.st tags(7) +sql create table db.t48 using db.st tags(8) +sql create table db.t49 using db.st tags(9) + +sql insert into db.t40 values(now, 1) +sql insert into db.t41 values(now, 1) +sql insert into db.t42 values(now, 1) +sql insert into db.t43 values(now, 1) +sql insert into db.t44 values(now, 1) +sql insert into db.t45 values(now, 1) +sql insert into db.t46 values(now, 1) +sql insert into db.t47 values(now, 1) +sql insert into db.t48 values(now, 1) +sql insert into db.t49 values(now, 1) + +sql show db.tables +if $rows != 50 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.t30 +if $rows != 1 then + return -1 +endi + +sql select * from db.t40 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 50 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_tables_v4.sim b/tests/script/general/db/alter_tables_v4.sim new file mode 100644 index 0000000000000000000000000000000000000000..db00219ed03d20eaf369b4c7386dd1f774cf4417 --- /dev/null +++ b/tests/script/general/db/alter_tables_v4.sim @@ -0,0 +1,457 @@ +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 numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ step1 + +sql create database db maxTables 5 +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 + +sql alter database db maxTables 10 +sleep 1000 + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 + +sql alter database db maxTables 15 +sleep 1000 + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t300 using db.st tags(10) +sql show db.tables +if $rows != 60 then + return -1 +endi + +print ============================ step9 + +sql alter database db maxTables 20 +sleep 1000 + +sql create table db.t300 using db.st tags(0) +sql create table db.t301 using db.st tags(1) +sql create table db.t302 using db.st tags(2) +sql create table db.t303 using db.st tags(3) +sql create table db.t304 using db.st tags(4) +sql create table db.t305 using db.st tags(5) +sql create table db.t306 using db.st tags(6) +sql create table db.t307 using db.st tags(7) +sql create table db.t308 using db.st tags(8) +sql create table db.t309 using db.st tags(9) +sql create table db.t310 using db.st tags(0) +sql create table db.t311 using db.st tags(1) +sql create table db.t312 using db.st tags(2) +sql create table db.t313 using db.st tags(3) +sql create table db.t314 using db.st tags(4) +sql create table db.t315 using db.st tags(5) +sql create table db.t316 using db.st tags(6) +sql create table db.t317 using db.st tags(7) +sql create table db.t318 using db.st tags(8) +sql create table db.t319 using db.st tags(9) + +sql insert into db.t300 values(now, 1) +sql insert into db.t301 values(now, 1) +sql insert into db.t302 values(now, 1) +sql insert into db.t303 values(now, 1) +sql insert into db.t304 values(now, 1) +sql insert into db.t305 values(now, 1) +sql insert into db.t306 values(now, 1) +sql insert into db.t307 values(now, 1) +sql insert into db.t308 values(now, 1) +sql insert into db.t309 values(now, 1) +sql insert into db.t310 values(now, 1) +sql insert into db.t311 values(now, 1) +sql insert into db.t312 values(now, 1) +sql insert into db.t313 values(now, 1) +sql insert into db.t314 values(now, 1) +sql insert into db.t315 values(now, 1) +sql insert into db.t316 values(now, 1) +sql insert into db.t317 values(now, 1) +sql insert into db.t318 values(now, 1) +sql insert into db.t319 values(now, 1) + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t400 using db.st tags(10) +sql show db.tables +if $rows != 80 then + return -1 +endi + +print ============================ step12 + +sql alter database db maxTables 25 +sleep 1000 + +sql create table db.t400 using db.st tags(0) +sql create table db.t401 using db.st tags(1) +sql create table db.t402 using db.st tags(2) +sql create table db.t403 using db.st tags(3) +sql create table db.t404 using db.st tags(4) +sql create table db.t405 using db.st tags(5) +sql create table db.t406 using db.st tags(6) +sql create table db.t407 using db.st tags(7) +sql create table db.t408 using db.st tags(8) +sql create table db.t409 using db.st tags(9) +sql create table db.t410 using db.st tags(0) +sql create table db.t411 using db.st tags(1) +sql create table db.t412 using db.st tags(2) +sql create table db.t413 using db.st tags(3) +sql create table db.t414 using db.st tags(4) +sql create table db.t415 using db.st tags(5) +sql create table db.t416 using db.st tags(6) +sql create table db.t417 using db.st tags(7) +sql create table db.t418 using db.st tags(8) +sql create table db.t419 using db.st tags(9) + +sql insert into db.t400 values(now, 1) +sql insert into db.t401 values(now, 1) +sql insert into db.t402 values(now, 1) +sql insert into db.t403 values(now, 1) +sql insert into db.t404 values(now, 1) +sql insert into db.t405 values(now, 1) +sql insert into db.t406 values(now, 1) +sql insert into db.t407 values(now, 1) +sql insert into db.t408 values(now, 1) +sql insert into db.t409 values(now, 1) +sql insert into db.t410 values(now, 1) +sql insert into db.t411 values(now, 1) +sql insert into db.t412 values(now, 1) +sql insert into db.t413 values(now, 1) +sql insert into db.t414 values(now, 1) +sql insert into db.t415 values(now, 1) +sql insert into db.t416 values(now, 1) +sql insert into db.t417 values(now, 1) +sql insert into db.t418 values(now, 1) +sql insert into db.t419 values(now, 1) + +sql show db.tables +if $rows != 100 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.t400 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_vgroups.sim b/tests/script/general/db/alter_vgroups.sim new file mode 100644 index 0000000000000000000000000000000000000000..1aae7b93830b5d0ed80e7087af6772cbac1a4947 --- /dev/null +++ b/tests/script/general/db/alter_vgroups.sim @@ -0,0 +1,210 @@ +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 numOfTotalVnodes -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ step1 + +sql create database db maxTables 20 +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 2 +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 3 +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/dropdnodes.sim b/tests/script/general/db/dropdnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..7ba5e7b66e26a506f6204259a60e8acd69454b6c --- /dev/null +++ b/tests/script/general/db/dropdnodes.sim @@ -0,0 +1,104 @@ +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/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +sleep 3000 +sql connect + +sql create dnode $hostname2 +sleep 2000 + +sql create database db maxTables 4 +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table db.t1 using db.mt tags(1) +sql create table db.t2 using db.mt tags(2) +sql create table db.t3 using db.mt tags(3) +sql create table db.t4 using db.mt tags(4) +sql create table db.t5 using db.mt tags(5) +sql create table db.t6 using db.mt tags(6) +sql create table db.t7 using db.mt tags(7) +sql create table db.t8 using db.mt tags(8) +sql create table db.t9 using db.mt tags(9) +sql create table db.t10 using db.mt tags(10) +sql create table db.t11 using db.mt tags(11) +sql create table db.t12 using db.mt tags(12) +sql create table db.t13 using db.mt tags(13) +sql create table db.t14 using db.mt tags(14) +sql create table db.t15 using db.mt tags(15) +sql create table db.t16 using db.mt tags(16) + +sql insert into db.t1 values(now, 1) +sql insert into db.t2 values(now, 1) +sql insert into db.t3 values(now, 1) +sql insert into db.t4 values(now, 1) +sql insert into db.t5 values(now, 1) +sql insert into db.t6 values(now, 1) +sql insert into db.t7 values(now, 1) +sql insert into db.t8 values(now, 1) +sql insert into db.t9 values(now, 1) +sql insert into db.t10 values(now, 1) +sql insert into db.t11 values(now, 1) +sql insert into db.t12 values(now, 1) +sql insert into db.t13 values(now, 1) +sql insert into db.t14 values(now, 1) +sql insert into db.t15 values(now, 1) +sql insert into db.t16 values(now, 1) + +print ========== step2 +sql show tables +print $rows +if $rows != 16 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 16 then + return -1 +endi + +print ========== step3 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 500 +sql drop dnode $hostname2 +sleep 2000 + +print ========== step3 + +sql show tables +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from db.t5 +if $rows != 1 then + return -1 +endi + +sql select * from db.t13 +if $rows != 1 then + return -1 +endi + +sql_error select * from db.t1 +sql_error select * from db.t9 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/autocreate.sim b/tests/script/general/http/autocreate.sim new file mode 100644 index 0000000000000000000000000000000000000000..7c1fdcd0f842021f644feb4bec93d31ab88cf6c5 --- /dev/null +++ b/tests/script/general/http/autocreate.sim @@ -0,0 +1,28 @@ +system sh/stop_dnodes.sh +sleep 3000 +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 http -v 1 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database db +sql use db +sql create table if not exists db.win_cpu(ts timestamp,f_percent_dpc_time double,f_percent_idle_time double,f_percent_interrupt_time double,f_percent_privileged_time double,f_percent_processor_time double,f_percent_user_time double) tags(t_host binary(32),t_instance binary(32),t_objectname binary(32)); + +print =============== step2 - auto create + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'import into db.win_cpu_windows_1_processor using db.win_cpu tags('windows','1','Processor') values(1564641722000,0.000000,95.598305,0.000000,0.000000,0.000000,0.000000);' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content +#if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then +# return -1 +#endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/restful_insert.sim b/tests/script/general/http/restful_insert.sim index 7b1e88a25f53c188072963f6bbd39c419a81dc12..b36a92c0034b844bacf9c05dff41c8537dd19382 100644 --- a/tests/script/general/http/restful_insert.sim +++ b/tests/script/general/http/restful_insert.sim @@ -37,7 +37,7 @@ endi print =============== step3 - query data -system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim index 1bd1419496aebd532682c5632e52776dca538566..61f563ba8e9489e2ad0ffe217b37603ffb975319 100644 --- a/tests/script/general/import/replica1.sim +++ b/tests/script/general/import/replica1.sim @@ -32,10 +32,10 @@ sql connect sql create database ir1db days 7 sql use ir1db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -43,7 +43,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -51,7 +51,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -59,9 +59,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -69,10 +69,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -80,11 +80,11 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then @@ -104,11 +104,11 @@ if $rows != 14 then endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows if $rows != 19 then @@ -117,13 +117,13 @@ if $rows != 19 then endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows -if $rows != 24 then +if $rows != 23 then return -1 endi @@ -142,21 +142,21 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi @@ -169,42 +169,42 @@ sleep 5000 sql use ir1db sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; -if $rows != 41 then +if $rows != 40 then return -1 endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows -if $rows != 50 then +if $rows != 49 then return -1 endi print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; -if $rows != 50 then +if $rows != 52 then return -1 endi diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim index 5b951b7b350224d5346eaa8e2a3772cf72660281..f21a83067186dc226bd035fe3ff7ba5cc28675c0 100644 --- a/tests/script/general/parser/create_mt.sim +++ b/tests/script/general/parser/create_mt.sim @@ -45,10 +45,6 @@ sql show stables if $rows != 0 then return -1 endi -print data00 = $data00 -if $data00 != NULL then - return -1 -endi print case_insensitivity test passed # case2: illegal_metric_name test diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim index 7bb329396c6f3209223d5a99d184d9840c17f627..9d1672fdbef136fccb28d38df967d45132c9d40a 100644 --- a/tests/script/general/parser/create_tb.sim +++ b/tests/script/general/parser/create_tb.sim @@ -44,10 +44,6 @@ sql show tables if $rows != 0 then return -1 endi -print data00 = $data00 -if $data00 != NULL then - return -1 -endi print case_insensitivity test passed # case2: illegal_table_name test diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim index 8ed21a47e6b928cbd3f9ab4019edd8c1f70e3190..a9484d10dbaaad1c8c08b2ae54caf85ad186207e 100644 --- a/tests/script/general/parser/limit1_tb.sim +++ b/tests/script/general/parser/limit1_tb.sim @@ -111,16 +111,16 @@ endi if $data09 != nchar0 then return -1 endi -if $data11 != NULL then +if $data11 != null then return -1 endi -if $data12 != NULL then +if $data12 != null then return -1 endi -if $data13 != NULL then +if $data13 != null then return -1 endi -if $data14 != NULL then +if $data14 != null then return -1 endi @@ -543,7 +543,7 @@ endi if $data14 != 8.000000000 then return -1 endi -if $data21 != NULL then +if $data21 != null then return -1 endi @@ -613,7 +613,7 @@ endi if $data21 != 7.000000000 then return -1 endi -if $data31 != NULL then +if $data31 != null then return -1 endi sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim index af4d3eda852ae7fe5219fbb66642950003fdb78a..126c3227a7eb21852f8fcf23333a99a20e6a1763 100644 --- a/tests/script/general/parser/limit1_tblocks100.sim +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -21,7 +21,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db tblocks 100 +sql create database $db cache 16 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim index c6a3766b7d41b690cda319859ad3186af23ef6dd..9983424dbfe3ee4fd31beef7a5d9022c286a7569 100644 --- a/tests/script/general/parser/limit_stb.sim +++ b/tests/script/general/parser/limit_stb.sim @@ -47,19 +47,21 @@ sql select * from $stb order by ts desc limit 5 if $rows != 5 then return -1 endi + sql select * from $stb order by ts desc limit 5 offset 1 if $rows != 5 then return -1 endi -if $data01 != 8 then +if $data01 != 9 then return -1 endi -if $data11 != 7 then +if $data11 != 9 then return -1 endi -if $data41 != 4 then +if $data41 != 9 then return -1 endi + sql select * from $stb order by ts asc limit 5 if $rows != 5 then return -1 @@ -67,19 +69,28 @@ endi if $data00 != @18-09-17 09:00:00.000@ then return -1 endi + +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi + if $data01 != 0 then return -1 endi -if $data12 != 1 then + +print data12 = $data12 +if $data12 != NULL then return -1 endi -if $data24 != 2.000000000 then + +if $data24 != NULL then return -1 endi -if $data35 != 3 then + +if $data35 != 0 then return -1 endi -if $data49 != nchar4 then +if $data49 != nchar0 then return -1 endi @@ -87,10 +98,18 @@ sql select * from $stb order by ts asc limit 5 offset 1 if $rows != 5 then return -1 endi -if $data01 != 1 then +if $data01 != 0 then return -1 endi -if $data41 != 5 then +if $data41 != 0 then + return -1 +endi + +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi + +if $data00 != @18-09-17 09:00:00.000@ then return -1 endi @@ -98,6 +117,7 @@ sql select * from $stb limit 500 offset 1 if $rows != 99 then return -1 endi + if $data01 != 1 then return -1 endi @@ -629,6 +649,7 @@ endi if $data09 != 7 then return -1 endi +print $data13 if $data13 != 0.000000000 then return -1 endi @@ -656,6 +677,8 @@ endi if $data35 != 0 then return -1 endi + +print $data36 if $data36 != 0.000000000 then return -1 endi @@ -675,49 +698,49 @@ if $data59 != 2 then return -1 endi -sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 -if $rows != 3 then - return -1 -endi -if $data00 != @18-09-17 09:20:00.000@ then - return -1 -endi -if $data01 != 2 then - return -1 -endi -if $data02 != 2 then - return -1 -endi -if $data09 != 4 then - return -1 -endi -if $data13 != 3.000000000 then - return -1 -endi -if $data19 != 4 then - return -1 -endi -if $data20 != @18-09-17 09:40:00.000@ then - return -1 -endi -if $data24 != 1 then - return -1 -endi -if $data25 != 4 then - return -1 -endi -if $data26 != 0.000000000 then - return -1 -endi -if $data27 != 4 then - return -1 -endi -if $data28 != 4 then - return -1 -endi -if $data29 != 4 then - return -1 -endi +#sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi +#if $data02 != 2 then +# return -1 +#endi +#if $data09 != 4 then +# return -1 +#endi +#if $data13 != 3.000000000 then +# return -1 +#endi +#if $data19 != 4 then +# return -1 +#endi +#if $data20 != @18-09-17 09:40:00.000@ then +# return -1 +#endi +#if $data24 != 1 then +# return -1 +#endi +#if $data25 != 4 then +# return -1 +#endi +#if $data26 != 0.000000000 then +# return -1 +#endi +#if $data27 != 4 then +# return -1 +#endi +#if $data28 != 4 then +# return -1 +#endi +#if $data29 != 4 then +# return -1 +#endi sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 if $rows != 6 then diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim index 00d49b556fa013383881fd2f25c0b171e1096618..9e62d652e2527c55a02895984877b29904b8ca2a 100644 --- a/tests/script/general/parser/limit_tb.sim +++ b/tests/script/general/parser/limit_tb.sim @@ -111,18 +111,7 @@ endi if $data09 != nchar0 then return -1 endi -if $data11 != NULL then - return -1 -endi -if $data12 != NULL then - return -1 -endi -if $data13 != NULL then - return -1 -endi -if $data14 != NULL then - return -1 -endi + ## TBASE-329 sql select * from $tb where c1 < 9 order by ts desc limit 1 offset 1 @@ -537,7 +526,8 @@ endi if $data14 != 8.000000000 then return -1 endi -if $data21 != NULL then +if $data21 != null then + print expect null, actual: $data21 return -1 endi @@ -554,7 +544,7 @@ endi if $data21 != 9 then return -1 endi -if $data31 != NULL then +if $data31 != null then return -1 endi @@ -574,7 +564,7 @@ endi if $data31 != 9 then return -1 endi -if $data41 != NULL then +if $data41 != null then return -1 endi sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 @@ -590,7 +580,7 @@ endi if $data21 != 9 then return -1 endi -if $data31 != NULL then +if $data31 != null then return -1 endi @@ -607,7 +597,7 @@ endi if $data21 != 7.000000000 then return -1 endi -if $data31 != NULL then +if $data31 != null then return -1 endi sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 @@ -623,7 +613,7 @@ endi if $data21 != 9.000000000 then return -1 endi -if $data31 != NULL then +if $data31 != null then return -1 endi diff --git a/tests/script/general/parser/null_char.sim b/tests/script/general/parser/null_char.sim index d395b4c8baa8f29a5d292cdbc27600fd64522244..7a6c40c1a3fb9d6cabbc0109259d6e976c94556e 100644 --- a/tests/script/general/parser/null_char.sim +++ b/tests/script/general/parser/null_char.sim @@ -84,43 +84,43 @@ endi #### case 1: tag NULL, or 'NULL' sql create table mt2 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) sql create table st2 using mt2 tags (NULL, 'NULL', 102, 'true') -sql describe st2 -if $rows != 10 then +sql select tag1, tag2, tag3, tag5 from st2 +if $rows != 1 then return -1 endi -if $data63 != NULL then - print ==1== expect: NULL, actually: $data63 +if $data00 != NULL then + print ==1== expect: NULL, actually: $data00 return -1 endi -if $data73 != NULL then - print ==2== expect: NULL, actually: $data73 +if $data01 != NULL then + print ==2== expect: NULL, actually: $data01 return -1 endi -if $data83 != 102 then - print ==3== expect: NULL, actually: $data83 +if $data02 != 102 then + print ==3== expect: NULL, actually: $data02 return -1 endi -if $data93 != true then - print ==4== expect: NULL, actually: $data93 +if $data03 != 1 then + print ==4== expect: 1, actually: $data03 return -1 endi sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE') -sql describe st3 -if $rows != 10 then +sql select tag1, tag2, tag3, tag5 from st3 +if $rows != 1 then return -1 endi -if $data63 != NULL then - print ==5== expect: NULL, actually: $data63 +if $data00 != NULL then + print ==5== expect: NULL, actually: $data00 return -1 endi -if $data73 != ABC then +if $data01 != ABC then return -1 endi -if $data83 != 103 then +if $data02 != 103 then return -1 endi -if $data93 != false then +if $data03 != 0 then return -1 endi @@ -128,39 +128,39 @@ endi sql_error create table stx using mt2 tags ('NULL', '123aBc', 104, '123') sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL') -sql describe st4 -if $rows != 10 then +sql select tag1,tag2,tag3,tag5 from st4 +if $rows != 1 then return -1 endi -if $data63 != NULL then +if $data00 != NULL then return -1 endi -if $data73 != 123aBc then +if $data01 != 123aBc then return -1 endi -if $data83 != 104 then +if $data02 != 104 then return -1 endi -if $data93 != NULL then - print ==6== expect: NULL, actually: $data93 +if $data03 != NULL then + print ==6== expect: NULL, actually: $data03 return -1 endi sql create table st5 using mt2 tags ('NULL', '123aBc', 105, NULL) -sql describe st5 -if $rows != 10 then +sql select tag1,tag2,tag3,tag5 from st5 +if $rows != 1 then return -1 endi -if $data63 != NULL then +if $data00 != NULL then return -1 endi -if $data73 != 123aBc then +if $data01 != 123aBc then return -1 endi -if $data83 != 105 then +if $data02 != 105 then return -1 endi -if $data93 != NULL then +if $data03 != NULL then return -1 endi @@ -177,28 +177,29 @@ sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values #### case 3: set tag value sql create table mt4 (ts timestamp, c1 int) tags (tag_binary binary(16), tag_nchar nchar(16), tag_int int, tag_bool bool, tag_float float, tag_double double) sql create table st41 using mt4 tags ("beijing", 'nchar_tag', 100, false, 9.12345, 7.123456789) -sql describe st41 -if $rows != 8 then +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double st41 +if $rows != 1 then return -1 endi -if $data23 != beijing then +if $data00 != beijing then return -1 endi -if $data33 != nchar_tag then +if $data01 != nchar_tag then return -1 endi -if $data43 != 100 then +if $data02 != 100 then return -1 endi -if $data53 != false then +if $data03 != false then return -1 endi -if $data63 != 9.123450 then +if $dat04 != 9.123450 then return -1 endi -if $data73 != 7.123457 then +if $data05 != 7.123457 then return -1 endi + ################# binary sql alter table st41 set tag tag_binary = "shanghai" sql describe st41 diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/general/parser/selectResNum.sim index a0adc46d5f10792b62c57eb5a1c32b5b86a14f8a..ef9116cb3f8b3d25f2921dc3e70724ab3afa2e23 100644 --- a/tests/script/general/parser/selectResNum.sim +++ b/tests/script/general/parser/selectResNum.sim @@ -23,7 +23,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 2048 tables 200 +sql create database $db cache 16 maxtables 200 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/general/parser/single_row_in_tb.sim index 52bdad20658d33faea3d9b59b629ff48d79aef21..200047140e8ea85b972ba46a5e7f113561b77f01 100644 --- a/tests/script/general/parser/single_row_in_tb.sim +++ b/tests/script/general/parser/single_row_in_tb.sim @@ -15,7 +15,7 @@ $db = $dbPrefix $stb = $stbPrefix sql drop database if exists $db -sql create database $db rows 200 maxTables 4 +sql create database $db maxrows 200 maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/single_row_in_tb_query.sim b/tests/script/general/parser/single_row_in_tb_query.sim index 7bab49f2249bdc0cd863ad0bc804352a4b32400a..a1ae70ec814d0babf00dbf5051da45c5cd7daf94 100644 --- a/tests/script/general/parser/single_row_in_tb_query.sim +++ b/tests/script/general/parser/single_row_in_tb_query.sim @@ -130,6 +130,7 @@ if $data03 != 1 then return -1 endi if $data04 != 0.000000000 then + print expect: 0.00000000 , actual: $data04 return -1 endi if $data05 != 1 then diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index 0b7d705688aebc86367de89e6eae1fbf26cda802..3d5f33842e771b6ea93bdd11fa7856f34d628805 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -38,7 +38,6 @@ sleep 2000 run general/parser/lastrow.sim sleep 2000 run general/parser/nchar.sim - sleep 2000 run general/parser/null_char.sim sleep 2000 @@ -46,42 +45,45 @@ run general/parser/single_row_in_tb.sim sleep 2000 run general/parser/select_from_cache_disk.sim sleep 2000 -run general/parser/limit.sim - -sleep 2000 -run general/parser/fill.sim -sleep 2000 -run general/parser/fill_stb.sim -sleep 2000 -run general/parser/tags_dynamically_specifiy.sim +run general/parser/selectResNum.sim sleep 2000 -run general/parser/interp.sim +run general/parser/mixed_blocks.sim sleep 2000 run general/parser/limit1.sim sleep 2000 +run general/parser/limit.sim +sleep 2000 run general/parser/limit1_tblocks100.sim +sleep 2000 +run general/parser/select_across_vnodes.sim + sleep 2000 run general/parser/limit2.sim sleep 2000 -run general/parser/mixed_blocks.sim +run general/parser/tbnameIn.sim sleep 2000 -run general/parser/selectResNum.sim +run general/parser/slimit.sim sleep 2000 -run general/parser/select_across_vnodes.sim +run general/parser/slimit1.sim + sleep 2000 -run general/parser/set_tag_vals.sim +run general/parser/fill.sim sleep 2000 -run general/parser/slimit.sim +run general/parser/fill_stb.sim sleep 2000 -run general/parser/slimit1.sim +run general/parser/tags_dynamically_specifiy.sim +sleep 2000 +run general/parser/interp.sim +sleep 2000 +run general/parser/set_tag_vals.sim + sleep 2000 run general/parser/slimit_alter_tags.sim sleep 2000 run general/parser/stream_on_sys.sim sleep 2000 run general/parser/stream.sim -sleep 2000 -run general/parser/tbnameIn.sim + sleep 2000 run general/parser/where.sim sleep 2000 diff --git a/tests/script/general/table/column_value.sim b/tests/script/general/table/column_value.sim index 72f5faee63f7f3c30505f15c66d2b7296db8c83f..117c288b3602d3ca61fe83591c6943b79903e779 100644 --- a/tests/script/general/table/column_value.sim +++ b/tests/script/general/table/column_value.sim @@ -60,11 +60,9 @@ if $rows != 0 then endi print =============== step4 -sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -x step4 - return -1 -step4: +sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) sql show tables -if $rows != 0 then +if $rows != 1 then return -1 endi diff --git a/tests/script/general/tag/create.sim b/tests/script/general/tag/create.sim index 3e16810f9123104ef3d3fde99ca4f929d76036de..adbb14e88aa28a1b5b1d1f7cd7bdab53c6d7c104 100644 --- a/tests/script/general/tag/create.sim +++ b/tests/script/general/tag/create.sim @@ -579,7 +579,7 @@ $i = 30 $mt = $mtPrefix . $i $tb = $tbPrefix . $i sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 - return -1 +# return -1 step30: print =============== step31 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 272183b26d4c432d80002e454c7809601af75820..9d116aebc5cc3f93aaae28833631631d5f50368c 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -32,7 +32,7 @@ cd ../../../debug; make ./test.sh -f general/compute/diff.sim ./test.sh -f general/compute/diff2.sim ./test.sh -f general/compute/first.sim -# liao ./test.sh -f general/compute/interval.sim +./test.sh -f general/compute/interval.sim ./test.sh -f general/compute/last.sim ./test.sh -f general/compute/leastsquare.sim ./test.sh -f general/compute/max.sim @@ -43,23 +43,29 @@ cd ../../../debug; make ./test.sh -f general/compute/sum.sim ./test.sh -f general/compute/top.sim +./test.sh -f general/db/alter_option.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim +./test.sh -f general/db/alter_vgroups.sim ./test.sh -f general/db/basic.sim ./test.sh -f general/db/basic1.sim ./test.sh -f general/db/basic2.sim ./test.sh -f general/db/basic3.sim ./test.sh -f general/db/basic4.sim ./test.sh -f general/db/basic5.sim -./test.sh -f general/db/delete.sim ./test.sh -f general/db/delete_reuse1.sim ./test.sh -f general/db/delete_reuse2.sim ./test.sh -f general/db/delete_reusevnode.sim ./test.sh -f general/db/delete_reusevnode2.sim ./test.sh -f general/db/delete_writing1.sim ./test.sh -f general/db/delete_writing2.sim +./test.sh -f general/db/delete.sim +./test.sh -f general/db/dropdnodes.sim ./test.sh -f general/db/len.sim -#liao ./test.sh -f general/db/vnodes.sim ./test.sh -f general/db/repeat.sim ./test.sh -f general/db/tables.sim +./test.sh -f general/db/vnodes.sim ./test.sh -f general/field/2.sim ./test.sh -f general/field/3.sim @@ -85,10 +91,10 @@ cd ../../../debug; make ./test.sh -f general/import/basic.sim ./test.sh -f general/import/commit.sim ./test.sh -f general/import/large.sim -#liao ./test.sh -f general/import/replica1.sim +./test.sh -f general/import/replica1.sim ./test.sh -f general/insert/basic.sim -#liao ./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/insert_drop.sim ./test.sh -f general/insert/query_block1_memory.sim ./test.sh -f general/insert/query_block2_memory.sim ./test.sh -f general/insert/query_block1_file.sim @@ -103,34 +109,34 @@ cd ../../../debug; make ./test.sh -f general/parser/auto_create_tb.sim ./test.sh -f general/parser/auto_create_tb_drop_tb.sim ./test.sh -f general/parser/col_arithmetic_operation.sim -./test.sh -f general/parser/columnValue.sim +#/test.sh -f general/parser/columnValue.sim ./test.sh -f general/parser/commit.sim # ./test.sh -f general/parser/create_db.sim -# ./test.sh -f general/parser/create_mt.sim -# ./test.sh -f general/parser/create_tb.sim -# ./test.sh -f general/parser/dbtbnameValidate.sim +./test.sh -f general/parser/create_mt.sim +./test.sh -f general/parser/create_tb.sim +./test.sh -f general/parser/dbtbnameValidate.sim ./test.sh -f general/parser/import_commit1.sim ./test.sh -f general/parser/import_commit2.sim ./test.sh -f general/parser/import_commit3.sim -# ./test.sh -f general/parser/insert_tb.sim -# ./test.sh -f general/parser/first_last.sim +./test.sh -f general/parser/insert_tb.sim +./test.sh -f general/parser/first_last.sim # ./test.sh -f general/parser/import_file.sim -# ./test.sh -f general/parser/lastrow.sim +./test.sh -f general/parser/lastrow.sim # ./test.sh -f general/parser/nchar.sim # ./test.sh -f general/parser/null_char.sim -# ./test.sh -f general/parser/single_row_in_tb.sim +./test.sh -f general/parser/single_row_in_tb.sim ./test.sh -f general/parser/select_from_cache_disk.sim -# ./test.sh -f general/parser/limit.sim +./test.sh -f general/parser/limit.sim # ./test.sh -f general/parser/fill.sim # ./test.sh -f general/parser/fill_stb.sim # ./test.sh -f general/parser/tags_dynamically_specifiy.sim # ./test.sh -f general/parser/interp.sim -# ./test.sh -f general/parser/limit1.sim -# ./test.sh -f general/parser/limit1_tblocks100.sim +./test.sh -f general/parser/limit1.sim +./test.sh -f general/parser/limit1_tblocks100.sim # ./test.sh -f general/parser/limit2.sim -# ./test.sh -f general/parser/mixed_blocks.sim -# ./test.sh -f general/parser/selectResNum.sim -# ./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/mixed_blocks.sim +./test.sh -f general/parser/selectResNum.sim +./test.sh -f general/parser/select_across_vnodes.sim # ./test.sh -f general/parser/set_tag_vals.sim # ./test.sh -f general/parser/slimit.sim ./test.sh -f general/parser/slimit1.sim @@ -150,7 +156,7 @@ cd ../../../debug; make #./test.sh -f general/parser/bug.sim ./test.sh -f general/stable/disk.sim -#liao ./test.sh -f general/stable/dnode3.sim +./test.sh -f general/stable/dnode3.sim ./test.sh -f general/stable/metrics.sim ./test.sh -f general/stable/values.sim ./test.sh -f general/stable/vnode3.sim @@ -170,7 +176,7 @@ cd ../../../debug; make ./test.sh -f general/table/db.table.sim ./test.sh -f general/table/delete_reuse1.sim ./test.sh -f general/table/delete_reuse2.sim -#hongze ./test.sh -f general/table/delete_writing.sim +#liao ./test.sh -f general/table/delete_writing.sim ./test.sh -f general/table/describe.sim ./test.sh -f general/table/double.sim ./test.sh -f general/table/fill.sim @@ -241,8 +247,8 @@ cd ../../../debug; make ./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_len.sim -#liao wait ./test.sh -u -f unique/big/balance.sim -#liao wait ./test.sh -u -f unique/big/maxvnodes.sim +./test.sh -u -f unique/big/balance.sim +./test.sh -u -f unique/big/maxvnodes.sim ./test.sh -u -f unique/big/tcp.sim ./test.sh -u -f unique/cluster/balance1.sim @@ -252,15 +258,15 @@ cd ../../../debug; make ./test.sh -u -f unique/column/replica3.sim -#liao wait ./test.sh -u -f unique/db/commit.sim +./test.sh -u -f unique/db/commit.sim ./test.sh -u -f unique/db/delete.sim ./test.sh -u -f unique/db/delete_part.sim ./test.sh -u -f unique/db/replica_add12.sim -#hongze ./test.sh -u -f unique/db/replica_add13.sim -#hongze wait ./test.sh -u -f unique/db/replica_add23.sim -#hongze wait ./test.sh -u -f unique/db/replica_reduce21.sim +./test.sh -u -f unique/db/replica_add13.sim +./test.sh -u -f unique/db/replica_add23.sim +./test.sh -u -f unique/db/replica_reduce21.sim ./test.sh -u -f unique/db/replica_reduce32.sim -#hongze wait /test.sh -u -f unique/db/replica_reduce31.sim +./test.sh -u -f unique/db/replica_reduce31.sim ./test.sh -u -f unique/db/replica_part.sim ./test.sh -u -f unique/dnode/balance1.sim @@ -268,25 +274,25 @@ cd ../../../debug; make ./test.sh -u -f unique/dnode/balance3.sim ./test.sh -u -f unique/dnode/balancex.sim ./test.sh -u -f unique/dnode/offline1.sim -#hongze wait ./test.sh -u -f unique/dnode/offline2.sim +./test.sh -u -f unique/dnode/offline2.sim ./test.sh -u -f unique/dnode/remove1.sim -#hongze ./test.sh -u -f unique/dnode/remove2.sim +./test.sh -u -f unique/dnode/remove2.sim ./test.sh -u -f unique/dnode/vnode_clean.sim ./test.sh -u -f unique/http/admin.sim ./test.sh -u -f unique/http/opentsdb.sim -#liao wait ./test.sh -u -f unique/import/replica2.sim -#liao wait ./test.sh -u -f unique/import/replica3.sim +./test.sh -u -f unique/import/replica2.sim +./test.sh -u -f unique/import/replica3.sim -#liao wait ./test.sh -u -f unique/stable/balance_replica1.sim -#liao wait ./test.sh -u -f unique/stable/dnode2_stop.sim -#liao wait ./test.sh -u -f unique/stable/dnode2.sim -#liao wait ./test.sh -u -f unique/stable/dnode3.sim -#liao wait ./test.sh -u -f unique/stable/replica2_dnode4.sim -#liao wait ./test.sh -u -f unique/stable/replica2_vnode3.sim -#liao wait ./test.sh -u -f unique/stable/replica3_dnode6.sim -#liao wait ./test.sh -u -f unique/stable/replica3_vnode3.sim +./test.sh -u -f unique/stable/balance_replica1.sim +./test.sh -u -f unique/stable/dnode2_stop.sim +./test.sh -u -f unique/stable/dnode2.sim +./test.sh -u -f unique/stable/dnode3.sim +./test.sh -u -f unique/stable/replica2_dnode4.sim +./test.sh -u -f unique/stable/replica2_vnode3.sim +./test.sh -u -f unique/stable/replica3_dnode6.sim +./test.sh -u -f unique/stable/replica3_vnode3.sim ./test.sh -u -f unique/mnode/mgmt22.sim ./test.sh -u -f unique/mnode/mgmt23.sim diff --git a/tests/script/jenkins/sync.txt b/tests/script/jenkins/sync.txt new file mode 100644 index 0000000000000000000000000000000000000000..934680b7c0c42974a40025afd6f0226e1a6ccf9c --- /dev/null +++ b/tests/script/jenkins/sync.txt @@ -0,0 +1,79 @@ +cd ../../debug; cmake .. +cd ../../debug; make +cd ../../../debug; cmake .. +cd ../../../debug; make + +./test.sh -u -f unique/account/account_create.sim +./test.sh -u -f unique/account/account_delete.sim +./test.sh -u -f unique/account/account_len.sim +./test.sh -u -f unique/account/authority.sim +./test.sh -u -f unique/account/basic.sim +./test.sh -u -f unique/account/paras.sim +./test.sh -u -f unique/account/pass_alter.sim +./test.sh -u -f unique/account/pass_len.sim +./test.sh -u -f unique/account/usage.sim +./test.sh -u -f unique/account/user_create.sim +./test.sh -u -f unique/account/user_len.sim + +./test.sh -u -f unique/big/balance.sim +./test.sh -u -f unique/big/maxvnodes.sim +./test.sh -u -f unique/big/tcp.sim + +./test.sh -u -f unique/cluster/balance1.sim +./test.sh -u -f unique/cluster/balance2.sim +./test.sh -u -f unique/cluster/balance3.sim +./test.sh -u -f unique/cluster/cache.sim + +./test.sh -u -f unique/column/replica3.sim + +./test.sh -u -f unique/db/commit.sim +./test.sh -u -f unique/db/delete.sim +./test.sh -u -f unique/db/delete_part.sim +./test.sh -u -f unique/db/replica_add12.sim +./test.sh -u -f unique/db/replica_add13.sim +./test.sh -u -f unique/db/replica_add23.sim +./test.sh -u -f unique/db/replica_reduce21.sim +./test.sh -u -f unique/db/replica_reduce32.sim +./test.sh -u -f unique/db/replica_reduce31.sim +./test.sh -u -f unique/db/replica_part.sim + +./test.sh -u -f unique/dnode/balance1.sim +./test.sh -u -f unique/dnode/balance2.sim +./test.sh -u -f unique/dnode/balance3.sim +./test.sh -u -f unique/dnode/balancex.sim +./test.sh -u -f unique/dnode/offline1.sim +./test.sh -u -f unique/dnode/offline2.sim +./test.sh -u -f unique/dnode/remove1.sim +./test.sh -u -f unique/dnode/remove2.sim +./test.sh -u -f unique/dnode/vnode_clean.sim + +./test.sh -u -f unique/http/admin.sim +./test.sh -u -f unique/http/opentsdb.sim + +./test.sh -u -f unique/import/replica2.sim +./test.sh -u -f unique/import/replica3.sim + +./test.sh -u -f unique/stable/balance_replica1.sim +./test.sh -u -f unique/stable/dnode2_stop.sim +./test.sh -u -f unique/stable/dnode2.sim +./test.sh -u -f unique/stable/dnode3.sim +./test.sh -u -f unique/stable/replica2_dnode4.sim +./test.sh -u -f unique/stable/replica2_vnode3.sim +./test.sh -u -f unique/stable/replica3_dnode6.sim +./test.sh -u -f unique/stable/replica3_vnode3.sim + +./test.sh -u -f unique/mnode/mgmt22.sim +./test.sh -u -f unique/mnode/mgmt23.sim +./test.sh -u -f unique/mnode/mgmt24.sim +./test.sh -u -f unique/mnode/mgmt25.sim +./test.sh -u -f unique/mnode/mgmt26.sim +./test.sh -u -f unique/mnode/mgmt33.sim +./test.sh -u -f unique/mnode/mgmt34.sim +./test.sh -u -f unique/mnode/mgmtr2.sim + +./test.sh -u -f unique/vnode/many.sim +./test.sh -u -f unique/vnode/replica2_basic2.sim +./test.sh -u -f unique/vnode/replica2_repeat.sim +./test.sh -u -f unique/vnode/replica3_basic.sim +./test.sh -u -f unique/vnode/replica3_repeat.sim +./test.sh -u -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index bd85ce9704945c26ea75ba663a66a735038bb971..83ecea555a8c85eebadfd19fade5fd17340b237e 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -107,6 +107,7 @@ echo "monitorDebugFlag 131" >> $TAOS_CFG echo "udebugFlag 131" >> $TAOS_CFG echo "jnidebugFlag 131" >> $TAOS_CFG echo "sdebugFlag 135" >> $TAOS_CFG +echo "qdebugFlag 135" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG diff --git a/tests/script/tjenkins b/tests/script/tjenkins index b05ab3c9009be2c79e47f69e4df877cf009bf8c1..9b93527de97f29f84e2b1e6b2ec2ab4a621f6709 100755 Binary files a/tests/script/tjenkins and b/tests/script/tjenkins differ diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 68a05a33e75e0716d83c21da3aade66a16ca472a..1db643c5c9c198e103aa0429b06cf6b5848ea960 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -23,4 +23,8 @@ system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 \ No newline at end of file +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode3 -c http -v 1 \ No newline at end of file diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index 4b0a6cd0bf25f1ad4a279ab9150adf1f114b3b60..5259f415c88da90c99372ee2f81786d2743fddbc 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -93,7 +93,7 @@ $x = 0 show1: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi @@ -107,6 +107,9 @@ if $data2_2 != 2 then goto show1 endi +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -149,7 +152,7 @@ $x = 0 show3: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi @@ -160,7 +163,7 @@ print dnode3 freeVnodes $data2_3 if $data2_1 != 2 then goto show3 endi -if $data2_2 != NULL then +if $data2_2 != null then goto show3 endi if $data2_3 != 2 then @@ -169,6 +172,9 @@ endi system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -206,22 +212,25 @@ $x = 0 show4: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 freeVnodes $data2_1 print dnode3 freeVnodes $data2_3 -if $data2_1 != 0 then +if $data2_1 != 4 then goto show4 endi -if $data2_3 != NULL then +if $data2_3 != null then goto show4 endi system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -253,28 +262,33 @@ if $data00 != $totalNum then endi print ========== step5 -sql alter database db replica 2 -sql create dnode $hostname4 system sh/exec_up.sh -n dnode4 -s start +sql create dnode $hostname4 + +sleep 3000 +sql alter database db replica 2 $x = 0 show5: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 freeVnodes $data2_1 print dnode4 freeVnodes $data2_4 -if $data2_1 != 0 then +if $data2_1 != 4 then goto show5 endi -if $data2_4 != 0 then +if $data2_4 != 4 then goto show5 endi +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index 2b56f51e599f72e9c2bf62251e82aff675722af1..f019ea607c6b1097e12e2aa788c8b69656ce23cf 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh -$totalVnodes = 100 -$minVnodes = 50 -$maxVnodes = 50 +$totalVnodes = 20 +$minVnodes = 10 +$maxVnodes = 10 $maxTables = 4 $totalRows = $totalVnodes * $maxTables diff --git a/tests/script/unique/big/restartSpeed.sim b/tests/script/unique/big/restartSpeed.sim new file mode 100644 index 0000000000000000000000000000000000000000..5ab77f5fa6be4ade4565493fb446c98fa7f3a0b4 --- /dev/null +++ b/tests/script/unique/big/restartSpeed.sim @@ -0,0 +1,43 @@ +system sh/stop_dnodes.sh + +$totalVnodes = 20 +$minVnodes = 10 +$maxVnodes = 10 +$maxTables = 4 +$totalRows = $totalVnodes * $maxTables + +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 numOfTotalVnodes -v $totalVnodes +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v $totalVnodes + + +print ========== prepare data +system sh/exec_up.sh -n dnode1 -s start +sleep 3000 +sql connect +sql create database db blocks 2 cache 1 maxTables $maxTables +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$x = 0 +while $x < $totalRows + $tb = t . $x + sql create table $tb using mt tags( $x ) + sql insert into $tb values (now, $x ) + $x = $x + 1 +endw + + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/column/replica3.sim b/tests/script/unique/column/replica3.sim index 4b08b13e2fb08f36e5e19886d5acf02dfdb98e3c..4e45edc02d142f056d2f1593c78831d94fddf071 100644 --- a/tests/script/unique/column/replica3.sim +++ b/tests/script/unique/column/replica3.sim @@ -29,6 +29,10 @@ while $x < 1010 $x = $x + 1 endw +sql_error create database d1 replica 2 wal 0 +sql create database d2 replica 1 wal 0 +sql_error alter database d2 replica 2 + system sh/exec_up.sh -n dnode1 -s stop -x SIGINT system sh/exec_up.sh -n dnode2 -s stop -x SIGINT system sh/exec_up.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/unique/db/replica_add23.sim b/tests/script/unique/db/replica_add23.sim index 995cd4116c307b5c0fe9cb37f7993d724da3cd70..2d293183af197379f2a541fc0a2662dc26c8d1cb 100644 --- a/tests/script/unique/db/replica_add23.sim +++ b/tests/script/unique/db/replica_add23.sim @@ -47,10 +47,10 @@ sql create table d2.t2 (ts timestamp, i int) sql create table d3.t3 (ts timestamp, i int) sql create table d4.t4 (ts timestamp, i int) -sql insert into d1.t1 values(now, 1) -sql insert into d2.t2 values(now, 1) -sql insert into d3.t3 values(now, 1) -sql insert into d4.t4 values(now, 1) +sql insert into d1.t1 values(1588262400001, 1) +sql insert into d2.t2 values(1588262400001, 1) +sql insert into d3.t3 values(1588262400001, 1) +sql insert into d4.t4 values(1588262400001, 1) sql select * from d1.t1 if $rows != 1 then @@ -111,10 +111,10 @@ if $data2_3 != 4 then endi print ======== step4 -sql insert into d1.t1 values(now, 2) -sql insert into d2.t2 values(now, 2) -sql insert into d3.t3 values(now, 2) -sql insert into d4.t4 values(now, 2) +sql insert into d1.t1 values(1588262400002, 2) +sql insert into d2.t2 values(1588262400002, 2) +sql insert into d3.t3 values(1588262400002, 2) +sql insert into d4.t4 values(1588262400002, 2) sql select * from d1.t1 if $rows != 2 then @@ -143,10 +143,10 @@ print ========= step5 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 -sql insert into d1.t1 values(now, 3) -sql insert into d2.t2 values(now, 3) -sql insert into d3.t3 values(now, 3) -sql insert into d4.t4 values(now, 3) +sql insert into d1.t1 values(1588262400003, 3) +sql insert into d2.t2 values(1588262400003, 3) +sql insert into d3.t3 values(1588262400003, 3) +sql insert into d4.t4 values(1588262400003, 3) sql select * from d1.t1 if $rows != 3 then @@ -174,10 +174,10 @@ sleep 5000 system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 5000 -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) +sql insert into d1.t1 values(1588262400004, 4) +sql insert into d2.t2 values(1588262400004, 4) +sql insert into d3.t3 values(1588262400004, 4) +sql insert into d4.t4 values(1588262400004, 4) sql select * from d1.t1 if $rows != 4 then @@ -205,10 +205,10 @@ sleep 5000 system sh/exec_up.sh -n dnode4 -s stop -x SIGINT sleep 5000 -sql insert into d1.t1 values(now, 5) -sql insert into d2.t2 values(now, 5) -sql insert into d3.t3 values(now, 5) -sql insert into d4.t4 values(now, 5) +sql insert into d1.t1 values(1588262400005, 5) +sql insert into d2.t2 values(1588262400005, 5) +sql insert into d3.t3 values(1588262400005, 5) +sql insert into d4.t4 values(1588262400005, 5) sql select * from d1.t1 if $rows != 5 then @@ -236,10 +236,10 @@ sleep 5000 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 -sql insert into d1.t1 values(now, 6) -sql insert into d2.t2 values(now, 6) -sql insert into d3.t3 values(now, 6) -sql insert into d4.t4 values(now, 6) +sql insert into d1.t1 values(1588262400006, 6) +sql insert into d2.t2 values(1588262400006, 6) +sql insert into d3.t3 values(1588262400006, 6) +sql insert into d4.t4 values(1588262400006, 6) sql select * from d1.t1 if $rows != 6 then diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim index c526e45b6e44e3a7fc387e0b2430a52e85806829..9d8ba8bf9d15442a271f9d2755fce6f3f28a274e 100644 --- a/tests/script/unique/dnode/offline2.sim +++ b/tests/script/unique/dnode/offline2.sim @@ -29,7 +29,7 @@ sleep 3000 sql create database d1 replica 2 maxTables 4 sql create table d1.t1(ts timestamp, i int) -sql insert into d1.t1 values(now, 1) +sql insert into d1.t1 values(1588262400001, 1) sql show dnodes print dnode1 $data4_1 diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim index 77ec1fa630d409b391f72b7733959c1eee29059d..42cb9e5485b2a65b67b29bccff99f73055056ed0 100644 --- a/tests/script/unique/dnode/remove2.sim +++ b/tests/script/unique/dnode/remove2.sim @@ -22,19 +22,19 @@ sql connect sql create database d1 maxTables 4 sql create table d1.t1 (t timestamp, i int) -sql insert into d1.t1 values(now+1s, 15) -sql insert into d1.t1 values(now+2s, 14) -sql insert into d1.t1 values(now+3s, 13) -sql insert into d1.t1 values(now+4s, 12) -sql insert into d1.t1 values(now+5s, 11) +sql insert into d1.t1 values(1588262400001, 15) +sql insert into d1.t1 values(1588262400002, 14) +sql insert into d1.t1 values(1588262400003, 13) +sql insert into d1.t1 values(1588262400004, 12) +sql insert into d1.t1 values(1588262400005, 11) sql create database d2 maxTables 4 sql create table d2.t2 (t timestamp, i int) -sql insert into d2.t2 values(now+1s, 25) -sql insert into d2.t2 values(now+2s, 24) -sql insert into d2.t2 values(now+3s, 23) -sql insert into d2.t2 values(now+4s, 22) -sql insert into d2.t2 values(now+5s, 21) +sql insert into d2.t2 values(1588262400001, 25) +sql insert into d2.t2 values(1588262400002, 24) +sql insert into d2.t2 values(1588262400003, 23) +sql insert into d2.t2 values(1588262400004, 22) +sql insert into d2.t2 values(1588262400005, 21) sql show dnodes print dnode1 openVnodes $data2_1 @@ -49,11 +49,11 @@ sleep 9000 sql create database d3 replica 2 maxTables 4 sql create table d3.t3 (t timestamp, i int) -sql insert into d3.t3 values(now+1s, 35) -sql insert into d3.t3 values(now+2s, 34) -sql insert into d3.t3 values(now+3s, 33) -sql insert into d3.t3 values(now+4s, 32) -sql insert into d3.t3 values(now+5s, 31) +sql insert into d3.t3 values(1588262400001, 35) +sql insert into d3.t3 values(1588262400002, 34) +sql insert into d3.t3 values(1588262400003, 33) +sql insert into d3.t3 values(1588262400004, 32) +sql insert into d3.t3 values(1588262400005, 31) $x = 0 show2: @@ -111,10 +111,10 @@ sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_2 != null then +if $data2_1 != 1 then goto show4 endi -if $data2_1 != 1 then +if $data2_2 != null then goto show4 endi if $data2_3 != 3 then diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim index bcb4179c12b1b3f9045a4690e7ecaa5685aa1f1e..70097a50221195b4f7bee6d7e5f54572faa509a3 100644 --- a/tests/script/unique/import/replica2.sim +++ b/tests/script/unique/import/replica2.sim @@ -20,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec_up.sh -n dnode1 -s start @@ -35,10 +35,10 @@ system sh/exec_up.sh -n dnode2 -s start sql create database ir2db replica 2 days 7 sql use ir2db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -46,7 +46,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -54,7 +54,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -62,9 +62,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -72,10 +72,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -83,11 +83,11 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then @@ -105,25 +105,26 @@ if $rows != 14 then endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows -if $rows != 19 then +if $rows != 19 then + print expect 19, actual: $rows return -1 endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows -if $rows != 24 then +if $rows != 23 then return -1 endi @@ -142,21 +143,21 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi @@ -167,55 +168,57 @@ system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; -if $rows != 41 then +if $rows != 40 then return -1 endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows -if $rows != 50 then +if $rows != 49 then return -1 endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode2 -s start sleep 5000 print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; -if $rows != 50 then +if $rows != 52 then return -1 endi print ================= step15 -system sh/exec_up.sh -n dnode2 -s start -sleep 8000 -system sh/exec_up.sh -n dnode1 -s stop -sleep 10000 +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode1 -s start +sleep 5000 -if $rows != 50 then +if $rows != 52 then return -1 endi diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim index 8d70d227a5033b837bb0faf3940b18f81ed0be38..ad236bfb0cae4a821b757d93d0f04285439f0f7b 100644 --- a/tests/script/unique/import/replica3.sim +++ b/tests/script/unique/import/replica3.sim @@ -20,14 +20,14 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec_up.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql connect sql create dnode $hostname2 @@ -38,10 +38,10 @@ system sh/exec_up.sh -n dnode3 -s start sql create database ir3db replica 3 days 7 sql use ir3db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -49,7 +49,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -57,7 +57,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -65,9 +65,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -75,10 +75,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -86,47 +86,48 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then return -1 endi -#print ================== dnode restart -#system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -#sleep 5000 -#system sh/exec_up.sh -n dnode1 -s start -#sleep 5000 -#sql select * from tb; -#if $rows != 14 then -# return -1 -#endi +print ================== dnode restart +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode1 -s start +sleep 5000 +sql select * from tb; +if $rows != 14 then + return -1 +endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows -if $rows != 19 then +if $rows != 19 then + print expect 19, actual: $rows return -1 endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows -if $rows != 24 then +if $rows != 23 then return -1 endi @@ -145,21 +146,21 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi @@ -170,55 +171,57 @@ system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; -if $rows != 41 then +if $rows != 40 then return -1 endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows -if $rows != 50 then +if $rows != 49 then return -1 endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode2 -s start sleep 5000 print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; -if $rows != 50 then +if $rows != 52 then return -1 endi print ================= step15 -system sh/exec_up.sh -n dnode2 -s start -sleep 8000 -system sh/exec_up.sh -n dnode3 -s stop -sleep 3000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode3 -s start +sleep 5000 -if $rows != 50 then +if $rows != 52 then return -1 endi diff --git a/tests/script/unique/stable/balance_replica1.sim b/tests/script/unique/stable/balance_replica1.sim index 8cf41319a020d201af62d4a775737aac679f9bba..9257ba79beeea5060ed8b4b7dc38e0ad7721c59b 100644 --- a/tests/script/unique/stable/balance_replica1.sim +++ b/tests/script/unique/stable/balance_replica1.sim @@ -7,8 +7,8 @@ system sh/cfg.sh -n dnode1 -c statusInterval -v 1 system sh/cfg.sh -n dnode2 -c statusInterval -v 1 system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 @@ -60,20 +60,20 @@ print =============== step2 $x = 0 show1: $x = $x + 1 - sleep 1000 - if $x == 20 then + sleep 2000 + if $x == 10 then return -1 endi sql show dnodes -x show1 -$dnode1Vnodes = $data3_192.168.0.1 +$dnode1Vnodes = $data2_1 print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data3_192.168.0.2 +$dnode2Vnodes = $data2_2 print dnode2 $dnode2Vnodes -if $dnode1Vnodes != 0 then +if $dnode1Vnodes != 4 then goto show1 endi -if $dnode2Vnodes != NULL then +if $dnode2Vnodes != null then goto show1 endi print =============== step3 start dnode2 @@ -89,9 +89,9 @@ show2: return -1 endi sql show dnodes -x show2 -$dnode1Vnodes = $data3_192.168.0.1 +$dnode1Vnodes = $data2_1 print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data3_192.168.0.2 +$dnode2Vnodes = $data2_2 print dnode2 $dnode2Vnodes if $dnode1Vnodes != 2 then diff --git a/tests/script/unique/stable/dnode2_stop.sim b/tests/script/unique/stable/dnode2_stop.sim index 55ad5fcf094bb35cd399762bbce23e3b0b390d4b..0cf13fa286b7ff332f609ed88fe3504347046642 100644 --- a/tests/script/unique/stable/dnode2_stop.sim +++ b/tests/script/unique/stable/dnode2_stop.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 diff --git a/tests/script/unique/stable/dnode3.sim b/tests/script/unique/stable/dnode3.sim index c9dd31f6f80421791f4b2fecf34d58e2205383d8..8025b180d898014d16b2450a0acc4ff63eaf8162 100644 --- a/tests/script/unique/stable/dnode3.sim +++ b/tests/script/unique/stable/dnode3.sim @@ -84,13 +84,13 @@ print dnode2 $dnode2Vnodes $dnode3Vnodes = $data2_3 print dnode3 $dnode3Vnodes -if $dnode1Vnodes != 3 then +if $dnode1Vnodes != 1 then return -1 endi -if $dnode2Vnodes != 3 then +if $dnode2Vnodes != 1 then return -1 endi -if $dnode3Vnodes != 3 then +if $dnode3Vnodes != 1 then return -1 endi diff --git a/tests/script/unique/stable/replica2_dnode4.sim b/tests/script/unique/stable/replica2_dnode4.sim index f204e059491b63e79008a9d54b2e1934b9f28072..b96535fccd4f89a1472964d5d22823c953102f46 100644 --- a/tests/script/unique/stable/replica2_dnode4.sim +++ b/tests/script/unique/stable/replica2_dnode4.sim @@ -3,10 +3,10 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 diff --git a/tests/script/unique/stable/replica2_vnode3.sim b/tests/script/unique/stable/replica2_vnode3.sim index 238e2e4aee36c3311cb57a6c16e270db1a9e8195..c7882d7a960077c20b935b8a3e5c2dafb2610a7e 100644 --- a/tests/script/unique/stable/replica2_vnode3.sim +++ b/tests/script/unique/stable/replica2_vnode3.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 diff --git a/tests/script/unique/stable/replica3_dnode6.sim b/tests/script/unique/stable/replica3_dnode6.sim index 1c8a8ae10ecb817fef4a1f72518caa30c4da197d..0dc81999ca63b3c9551980fa84f451ee8d86c8ca 100644 --- a/tests/script/unique/stable/replica3_dnode6.sim +++ b/tests/script/unique/stable/replica3_dnode6.sim @@ -6,12 +6,12 @@ system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode5 -i 5 system sh/deploy.sh -n dnode6 -i 6 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 -system sh/cfg.sh -n dnode5 -c walLevel -v 0 -system sh/cfg.sh -n dnode6 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 +system sh/cfg.sh -n dnode5 -c walLevel -v 2 +system sh/cfg.sh -n dnode6 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 diff --git a/tests/script/unique/stable/replica3_vnode3.sim b/tests/script/unique/stable/replica3_vnode3.sim index 75870af4c43de82dc99ba375a0035040bf249d9e..fe310aa0f7e5136db9517866b23c5a666674ce08 100644 --- a/tests/script/unique/stable/replica3_vnode3.sim +++ b/tests/script/unique/stable/replica3_vnode3.sim @@ -4,10 +4,10 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 diff --git a/tests/test-all.sh b/tests/test-all.sh index e58a6f51327c066b526d0332a2c7b1678d7cc4d4..a56b5eeef7fcb7c306318a81655c8656a78e4843 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -33,14 +33,13 @@ echo "### run Python script ###" cd ../pytest if [ "$1" == "cron" ]; then - ./fulltest.sh > /dev/null | tee pytest-out.txt + ./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt else - ./smoketest.sh > /dev/null | tee pytest-out.txt + ./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt fi totalPySuccess=`grep 'successfully executed' pytest-out.txt | wc -l` if [ "$totalPySuccess" -gt "0" ]; then - grep 'successfully executed' pytest-out.txt echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" fi