diff --git a/Jenkinsfile2 b/Jenkinsfile2 index f582461fb2..f618912295 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -338,6 +338,14 @@ pipeline { changeRequest() } steps { + script { + def linux_node_ip = sh ( + script: 'ip addr|grep 192|grep -v virbr|awk "{print \\\$2}"|sed "s/\\/.*//"', + returnStdout: true + ).trim() + echo "${linux_node_ip}" + echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" + } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { timeout(time: 120, unit: 'MINUTES'){ pre_test() diff --git a/cmake/cmake.install b/cmake/cmake.install index b2421fac25..27edd8e27a 100644 --- a/cmake/cmake.install +++ b/cmake/cmake.install @@ -13,6 +13,7 @@ ELSEIF (TD_WINDOWS) INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg) INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.h DESTINATION include) INSTALL(FILES ${TD_SOURCE_DIR}/include/util/taoserror.h DESTINATION include) + INSTALL(FILES ${TD_SOURCE_DIR}/include/libs/function/taosudf.h DESTINATION include) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos_static.lib DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) diff --git a/include/client/taos.h b/include/client/taos.h index 5e7f12de0a..d31d5c582c 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -128,6 +128,7 @@ typedef struct setConfRet { DLL_EXPORT void taos_cleanup(void); DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); +DLL_EXPORT setConfRet taos_set_config(const char *config); DLL_EXPORT int taos_init(void); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 2e2c7d1700..6653fdd9cd 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -236,7 +236,7 @@ void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* int8_t needCompress); const char* blockCompressDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData); -void blockDebugShowData(const SArray* dataBlocks, const char* flag); +void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag); // for debug char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf); diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index f9ede63f7f..8f7f22a6a0 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -78,7 +78,6 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove -void debugCheckTags(STag *pTag); // TODO: remove // STRUCT ================= struct STColumn { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a5688af18a..c5b0b89311 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1886,7 +1886,7 @@ typedef struct SVCreateStbReq { int8_t rollup; SSchemaWrapper schemaRow; SSchemaWrapper schemaTag; - SRSmaParam pRSmaParam; + SRSmaParam rsmaParam; } SVCreateStbReq; int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq); diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h new file mode 100644 index 0000000000..5e84b87a81 --- /dev/null +++ b/include/libs/function/taosudf.h @@ -0,0 +1,266 @@ +/* +* 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_TAOSUDF_H +#define TDENGINE_TAOSUDF_H + +#include +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) +#define FORCE_INLINE inline __attribute__((always_inline)) +#else +#define FORCE_INLINE +#endif +typedef struct SUdfColumnMeta { + int16_t type; + int32_t bytes; + uint8_t precision; + uint8_t scale; +} SUdfColumnMeta; + +typedef struct SUdfColumnData { + int32_t numOfRows; + int32_t rowsAlloc; + union { + struct { + int32_t nullBitmapLen; + char *nullBitmap; + int32_t dataLen; + char *data; + } fixLenCol; + + struct { + int32_t varOffsetsLen; + int32_t *varOffsets; + int32_t payloadLen; + char *payload; + int32_t payloadAllocLen; + } varLenCol; + }; +} SUdfColumnData; + + +typedef struct SUdfColumn { + SUdfColumnMeta colMeta; + bool hasNull; + SUdfColumnData colData; +} SUdfColumn; + +typedef struct SUdfDataBlock { + int32_t numOfRows; + int32_t numOfCols; + SUdfColumn **udfCols; +} SUdfDataBlock; + +typedef struct SUdfInterBuf { + int32_t bufLen; + char* buf; + int8_t numOfResult; //zero or one +} SUdfInterBuf; +typedef void *UdfcFuncHandle; + +// dynamic lib init and destroy +typedef int32_t (*TUdfInitFunc)(); +typedef int32_t (*TUdfDestroyFunc)(); + +#define UDF_MEMORY_EXP_GROWTH 1.5 +#define NBIT (3u) +#define BitPos(_n) ((_n) & ((1 << NBIT) - 1)) +#define BMCharPos(bm_, r_) ((bm_)[(r_) >> NBIT]) +#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) + +#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) +#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) +#define udfColDataSetNull_f(pColumn, row) \ + do { \ + BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ + } while (0) + +#define udfColDataSetNotNull_f(pColumn, r_) \ + do { \ + BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ + } while (0) +#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) + +typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 +#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) +#define varDataLen(v) ((VarDataLenT *)(v))[0] +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) +#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v)) +#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE)) +#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len)) +#define IS_VAR_DATA_TYPE(t) \ + (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) +#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) + + +static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) { + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; + } else { + return pColumn->colData.fixLenCol.data + pColumn->colMeta.bytes * row; + } +} + +static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { + if (udfColDataIsNull_var(pColumn, row)) { + return true; + } + char* data = udfColDataGetData(pColumn, row); + return (*data == TSDB_DATA_TYPE_NULL); + } else { + return udfColDataIsNull_var(pColumn, row); + } + } else { + return udfColDataIsNull_f(pColumn, row); + } +} + +static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { + SUdfColumnMeta *meta = &pColumn->colMeta; + SUdfColumnData *data = &pColumn->colData; + + if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { + return TSDB_CODE_SUCCESS; + } + + int allocCapacity = (data->rowsAlloc< 8) ? 8 : data->rowsAlloc; + while (allocCapacity < newCapacity) { + allocCapacity *= UDF_MEMORY_EXP_GROWTH; + } + + if (IS_VAR_DATA_TYPE(meta->type)) { + char* tmp = (char*)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + data->varLenCol.varOffsets = (int32_t*)tmp; + data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; + // for payload, add data in udfColDataAppend + } else { + char* tmp = (char*)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + data->fixLenCol.nullBitmap = tmp; + data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity); + if (meta->type == TSDB_DATA_TYPE_NULL) { + return TSDB_CODE_SUCCESS; + } + + tmp = (char*)realloc(data->fixLenCol.data, allocCapacity* meta->bytes); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + data->fixLenCol.data = tmp; + data->fixLenCol.dataLen = allocCapacity* meta->bytes; + } + + data->rowsAlloc = allocCapacity; + + return TSDB_CODE_SUCCESS; +} + +static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { + udfColEnsureCapacity(pColumn, row+1); + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + udfColDataSetNull_var(pColumn, row); + } else { + udfColDataSetNull_f(pColumn, row); + } + pColumn->hasNull = true; +} + +static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { + SUdfColumnMeta *meta = &pColumn->colMeta; + SUdfColumnData *data = &pColumn->colData; + udfColEnsureCapacity(pColumn, currentRow+1); + bool isVarCol = IS_VAR_DATA_TYPE(meta->type); + if (isNull) { + udfColDataSetNull(pColumn, currentRow); + } else { + if (!isVarCol) { + udfColDataSetNotNull_f(pColumn, currentRow); + memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes); + } else { + int32_t dataLen = varDataTLen(pData); + if (meta->type == TSDB_DATA_TYPE_JSON) { + if (*pData == TSDB_DATA_TYPE_NULL) { + dataLen = 0; + } else if (*pData == TSDB_DATA_TYPE_NCHAR) { + dataLen = varDataTLen(pData + sizeof(char)); + } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) { + dataLen = sizeof(int64_t); + } else if (*pData == TSDB_DATA_TYPE_BOOL) { + dataLen = sizeof(char); + } + dataLen += sizeof(char); + } + + if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) { + uint32_t newSize = data->varLenCol.payloadAllocLen; + if (newSize <= 1) { + newSize = 8; + } + + while (newSize < data->varLenCol.payloadLen + dataLen) { + newSize = newSize * UDF_MEMORY_EXP_GROWTH; + } + + char *buf = (char*)realloc(data->varLenCol.payload, newSize); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + data->varLenCol.payload = buf; + data->varLenCol.payloadAllocLen = newSize; + } + + uint32_t len = data->varLenCol.payloadLen; + data->varLenCol.varOffsets[currentRow] = len; + + memcpy(data->varLenCol.payload + len, pData, dataLen); + data->varLenCol.payloadLen += dataLen; + } + } + data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow+1) : data->numOfRows; + return 0; +} + +typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); + +typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); +typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); +typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf* buf, SUdfInterBuf *resultData); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_TAOSUDF_H diff --git a/include/libs/function/tudf.h b/include/libs/function/tudf.h index 28b1fbe8ce..b4c05fea87 100644 --- a/include/libs/function/tudf.h +++ b/include/libs/function/tudf.h @@ -16,6 +16,13 @@ #ifndef TDENGINE_TUDF_H #define TDENGINE_TUDF_H +#undef malloc +#define malloc malloc +#undef free +#define free free +#undef realloc +#define alloc alloc +#include #include #include @@ -36,56 +43,6 @@ extern "C" { #endif #define UDF_DNODE_ID_ENV_NAME "DNODE_ID" -//====================================================================================== -//begin API to taosd and qworker - -typedef struct SUdfColumnMeta { - int16_t type; - int32_t bytes; - uint8_t precision; - uint8_t scale; -} SUdfColumnMeta; - -typedef struct SUdfColumnData { - int32_t numOfRows; - int32_t rowsAlloc; - union { - struct { - int32_t nullBitmapLen; - char *nullBitmap; - int32_t dataLen; - char *data; - } fixLenCol; - - struct { - int32_t varOffsetsLen; - int32_t *varOffsets; - int32_t payloadLen; - char *payload; - int32_t payloadAllocLen; - } varLenCol; - }; -} SUdfColumnData; - - -typedef struct SUdfColumn { - SUdfColumnMeta colMeta; - bool hasNull; - SUdfColumnData colData; -} SUdfColumn; - -typedef struct SUdfDataBlock { - int32_t numOfRows; - int32_t numOfCols; - SUdfColumn **udfCols; -} SUdfDataBlock; - -typedef struct SUdfInterBuf { - int32_t bufLen; - char* buf; - int8_t numOfResult; //zero or one -} SUdfInterBuf; -typedef void *UdfcFuncHandle; //low level APIs /** @@ -127,177 +84,6 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t cleanUpUdfs(); -// end API to taosd and qworker -//============================================================================================================================= -// begin API to UDF writer. - -// dynamic lib init and destroy -typedef int32_t (*TUdfInitFunc)(); -typedef int32_t (*TUdfDestroyFunc)(); - -//TODO: add API to check function arguments type, number etc. - -#define UDF_MEMORY_EXP_GROWTH 1.5 - -#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) -#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) -#define udfColDataSetNull_f(pColumn, row) \ - do { \ - BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ - } while (0) - -#define udfColDataSetNotNull_f(pColumn, r_) \ - do { \ - BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ - } while (0) -#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) - - -static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) { - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; - } else { - return pColumn->colData.fixLenCol.data + pColumn->colMeta.bytes * row; - } -} - -static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { - if (udfColDataIsNull_var(pColumn, row)) { - return true; - } - char* data = udfColDataGetData(pColumn, row); - return (*data == TSDB_DATA_TYPE_NULL); - } else { - return udfColDataIsNull_var(pColumn, row); - } - } else { - return udfColDataIsNull_f(pColumn, row); - } -} - -static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { - SUdfColumnMeta *meta = &pColumn->colMeta; - SUdfColumnData *data = &pColumn->colData; - - if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { - return TSDB_CODE_SUCCESS; - } - - int allocCapacity = TMAX(data->rowsAlloc, 8); - while (allocCapacity < newCapacity) { - allocCapacity *= UDF_MEMORY_EXP_GROWTH; - } - - if (IS_VAR_DATA_TYPE(meta->type)) { - char* tmp = taosMemoryRealloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - data->varLenCol.varOffsets = (int32_t*)tmp; - data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; - // for payload, add data in udfColDataAppend - } else { - char* tmp = taosMemoryRealloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - data->fixLenCol.nullBitmap = tmp; - data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity); - if (meta->type == TSDB_DATA_TYPE_NULL) { - return TSDB_CODE_SUCCESS; - } - - tmp = taosMemoryRealloc(data->fixLenCol.data, allocCapacity* meta->bytes); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - data->fixLenCol.data = tmp; - data->fixLenCol.dataLen = allocCapacity* meta->bytes; - } - - data->rowsAlloc = allocCapacity; - - return TSDB_CODE_SUCCESS; -} - -static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { - udfColEnsureCapacity(pColumn, row+1); - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - udfColDataSetNull_var(pColumn, row); - } else { - udfColDataSetNull_f(pColumn, row); - } - pColumn->hasNull = true; -} - -static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { - SUdfColumnMeta *meta = &pColumn->colMeta; - SUdfColumnData *data = &pColumn->colData; - udfColEnsureCapacity(pColumn, currentRow+1); - bool isVarCol = IS_VAR_DATA_TYPE(meta->type); - if (isNull) { - udfColDataSetNull(pColumn, currentRow); - } else { - if (!isVarCol) { - colDataSetNotNull_f(data->fixLenCol.nullBitmap, currentRow); - memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes); - } else { - int32_t dataLen = varDataTLen(pData); - if (meta->type == TSDB_DATA_TYPE_JSON) { - if (*pData == TSDB_DATA_TYPE_NULL) { - dataLen = 0; - } else if (*pData == TSDB_DATA_TYPE_NCHAR) { - dataLen = varDataTLen(pData + CHAR_BYTES); - } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) { - dataLen = LONG_BYTES; - } else if (*pData == TSDB_DATA_TYPE_BOOL) { - dataLen = CHAR_BYTES; - } - dataLen += CHAR_BYTES; - } - - if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) { - uint32_t newSize = data->varLenCol.payloadAllocLen; - if (newSize <= 1) { - newSize = 8; - } - - while (newSize < data->varLenCol.payloadLen + dataLen) { - newSize = newSize * UDF_MEMORY_EXP_GROWTH; - } - - char *buf = taosMemoryRealloc(data->varLenCol.payload, newSize); - if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - data->varLenCol.payload = buf; - data->varLenCol.payloadAllocLen = newSize; - } - - uint32_t len = data->varLenCol.payloadLen; - data->varLenCol.varOffsets[currentRow] = len; - - memcpy(data->varLenCol.payload + len, pData, dataLen); - data->varLenCol.payloadLen += dataLen; - } - } - data->numOfRows = TMAX(currentRow + 1, data->numOfRows); - return 0; -} - -typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); - -typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); -typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); -typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf* buf, SUdfInterBuf *resultData); - - -// end API to UDF writer -//======================================================================================================================= #ifdef __cplusplus } diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index e23b84c1f8..4671c8b81e 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -24,6 +24,8 @@ extern "C" { #include "querynodes.h" #include "tname.h" +#define SLOT_NAME_LEN TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN + typedef struct SLogicNode { ENodeType type; SNodeList* pTargets; // SColumnNode @@ -74,8 +76,8 @@ typedef struct SScanLogicNode { int16_t tsColId; double filesFactor; SArray* pSmaIndexes; - SNodeList* pPartTags; - bool partSort; + SNodeList* pGroupTags; + bool groupSort; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -100,6 +102,8 @@ typedef struct SProjectLogicNode { typedef struct SIndefRowsFuncLogicNode { SLogicNode node; SNodeList* pFuncs; + bool isTailFunc; + bool isUniqueFunc; } SIndefRowsFuncLogicNode; typedef struct SInterpFuncLogicNode { @@ -138,6 +142,7 @@ typedef struct SMergeLogicNode { SNodeList* pInputs; int32_t numOfChannels; int32_t srcGroupId; + bool groupSort; } SMergeLogicNode; typedef enum EWindowType { WINDOW_TYPE_INTERVAL = 1, WINDOW_TYPE_SESSION, WINDOW_TYPE_STATE } EWindowType; @@ -184,6 +189,7 @@ typedef struct SFillLogicNode { typedef struct SSortLogicNode { SLogicNode node; SNodeList* pSortKeys; + bool groupSort; } SSortLogicNode; typedef struct SPartitionLogicNode { @@ -230,6 +236,7 @@ typedef struct SSlotDescNode { bool reserve; bool output; bool tag; + char name[SLOT_NAME_LEN]; } SSlotDescNode; typedef struct SDataBlockDescNode { @@ -279,7 +286,8 @@ typedef struct STableScanPhysiNode { double ratio; int32_t dataRequired; SNodeList* pDynamicScanFuncs; - SNodeList* pPartitionTags; + SNodeList* pGroupTags; + bool groupSort; int64_t interval; int64_t offset; int64_t sliding; @@ -353,6 +361,7 @@ typedef struct SMergePhysiNode { SNodeList* pTargets; int32_t numOfChannels; int32_t srcGroupId; + bool groupSort; } SMergePhysiNode; typedef struct SWinodwPhysiNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index a6e466e73e..56d0a3f9b9 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -50,6 +50,7 @@ typedef struct SExprNode { char aliasName[TSDB_COL_NAME_LEN]; char userAlias[TSDB_COL_NAME_LEN]; SArray* pAssociation; + bool orderAlias; } SExprNode; typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG, COLUMN_TYPE_TBNAME } EColumnType; @@ -259,6 +260,7 @@ typedef struct SSelectStmt { bool hasTailFunc; bool hasInterpFunc; bool hasLastRowFunc; + bool groupSort; } SSelectStmt; typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType; diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index b350837551..727cdd8ad6 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -48,6 +48,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo // @pSource one execution location of this group of datasource subplans int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource); +int32_t qClearSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId); + // Convert to subplan to string for the scheduler to send to the executor int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen); int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan); diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 0b767e96f6..9e8ce3ffb6 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -271,19 +271,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define qDebug(...) \ do { \ if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ + taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ } \ } while (0) #define qTrace(...) \ do { \ if (qDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \ + taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ } \ } while (0) #define qDebugL(...) \ do { \ if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ + taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ } \ } while (0) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index c2c1a3534d..2b8c6a895e 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -69,7 +69,7 @@ typedef struct SRpcMsg { } SRpcMsg; typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *rf); -typedef bool (*RpcRfp)(int32_t code); +typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType); typedef struct SRpcInit { char localFqdn[TSDB_FQDN_LEN]; diff --git a/include/os/osSystem.h b/include/os/osSystem.h index 6770be6e46..581e688ccb 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -29,6 +29,9 @@ extern "C" { #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #endif +#define TAOS_CONSOLE_PROMPT_HEADER "taos> " +#define TAOS_CONSOLE_PROMPT_CONTINUE " -> " + typedef struct TdCmd *TdCmdPtr; TdCmdPtr taosOpenCmd(const char* cmd); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 8af5945300..8565eea63b 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -25,7 +25,7 @@ extern "C" { // clang-format off #define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code)))) - + #define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code)) #define TAOS_SUCCEEDED(err) ((err) >= 0) #define TAOS_FAILED(err) ((err) < 0) @@ -35,7 +35,7 @@ const char* terrstr(); int32_t* taosGetErrno(); #define terrno (*taosGetErrno()) - + #define TSDB_CODE_SUCCESS 0 #define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error diff --git a/packaging/check_package.sh b/packaging/check_package.sh index 81abff57a5..e728c6455a 100644 --- a/packaging/check_package.sh +++ b/packaging/check_package.sh @@ -170,7 +170,7 @@ function check_lib_path() { function check_header_path() { # check all header - header_dir=("taos.h" "taosdef.h" "taoserror.h") + header_dir=("taos.h" "taosdef.h" "taoserror.h" "taosudf.h") for i in "${header_dir[@]}";do check_link ${inc_link_dir}/$i done diff --git a/packaging/deb/DEBIAN/prerm b/packaging/deb/DEBIAN/prerm index c01db74701..501398f350 100644 --- a/packaging/deb/DEBIAN/prerm +++ b/packaging/deb/DEBIAN/prerm @@ -29,6 +29,7 @@ else ${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${cfg_link_dir}/* || : ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosudf.h || : ${csudo}rm -f ${lib_link_dir}/libtaos.* || : ${csudo}rm -f ${log_link_dir} || : diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 5a14aea4ec..043c1456b8 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -70,6 +70,7 @@ cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_pat cp ${compile_dir}/../include/client/taos.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../include/common/taosdef.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../include/util/taoserror.h ${pkg_dir}${install_home_path}/include +cp ${compile_dir}/../include/libs/function/taosudf.h ${pkg_dir}${install_home_path}/include cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples #cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector #cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index d61d12932f..f440f72aa2 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -77,6 +77,7 @@ cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driv cp %{_compiledir}/../include/client/taos.h %{buildroot}%{homepath}/include cp %{_compiledir}/../include/common/taosdef.h %{buildroot}%{homepath}/include cp %{_compiledir}/../include/util/taoserror.h %{buildroot}%{homepath}/include +cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include #cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector @@ -201,6 +202,7 @@ if [ $1 -eq 0 ];then ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taosudf.h || : ${csudo}rm -f ${lib_link_dir}/libtaos.* || : ${csudo}rm -f ${log_link_dir} || : diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index d730cc0d8a..7c7d5477cf 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -314,11 +314,12 @@ function install_jemalloc() { } function install_header() { - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h } function add_newHostname_to_hosts() { diff --git a/packaging/tools/install_arbi.sh b/packaging/tools/install_arbi.sh index e3c63965d4..2863640153 100755 --- a/packaging/tools/install_arbi.sh +++ b/packaging/tools/install_arbi.sh @@ -115,11 +115,12 @@ function install_bin() { } function install_header() { - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h } function install_jemalloc() { diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index 5f449e5d91..0c86877c99 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -148,11 +148,12 @@ function install_lib() { } function install_header() { - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h } function install_jemalloc() { diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 6726b3fe2d..59be60f8fc 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -349,16 +349,17 @@ function install_lib() { function install_header() { if [ "$osType" != "Darwin" ]; then - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \ + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : + ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h else - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \ + ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ ${install_main_dir}/include || - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \ + ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ ${install_main_2_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* || ${csudo}chmod 644 ${install_main_2_dir}/include/* diff --git a/packaging/tools/makearbi.sh b/packaging/tools/makearbi.sh index 65a6dae9a4..cfae2b4a46 100755 --- a/packaging/tools/makearbi.sh +++ b/packaging/tools/makearbi.sh @@ -36,7 +36,7 @@ fi bin_files="${build_dir}/bin/tarbitrator ${script_dir}/remove_arbi.sh" install_files="${script_dir}/install_arbi.sh" -#header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h" +#header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h" init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 9e7f013006..0f1080521e 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -62,7 +62,7 @@ else lib_files="${build_dir}/lib/libtaos.${version}.dylib" fi -header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h" +header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h" if [ "$dbName" != "taos" ]; then cfg_dir="${top_dir}/../enterprise/packaging/cfg" else diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index d0fbf0c4d7..0bc11b99b3 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -93,7 +93,7 @@ else fi lib_files="${build_dir}/lib/libtaos.so.${version}" -header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h" +header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h" if [ "$dbName" != "taos" ]; then cfg_dir="${top_dir}/../enterprise/packaging/cfg" diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 93849dd4eb..2d744233ba 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -81,10 +81,11 @@ function kill_taosd() { } function install_include() { - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h|| : + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : ${csudo}ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${inc_dir}/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${inc_dir}/taosudf.h ${inc_link_dir}/taosudf.h } function install_lib() { diff --git a/packaging/tools/preun.sh b/packaging/tools/preun.sh index 2f35e41a48..8dee9da988 100755 --- a/packaging/tools/preun.sh +++ b/packaging/tools/preun.sh @@ -128,6 +128,7 @@ ${csudo}rm -f ${cfg_link_dir}/*.new || : ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : +${csudo}rm -f ${inc_link_dir}/taosudf.h || : ${csudo}rm -f ${lib_link_dir}/libtaos.* || : ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 3b043f44a3..413de17ee6 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -84,6 +84,7 @@ function clean_header() { ${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taosdef.h || : ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo} rm -f ${inc_link_dir}/taosudf.h || : } function clean_config() { diff --git a/packaging/tools/remove_arbi.sh b/packaging/tools/remove_arbi.sh index 0a1162cd7a..c95c579d30 100755 --- a/packaging/tools/remove_arbi.sh +++ b/packaging/tools/remove_arbi.sh @@ -59,6 +59,8 @@ function clean_header() { ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taosudf.h || : + } function clean_log() { diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index f2cbccb45f..54f7a949f3 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -54,6 +54,7 @@ function clean_header() { ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taosudf.h || : } function clean_config() { diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index d7bf4b60f1..8e0556125a 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -84,9 +84,12 @@ void closeTransporter(STscObj *pTscObj) { rpcClose(pTscObj->pAppInfo->pTransporter); } -static bool clientRpcRfp(int32_t code) { +static bool clientRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index bbd477fa3b..52574dcc9f 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -81,6 +81,19 @@ void taos_cleanup(void) { taosCloseLog(); } +static setConfRet taos_set_config_imp(const char *config){ + setConfRet ret = {SET_CONF_RET_SUCC, {0}}; + // TODO: need re-implementation + return ret; +} + +setConfRet taos_set_config(const char *config){ +// TODO pthread_mutex_lock(&setConfMutex); + setConfRet ret = taos_set_config_imp(config); +// pthread_mutex_unlock(&setConfMutex); + return ret; +} + TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db); if (user == NULL) { diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 9f89d72172..1ec298ee15 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1605,7 +1605,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { return buf; } -void blockDebugShowData(const SArray* dataBlocks, const char* flag) { +void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { char pBuf[128] = {0}; int32_t sz = taosArrayGetSize(dataBlocks); for (int32_t i = 0; i < sz; i++) { @@ -1613,7 +1613,7 @@ void blockDebugShowData(const SArray* dataBlocks, const char* flag) { size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; - printf("%s |block type %d |child id %d|\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId); + printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { printf("%s |", flag); for (int32_t k = 0; k < numOfCols; k++) { diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 8460a27a0e..7c1b31b6e4 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -862,21 +862,6 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) { printf("\n"); } -void debugCheckTags(STag *pTag) { - switch (pTag->flags) { - case 0x0: - case 0x20: - case 0x40: - case 0x60: - break; - default: - ASSERT(0); - } - - ASSERT(pTag->nTag <= 128 && pTag->nTag >= 0); - ASSERT(pTag->ver <= 512 && pTag->ver >= 0); // temp condition for pTag->ver -} - static int32_t tPutTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) { int32_t n = 0; @@ -999,7 +984,6 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) { debugPrintSTag(*ppTag, __func__, __LINE__); #endif - debugCheckTags(*ppTag); // TODO: remove this line after debug return code; _err: diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 8a052026f2..e9b5c67d76 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4763,7 +4763,7 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) { if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1; if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1; if (pReq->rollup) { - if (tEncodeSRSmaParam(pCoder, &pReq->pRSmaParam) < 0) return -1; + if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } tEndEncode(pCoder); @@ -4779,7 +4779,7 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) { if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1; if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1; if (pReq->rollup) { - if (tDecodeSRSmaParam(pCoder, &pReq->pRSmaParam) < 0) return -1; + if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } tEndDecode(pCoder); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index a4745abd5b..7e31cc3144 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -248,9 +248,12 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { } } -static bool rpcRfp(int32_t code) { +static bool rpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index bc2d5c82b1..1497bba11c 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -39,8 +39,10 @@ typedef struct { int32_t id; int32_t errCode; int32_t acceptableCode; - ETrnStage stage; + int32_t retryCode; ETrnAct actionType; + ETrnStage stage; + int8_t reserved; int8_t rawWritten; int8_t msgSent; int8_t msgReceived; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index b66082dd98..cb2f2aef07 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -15,7 +15,6 @@ #define _DEFAULT_SOURCE #include "mndAcct.h" -#include "mndPrivilege.h" #include "mndBnode.h" #include "mndCluster.h" #include "mndConsumer.h" @@ -27,6 +26,7 @@ #include "mndMnode.h" #include "mndOffset.h" #include "mndPerfSchema.h" +#include "mndPrivilege.h" #include "mndProfile.h" #include "mndQnode.h" #include "mndQuery.h" @@ -416,7 +416,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { char *syncNodeStr = sync2SimpleStr(pMgmt->sync); static int64_t mndTick = 0; if (++mndTick % 10 == 1) { - mTrace("vgId:%d, sync heartbeat msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); + mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); } if (gRaftDetailLog) { char logBuf[512] = {0}; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 029a1e6f8c..164bcc7d60 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -234,7 +234,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { if (retrieveReq.user[0] != 0) { memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN); } else { - memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, TSDB_USER_LEN); + memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1); } if (mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db) != 0) { return -1; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 92f85ecd04..dd01a0fa16 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -427,17 +427,17 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.schemaTag.pSchema = pStb->pTags; if (req.rollup) { - req.pRSmaParam.maxdelay[0] = pStb->maxdelay[0]; - req.pRSmaParam.maxdelay[1] = pStb->maxdelay[1]; + req.rsmaParam.maxdelay[0] = pStb->maxdelay[0]; + req.rsmaParam.maxdelay[1] = pStb->maxdelay[1]; if (pStb->ast1Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg[0], &req.pRSmaParam.qmsgLen[0], pStb->pAst1, pStb->uid, - STREAM_TRIGGER_WINDOW_CLOSE, req.pRSmaParam.watermark[0]) < 0) { + if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid, + STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0]) < 0) { goto _err; } } if (pStb->ast2Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg[1], &req.pRSmaParam.qmsgLen[1], pStb->pAst2, pStb->uid, - STREAM_TRIGGER_WINDOW_CLOSE, req.pRSmaParam.watermark[1]) < 0) { + if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid, + STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1]) < 0) { goto _err; } } @@ -470,12 +470,12 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt tEncoderClear(&encoder); *pContLen = contLen; - taosMemoryFreeClear(req.pRSmaParam.qmsg[0]); - taosMemoryFreeClear(req.pRSmaParam.qmsg[1]); + taosMemoryFreeClear(req.rsmaParam.qmsg[0]); + taosMemoryFreeClear(req.rsmaParam.qmsg[1]); return pHead; _err: - taosMemoryFreeClear(req.pRSmaParam.qmsg[0]); - taosMemoryFreeClear(req.pRSmaParam.qmsg[1]); + taosMemoryFreeClear(req.rsmaParam.qmsg[0]); + taosMemoryFreeClear(req.rsmaParam.qmsg[1]); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index a9de1a05a7..b09ee5f608 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -15,15 +15,15 @@ #define _DEFAULT_SOURCE #include "mndTrans.h" -#include "mndPrivilege.h" #include "mndConsumer.h" #include "mndDb.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndSync.h" #include "mndUser.h" -#define TRANS_VER_NUMBER 1 -#define TRANS_ARRAY_SIZE 8 +#define TRANS_VER_NUMBER 1 +#define TRANS_ARRAY_SIZE 8 #define TRANS_RESERVE_SIZE 64 static SSdbRaw *mndTransActionEncode(STrans *pTrans); @@ -55,7 +55,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans); static bool mndCannotExecuteTransAction(SMnode *pMnode) { return !pMnode->deploy && !mndIsMaster(pMnode); } static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); -static int32_t mndProcessTransReq(SRpcMsg *pReq); +static int32_t mndProcessTransTimer(SRpcMsg *pReq); static int32_t mndProcessTtl(SRpcMsg *pReq); static int32_t mndProcessKillTransReq(SRpcMsg *pReq); @@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndTransActionDelete, }; - mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq); + mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransTimer); mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); @@ -139,8 +139,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -163,8 +165,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -187,8 +191,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -291,10 +297,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType == TRANS_ACTION_RAW) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -324,10 +332,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType == TRANS_ACTION_RAW) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -357,10 +367,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -463,15 +475,25 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) { if (fp) { (*fp)(pSdb->pMnode, pTrans->param, pTrans->paramLen); } + pTrans->startFunc = 0; } return 0; } static void mndTransDropData(STrans *pTrans) { - mndTransDropActions(pTrans->redoActions); - mndTransDropActions(pTrans->undoActions); - mndTransDropActions(pTrans->commitActions); + if (pTrans->redoActions != NULL) { + mndTransDropActions(pTrans->redoActions); + pTrans->redoActions = NULL; + } + if (pTrans->undoActions != NULL) { + mndTransDropActions(pTrans->undoActions); + pTrans->undoActions = NULL; + } + if (pTrans->commitActions != NULL) { + mndTransDropActions(pTrans->commitActions); + pTrans->commitActions = NULL; + } if (pTrans->rpcRsp != NULL) { taosMemoryFree(pTrans->rpcRsp); pTrans->rpcRsp = NULL; @@ -492,6 +514,7 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans, bool callFunc) { if (fp) { (*fp)(pSdb->pMnode, pTrans->param, pTrans->paramLen); } + pTrans->stopFunc = 0; } mndTransDropData(pTrans); @@ -805,7 +828,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { sendRsp = true; } } else { - if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 3) { + if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 6) { if (code == 0) code = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; sendRsp = true; } @@ -875,8 +898,8 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { pAction->errCode = pRsp->code; } - mDebug("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x", transId, mndTransStr(pAction->stage), action, - pRsp->code, pAction->acceptableCode); + mDebug("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, + mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode); mndTransExecute(pMnode, pTrans); _OVER: @@ -884,6 +907,21 @@ _OVER: return 0; } +static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) { + pAction->rawWritten = 0; + pAction->msgSent = 0; + pAction->msgReceived = 0; + if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || + pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { + pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; + mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), + pAction->id, pAction->epSet.inUse); + } else { + mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), pAction->id); + } + pAction->errCode = 0; +} + static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) { int32_t numOfActions = taosArrayGetSize(pArray); @@ -894,18 +932,7 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) continue; if (pAction->rawWritten && (pAction->errCode == 0 || pAction->errCode == pAction->acceptableCode)) continue; - pAction->rawWritten = 0; - pAction->msgSent = 0; - pAction->msgReceived = 0; - if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || - pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { - pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; - mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), - action, pAction->epSet.inUse); - } else { - mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action); - } - pAction->errCode = 0; + mndTransResetAction(pMnode, pTrans, pAction); } } @@ -1112,9 +1139,9 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (pAction->msgReceived) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { code = pAction->errCode; - pAction->msgSent = 0; - pAction->msgReceived = 0; - mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action); + mndTransResetAction(pMnode, pTrans, pAction); + } else { + mDebug("trans:%d, %s:%d execute successfully", pTrans->id, mndTransStr(pAction->stage), action); } } else { code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -1123,6 +1150,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (pAction->rawWritten) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { code = pAction->errCode; + } else { + mDebug("trans:%d, %s:%d write successfully", pTrans->id, mndTransStr(pAction->stage), action); } } } @@ -1156,9 +1185,16 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) } else if (code == TSDB_CODE_ACTION_IN_PROGRESS) { mDebug("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id); break; + } else if (code == pAction->retryCode) { + mDebug("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code); + taosMsleep(300); + action--; + continue; } else { terrno = code; pTrans->code = code; + mDebug("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id, + mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes); break; } } @@ -1343,7 +1379,7 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) { mndTransSendRpcRsp(pMnode, pTrans); } -static int32_t mndProcessTransReq(SRpcMsg *pReq) { +static int32_t mndProcessTransTimer(SRpcMsg *pReq) { mndTransPullup(pReq->info.node); return 0; } diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 0e931e0a9c..d42016e6a0 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -15,10 +15,10 @@ #define _DEFAULT_SOURCE #include "mndVgroup.h" -#include "mndPrivilege.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" @@ -896,6 +896,8 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD action.pCont = pHead; action.contLen = contLen; action.msgType = TDMT_VND_ALTER_CONFIRM; + // incorrect redirect result will cause this erro + action.retryCode = TSDB_CODE_VND_INVALID_VGROUP_ID; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pHead); @@ -942,6 +944,8 @@ static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbOb action.contLen = contLen; action.msgType = TDMT_SYNC_SET_VNODE_STANDBY; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + // Keep retrying until the target vnode is not the leader + action.retryCode = TSDB_CODE_SYN_IS_LEADER; if (isRedo) { if (mndTransAppendRedoAction(pTrans, &action) != 0) { @@ -1003,7 +1007,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, mInfo("vgId:%d, will add 1 vnodes", pVgroup->vgId); if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[1], true) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1], true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; @@ -1017,10 +1021,19 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; - SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; - sdbSetRawStatus(pRaw, SDB_STATUS_READY); - pRaw = NULL; + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) return -1; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } + + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1168,10 +1181,19 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pOld3->id) != 0) goto _OVER; } - pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; - sdbSetRawStatus(pRaw, SDB_STATUS_READY); - pRaw = NULL; + { + pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } + + { + pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } mInfo("vgId:%d, vgroup info after redistribute, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1229,7 +1251,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { } if (req.dnodeId1 == pVgroup->vnodeGid[0].dnodeId) { - terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + // terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + code = 0; goto _OVER; } @@ -1351,7 +1374,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { } if (pNew1 == NULL && pOld1 == NULL && pNew2 == NULL && pOld2 == NULL && pNew3 == NULL && pOld3 == NULL) { - terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + // terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + code = 0; goto _OVER; } @@ -1424,13 +1448,25 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S } else { } - SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); - if (pVgRaw == NULL) return -1; - if (mndTransAppendCommitlog(pTrans, pVgRaw) != 0) { - sdbFreeRaw(pVgRaw); - return -1; + { + SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); + if (pVgRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); + } + + { + SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); + if (pVgRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); } - sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); } return 0; @@ -1538,12 +1574,23 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD if (mndAddIncVgroupReplicaToTrans(pMnode, pTrans, pDb, &newVg, pDst->id) != 0) return -1; if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pSrc->id) != 0) return -1; - SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) { - sdbFreeRaw(pRaw); - return -1; + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + return -1; + } + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + } + + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + return -1; + } + sdbSetRawStatus(pRaw, SDB_STATUS_READY); } - sdbSetRawStatus(pRaw, SDB_STATUS_READY); mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1552,7 +1599,8 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD return 0; } -static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDnodeObj *pSrc, SDnodeObj *pDst) { +static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDnodeObj *pSrc, SDnodeObj *pDst, + SHashObj *pBalancedVgroups) { void *pIter = NULL; int32_t code = -1; SSdb *pSdb = pMnode->pSdb; @@ -1561,6 +1609,10 @@ static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDno SVgObj *pVgroup = NULL; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; + if (taosHashGet(pBalancedVgroups, &pVgroup->vgId, sizeof(int32_t)) != NULL) { + sdbRelease(pSdb, pVgroup); + continue; + } bool existInSrc = false; bool existInDst = false; @@ -1577,6 +1629,9 @@ static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDno SDbObj *pDb = mndAcquireDb(pMnode, pVgroup->dbName); code = mndSetBalanceVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, pSrc, pDst); + if (code == 0) { + code = taosHashPut(pBalancedVgroups, &pVgroup->vgId, sizeof(int32_t), &pVgroup->vgId, sizeof(int32_t)); + } mndReleaseDb(pMnode, pDb); sdbRelease(pSdb, pVgroup); sdbCancelFetch(pSdb, pIter); @@ -1590,6 +1645,10 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { int32_t code = -1; int32_t numOfVgroups = 0; STrans *pTrans = NULL; + SHashObj *pBalancedVgroups = NULL; + + pBalancedVgroups = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (pBalancedVgroups == NULL) goto _OVER; pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); if (pTrans == NULL) goto _OVER; @@ -1613,18 +1672,18 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { pDst->id, dstScore); if (srcScore > dstScore - 0.000001) { - code = mndBalanceVgroupBetweenDnode(pMnode, pTrans, pSrc, pDst); + code = mndBalanceVgroupBetweenDnode(pMnode, pTrans, pSrc, pDst, pBalancedVgroups); if (code == 0) { pSrc->numOfVnodes--; pDst->numOfVnodes++; numOfVgroups++; continue; } else { - mError("trans:%d, failed to balance vgroup from dnode:%d to dnode:%d", pTrans->id, pSrc->id, pDst->id); - return -1; + mDebug("trans:%d, no vgroup need to balance from dnode:%d to dnode:%d", pTrans->id, pSrc->id, pDst->id); + break; } } else { - mDebug("trans:%d, no vgroup need to balance vgroup any more", pTrans->id); + mDebug("trans:%d, no vgroup need to balance any more", pTrans->id); break; } } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index c49b33beb2..5c2d2cd712 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -199,15 +199,20 @@ typedef struct { uint64_t groupId; } STableKeyInfo; +#define TABLE_ROLLUP_ON ((int8_t)0x1) +#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0) +#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON) struct SMetaEntry { int64_t version; int8_t type; + int8_t flags; // TODO: need refactor? tb_uid_t uid; char *name; union { struct { SSchemaWrapper schemaRow; SSchemaWrapper schemaTag; + SRSmaParam rsmaParam; } stbEntry; struct { int64_t ctime; diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 956e451b58..23ad70bad3 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -176,15 +176,18 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) { static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); +void *tdFreeRSmaInfo(SRSmaInfo *pInfo); -void *tdFreeRSmaInfo(SRSmaInfo *pInfo); - +int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); +int32_t tdProcessRSmaRestoreImpl(SSma *pSma); int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); // smaFileUtil ================ +#define TD_FILE_HEAD_SIZE 512 + typedef struct STFInfo STFInfo; typedef struct STFile STFile; @@ -202,16 +205,16 @@ struct STFile { uint8_t state; }; -#define TD_FILE_F(tf) (&((tf)->f)) -#define TD_FILE_PFILE(tf) ((tf)->pFile) -#define TD_FILE_OPENED(tf) (TD_FILE_PFILE(tf) != NULL) -#define TD_FILE_FULL_NAME(tf) (TD_FILE_F(tf)->aname) -#define TD_FILE_REL_NAME(tf) (TD_FILE_F(tf)->rname) -#define TD_FILE_OPENED(tf) (TD_FILE_PFILE(tf) != NULL) -#define TD_FILE_CLOSED(tf) (!TD_FILE_OPENED(tf)) -#define TD_FILE_SET_CLOSED(f) (TD_FILE_PFILE(f) = NULL) -#define TD_FILE_SET_STATE(tf, s) ((tf)->state = (s)) -#define TD_FILE_DID(tf) (TD_FILE_F(tf)->did) +#define TD_TFILE_F(tf) (&((tf)->f)) +#define TD_TFILE_PFILE(tf) ((tf)->pFile) +#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL) +#define TD_TFILE_FULL_NAME(tf) (TD_TFILE_F(tf)->aname) +#define TD_TFILE_REL_NAME(tf) (TD_TFILE_F(tf)->rname) +#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL) +#define TD_TFILE_CLOSED(tf) (!TD_TFILE_OPENED(tf)) +#define TD_TFILE_SET_CLOSED(f) (TD_TFILE_PFILE(f) = NULL) +#define TD_TFILE_SET_STATE(tf, s) ((tf)->state = (s)) +#define TD_TFILE_DID(tf) (TD_TFILE_F(tf)->did) int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname); int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fType); @@ -220,12 +223,14 @@ int64_t tdReadTFile(STFile *pTFile, void *buf, int64_t nbyte); int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence); int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte); int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset); +int64_t tdGetTFileSize(STFile *pTFile, int64_t *size); int32_t tdRemoveTFile(STFile *pTFile); int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo); int32_t tdUpdateTFileHeader(STFile *pTFile); void tdUpdateTFileMagic(STFile *pTFile, void *pCksm); void tdCloseTFile(STFile *pTFile); -void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName); + +void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 68ed6dde51..baead763ad 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -64,6 +64,7 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader; #define VNODE_TQ_DIR "tq" #define VNODE_WAL_DIR "wal" #define VNODE_TSMA_DIR "tsma" +#define VNODE_RSMA_DIR "rsma" #define VNODE_RSMA0_DIR "tsdb" #define VNODE_RSMA1_DIR "rsma1" #define VNODE_RSMA2_DIR "rsma2" @@ -161,7 +162,6 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool // sma int32_t smaOpen(SVnode* pVnode); -int32_t smaClose(SSma* pSma); int32_t smaCloseEnv(SSma* pSma); int32_t smaCloseEx(SSma* pSma); diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index acf5b0b613..23d7665ba3 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -24,22 +24,25 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) { if (tEncodeCStr(pCoder, pME->name) < 0) return -1; if (pME->type == TSDB_SUPER_TABLE) { + if (tEncodeI8(pCoder, pME->flags) < 0) return -1; // TODO: need refactor? if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow) < 0) return -1; if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag) < 0) return -1; + if (TABLE_IS_ROLLUP(pME->flags)) { + if (tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1; + } } else if (pME->type == TSDB_CHILD_TABLE) { if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1; - if (tEncodeI32(pCoder, pME->ctbEntry.commentLen) < 0) return -1; + if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1; if (pME->ctbEntry.commentLen > 0){ if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1; } if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1; - debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug if (tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags) < 0) return -1; } else if (pME->type == TSDB_NORMAL_TABLE) { if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1; - if (tEncodeI32(pCoder, pME->ntbEntry.commentLen) < 0) return -1; + if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1; if (pME->ntbEntry.commentLen > 0){ if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1; } @@ -64,23 +67,26 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (tDecodeCStr(pCoder, &pME->name) < 0) return -1; if (pME->type == TSDB_SUPER_TABLE) { + if (tDecodeI8(pCoder, &pME->flags) < 0) return -1; // TODO: need refactor? if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow) < 0) return -1; if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag) < 0) return -1; + if (TABLE_IS_ROLLUP(pME->flags)) { + if (tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1; + } } else if (pME->type == TSDB_CHILD_TABLE) { if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1; - if (tDecodeI32(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; + if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; if (pME->ctbEntry.commentLen > 0){ if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1; } if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO) - debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug } else if (pME->type == TSDB_NORMAL_TABLE) { if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1; - if (tDecodeI32(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; + if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; if (pME->ntbEntry.commentLen > 0){ if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index f57ee54400..85106f46c2 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -342,6 +342,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { pStbCur = (SMStbCursor *)taosMemoryCalloc(1, sizeof(*pStbCur)); if (pStbCur == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -351,6 +352,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { ret = tdbTbcOpen(pMeta->pSuidIdx, &pStbCur->pCur, NULL); if (ret < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; metaULock(pMeta); taosMemoryFree(pStbCur); return NULL; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index ea425ca7de..a621b4ddb0 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -139,6 +139,10 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { me.name = pReq->name; me.stbEntry.schemaRow = pReq->schemaRow; me.stbEntry.schemaTag = pReq->schemaTag; + if (pReq->rollup) { + TABLE_SET_ROLLUP(me.flags); + me.stbEntry.rsmaParam = pReq->rsmaParam; + } if (metaHandleEntry(pMeta, &me) < 0) goto _err; diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 1e8832615e..7f115633b9 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -156,6 +156,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS static void tdDestroyTSmaStat(STSmaStat *pStat) { if (pStat) { + smaDebug("destroy tsma stat"); tDestroyTSma(pStat->pTSma); taosMemoryFreeClear(pStat->pTSma); taosMemoryFreeClear(pStat->pTSchema); @@ -170,15 +171,12 @@ static void *tdFreeTSmaStat(STSmaStat *pStat) { static void tdDestroyRSmaStat(SRSmaStat *pStat) { if (pStat) { - smaDebug("vgId:%d, %s:%d free rsma stat", SMA_VID(pStat->pSma), __func__, __LINE__); + smaDebug("vgId:%d destroy rsma stat", SMA_VID(pStat->pSma)); // step 1: set persistence task cancelled atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); - // step 2: clean timer + // step 2: stop the persistence timer taosTmrStopA(&RSMA_TMR_ID(pStat)); - if (RSMA_TMR_HANDLE(pStat)) { - taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); - } // step 3: wait the persistence thread to finish int32_t nLoops = 0; @@ -194,7 +192,6 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { sched_yield(); nLoops = 0; } - taosMsleep(1000); // TODO: remove this line when release } } @@ -219,7 +216,11 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { sched_yield(); nLoops = 0; } - taosMsleep(1000); // TODO: remove this line when release + } + + // step 6: cleanup the timer handle + if (RSMA_TMR_HANDLE(pStat)) { + taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); } } } @@ -245,16 +246,12 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - smaDebug("%s:%d destroy tsma stat", __func__, __LINE__); tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat)); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - smaDebug("%s:%d destroy rsma stat", __func__, __LINE__); tdDestroyRSmaStat(SMA_RSMA_STAT(pSmaStat)); } else { ASSERT(0); } - } else { - smaDebug("%s:%d no need to destroy rsma stat", __func__, __LINE__); } return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 2f40df8b45..641b8c7934 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -18,6 +18,7 @@ static int32_t smaEvalDays(SRetention *r, int8_t precision); static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); +static int32_t rsmaRestore(SSma *pSma); #define SMA_SET_KEEP_CFG(l) \ do { \ @@ -100,6 +101,9 @@ int32_t smaOpen(SVnode *pVnode) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } + + pVnode->pSma = pSma; + pSma->pVnode = pVnode; taosThreadMutexInit(&pSma->mutex, NULL); pSma->locked = false; @@ -117,17 +121,22 @@ int32_t smaOpen(SVnode *pVnode) { ASSERT(0); } } + + // restore the rsma +#if 1 + if (rsmaRestore(pSma) < 0) { + goto _err; + } +#endif } - pVnode->pSma = pSma; return 0; _err: - taosMemoryFreeClear(pSma); return -1; } int32_t smaCloseEnv(SSma *pSma) { - if(pSma) { + if (pSma) { SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); } @@ -145,21 +154,14 @@ int32_t smaCloseEx(SSma *pSma) { return 0; } -int32_t smaClose(SSma *pSma) { - smaCloseEnv(pSma); - smaCloseEx(pSma); - return 0; -} - /** * @brief rsma env restore - * - * @param pSma - * @return int32_t + * + * @param pSma + * @return int32_t */ -int32_t smaRestore(SSma *pSma) { - if (!pSma) return 0; - // iterate all stables to restore the rsma env - - return TSDB_CODE_SUCCESS; +static int32_t rsmaRestore(SSma *pSma) { + ASSERT(VND_IS_RSMA(pSma->pVnode)); + + return tdProcessRSmaRestoreImpl(pSma); } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 020ee38db9..34c3ef8fca 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -15,10 +15,15 @@ #include "sma.h" -#define RSMA_QTASK_PERSIST_MS 7200000 +#define RSMA_QTASKINFO_PERSIST_MS 7200000 +#define RSMA_QTASKINFO_BUFSIZE 32768 +#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid typedef enum { TD_QTASK_TMP_FILE = 0, TD_QTASK_CUR_FILE } TD_QTASK_FILE_T; static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; +typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; +typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; + static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo *pRSmaInfo, SReadHandle *handle, @@ -27,6 +32,13 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType tb_uid_t suid, int8_t level); static void tdRSmaFetchTrigger(void *param, void *tmrId); static void tdRSmaPersistTrigger(void *param, void *tmrId); +static void *tdRSmaPersistExec(void *param); +static void tdRSmaQTaskInfoGetFName(int32_t vid, int8_t ftype, char *outputName); + +static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile); +static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish); +static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter); +static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem); struct SRSmaInfoItem { SRSmaInfo *pRsmaInfo; @@ -45,14 +57,39 @@ struct SRSmaInfo { SRSmaInfoItem items[TSDB_RETENTION_L2]; }; +struct SRSmaQTaskInfoItem { + int32_t len; + int8_t type; + int64_t suid; + void *qTaskInfo; +}; + +struct SRSmaQTaskInfoIter { + STFile *pTFile; + int64_t offset; + int64_t fsize; + int32_t nBytes; + int32_t nAlloc; + char *pBuf; + // ------------ + char *qBuf; // for iterator + int32_t nBufPos; +}; + +static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { + return lenWithHead - RSMA_QTASKINFO_HEAD_LEN; +} + +static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); } + static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { // Note: free/kill may in RC qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) { - smaDebug("vgId:%d, %s:%d free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); + smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level); qDestroyTask(otaskHandle); } else { - smaDebug("vgId:%d, %s:%d not free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); + smaDebug("vgId:%d, not free qTaskInfo_t %p of level %d", vgId, otaskHandle, level); } } @@ -89,7 +126,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) { return TSDB_CODE_SUCCESS; } -static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { +static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; @@ -230,26 +267,21 @@ _err: } /** - * @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam. + * @brief for rsam create or restore * - * @param pTsdb - * @param pMeta - * @param pReq + * @param pSma + * @param param + * @param suid + * @param tbName * @return int32_t */ -int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { - SSma *pSma = pVnode->pSma; - if (!pReq->rollup) { - smaTrace("vgId:%d, return directly since no rollup for stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); - return TSDB_CODE_SUCCESS; - } - - SMeta *pMeta = pVnode->pMeta; - SMsgCb *pMsgCb = &pVnode->msgCb; - SRSmaParam *param = &pReq->pRSmaParam; +int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) { + SVnode *pVnode = pSma->pVnode; + SMeta *pMeta = pVnode->pMeta; + SMsgCb *pMsgCb = &pVnode->msgCb; if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) { - smaWarn("vgId:%d, no qmsg1/qmsg2 for rollup stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + smaDebug("vgId:%d, no qmsg1/qmsg2 for rollup table %s %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; } @@ -262,10 +294,10 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; - pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t)); + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); if (pRSmaInfo) { - ASSERT(0); // TODO: free original pRSmaInfo is exists abnormally - smaWarn("vgId:%d, rsma info already exists for stb: %s, %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + ASSERT(0); // TODO: free original pRSmaInfo if exists abnormally + smaDebug("vgId:%d, rsma info already exists for table %s, %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; } @@ -289,14 +321,14 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { .vnode = pVnode, }; - STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), pReq->suid, -1); + STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), suid, -1); if (!pTSchema) { terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION; goto _err; } pRSmaInfo->pTSchema = pTSchema; pRSmaInfo->pSma = pSma; - pRSmaInfo->suid = pReq->suid; + pRSmaInfo->suid = suid; if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 0) < 0) { goto _err; @@ -306,16 +338,16 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { goto _err; } - if (taosHashPut(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { + if (taosHashPut(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { goto _err; - } else { - smaDebug("vgId:%d, register rsma info succeed for suid:%" PRIi64, SMA_VID(pSma), pReq->suid); } + smaDebug("vgId:%d, register rsma info succeed for suid:%" PRIi64, SMA_VID(pSma), suid); + // start the persist timer if (TASK_TRIGGER_STAT_INIT == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_INIT, TASK_TRIGGER_STAT_ACTIVE)) { - taosTmrStart(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pStat, RSMA_TMR_HANDLE(pStat)); + taosTmrStart(tdRSmaPersistTrigger, RSMA_QTASKINFO_PERSIST_MS, pStat, RSMA_TMR_HANDLE(pStat)); } return TSDB_CODE_SUCCESS; @@ -325,6 +357,23 @@ _err: return TSDB_CODE_FAILED; } +/** + * @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam currently + * + * @param pVnode + * @param pReq + * @return int32_t + */ +int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { + SSma *pSma = pVnode->pSma; + if (!pReq->rollup) { + smaTrace("vgId:%d, return directly since no rollup for stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + return TSDB_CODE_SUCCESS; + } + + return tdProcessRSmaCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name); +} + /** * @brief store suid/[uids], prefer to use array and then hash * @@ -487,7 +536,7 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) #if 1 char flag[10] = {0}; snprintf(flag, 10, "level %" PRIi8, pItem->level); - blockDebugShowData(pResult, flag); + blockDebugShowDataBlocks(pResult, flag); #endif STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2); SSubmitReq *pReq = NULL; @@ -502,8 +551,10 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) } taosMemoryFreeClear(pReq); + } else if (terrno == 0) { + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); } else { - smaDebug("vgId:%d, no rsma %" PRIi8 " data generated since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); } tdDestroySDataBlockArray(pResult); @@ -526,16 +577,16 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), - __func__, __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), + pItem->level, pItem->pRsmaInfo->suid); return; } int8_t fetchTriggerStat = atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), __func__, - __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, + pItem->pRsmaInfo->suid); tdRefSmaStat(pSma, (SSmaStat *)pStat); @@ -546,13 +597,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { tdUnRefSmaStat(pSma, (SSmaStat *)pStat); } else { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), __func__, - __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, + pItem->pRsmaInfo->suid); } } -static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, - tb_uid_t suid, int8_t level) { +static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, tb_uid_t suid, + int8_t level) { if (!pItem || !pItem->taskInfo) { smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid); return TSDB_CODE_SUCCESS; @@ -568,7 +619,7 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3 tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SUBMIT_BLOCK); atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); - smaDebug("vgId:%d, %s:%d process rsma insert", SMA_VID(pSma), __func__, __LINE__); + smaDebug("vgId:%d, process rsma insert", SMA_VID(pSma)); SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat); @@ -645,8 +696,265 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) { return TSDB_CODE_SUCCESS; } -void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char *outputName) { - tdGetVndFileName(vid, "rsma", tdQTaskInfoFname[ftype], outputName); +int32_t tdProcessRSmaRestoreImpl(SSma *pSma) { + SVnode *pVnode = pSma->pVnode; + + // step 1: iterate all stables to restore the rsma env + SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); + if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { + taosArrayDestroy(suidList); + smaError("vgId:%d, failed to restore rsma env since get stb id list error: %s", TD_VID(pVnode), terrstr()); + return TSDB_CODE_FAILED; + } + + int32_t arrSize = taosArrayGetSize(suidList); + if (arrSize == 0) { + taosArrayDestroy(suidList); + smaDebug("vgId:%d, no need to restore rsma env since empty stb id list", TD_VID(pVnode)); + return TSDB_CODE_SUCCESS; + } + + SMetaReader mr = {0}; + metaReaderInit(&mr, SMA_META(pSma), 0); + for (int32_t i = 0; i < arrSize; ++i) { + tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); + smaDebug("vgId:%d, rsma restore, suid[%d] is %" PRIi64, TD_VID(pVnode), i, suid); + if (metaGetTableEntryByUid(&mr, suid) < 0) { + smaError("vgId:%d, rsma restore, failed to get table meta for %" PRIi64 " since %s", TD_VID(pVnode), suid, + terrstr()); + goto _err; + } + ASSERT(mr.me.type == TSDB_SUPER_TABLE); + ASSERT(mr.me.uid == suid); + if (TABLE_IS_ROLLUP(mr.me.flags)) { + SRSmaParam *param = &mr.me.stbEntry.rsmaParam; + for (int i = 0; i < TSDB_RETENTION_L2; ++i) { + smaDebug("vgId:%d, rsma restore, table:%" PRIi64 " level:%d, maxdelay:%" PRIi64 " watermark:%" PRIi64 + " qmsgLen:%" PRIi32, + TD_VID(pVnode), suid, i, param->maxdelay[i], param->watermark[i], param->qmsgLen[i]); + } + if (tdProcessRSmaCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) { + smaError("vgId:%d, rsma restore env failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr()); + goto _err; + } + smaDebug("vgId:%d, rsma restore env success for %" PRIi64, TD_VID(pVnode), suid); + } + } + + // step 2: retrieve qtaskinfo items from the persistence file(rsma/qtaskinfo) and restore + STFile tFile = {0}; + char qTaskInfoFName[TSDB_FILENAME_LEN]; + + tdRSmaQTaskInfoGetFName(TD_VID(pVnode), TD_QTASK_CUR_FILE, qTaskInfoFName); + if (tdInitTFile(&tFile, pVnode->pTfs, qTaskInfoFName) < 0) { + goto _err; + } + + if(!taosCheckExistFile(TD_TFILE_FULL_NAME(&tFile))) { + metaReaderClear(&mr); + taosArrayDestroy(suidList); + return TSDB_CODE_SUCCESS; + } + + if (tdOpenTFile(&tFile, TD_FILE_READ) < 0) { + goto _err; + } + + SRSmaQTaskInfoIter fIter = {0}; + if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) { + goto _err; + } + SRSmaQTaskInfoItem infoItem = {0}; + if (tdRSmaQTaskInfoRestore(pSma, &fIter) < 0) { + tdRSmaQTaskInfoIterDestroy(&fIter); + goto _err; + } + + tdRSmaQTaskInfoIterDestroy(&fIter); + metaReaderClear(&mr); + taosArrayDestroy(suidList); + return TSDB_CODE_SUCCESS; +_err: + metaReaderClear(&mr); + taosArrayDestroy(suidList); + smaError("failed to restore rsma task since %s", terrstr()); + return TSDB_CODE_FAILED; +} + +static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *pItem) { + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)pSma->pRSmaEnv); + SRSmaInfo *pRSmaInfo = NULL; + void *qTaskInfo = NULL; + + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &pItem->suid, sizeof(pItem->suid)); + + if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { + smaDebug("vgId:%d, no restore as no rsma info for table:%" PRIu64, SMA_VID(pSma), pItem->suid); + return TSDB_CODE_SUCCESS; + } + + if (pItem->type == 1) { + qTaskInfo = pRSmaInfo->items[0].taskInfo; + } else if (pItem->type == 2) { + qTaskInfo = pRSmaInfo->items[1].taskInfo; + } else { + ASSERT(0); + } + + if (!qTaskInfo) { + smaDebug("vgId:%d, no restore as NULL rsma qTaskInfo for table:%" PRIu64, SMA_VID(pSma), pItem->suid); + return TSDB_CODE_SUCCESS; + } + + if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) { + smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid, + pItem->type, terrstr(terrno)); + return TSDB_CODE_FAILED; + } + smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid, pItem->type); + + return TSDB_CODE_SUCCESS; +} + +static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile) { + memset(pIter, 0, sizeof(*pIter)); + pIter->pTFile = pTFile; + pIter->offset = TD_FILE_HEAD_SIZE; + + if (tdGetTFileSize(pTFile, &pIter->fsize) < 0) { + return TSDB_CODE_FAILED; + } + + if ((pIter->fsize - TD_FILE_HEAD_SIZE) < RSMA_QTASKINFO_BUFSIZE) { + pIter->nAlloc = pIter->fsize - TD_FILE_HEAD_SIZE; + } else { + pIter->nAlloc = RSMA_QTASKINFO_BUFSIZE; + } + + if (pIter->nAlloc < TD_FILE_HEAD_SIZE) { + pIter->nAlloc = TD_FILE_HEAD_SIZE; + } + + pIter->pBuf = taosMemoryMalloc(pIter->nAlloc); + if (!pIter->pBuf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + pIter->qBuf = pIter->pBuf; + + return TSDB_CODE_SUCCESS; +} + +static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish) { + STFile *pTFile = pIter->pTFile; + int64_t nBytes = RSMA_QTASKINFO_BUFSIZE; + + if (pIter->offset >= pIter->fsize) { + *isFinish = true; + return TSDB_CODE_SUCCESS; + } + + if ((pIter->fsize - pIter->offset) < RSMA_QTASKINFO_BUFSIZE) { + nBytes = pIter->fsize - pIter->offset; + } + + if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + if (tdReadTFile(pTFile, pIter->qBuf, nBytes) != nBytes) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + int32_t infoLen = 0; + taosDecodeFixedI32(pIter->qBuf, &infoLen); + if (infoLen > nBytes) { + ASSERT(infoLen > RSMA_QTASKINFO_BUFSIZE); + pIter->nAlloc = infoLen; + void *pBuf = taosMemoryRealloc(pIter->pBuf, infoLen); + if (!pBuf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + pIter->pBuf = pBuf; + pIter->qBuf = pIter->pBuf; + nBytes = infoLen; + + if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET)) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + if (tdReadTFile(pTFile, pIter->pBuf, nBytes) != nBytes) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + } + + pIter->offset += nBytes; + pIter->nBytes = nBytes; + pIter->nBufPos = 0; + + return TSDB_CODE_SUCCESS; +} + +static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) { + while (1) { + // block iter + bool isFinish = false; + if (tdRSmaQTaskInfoIterNextBlock(pIter, &isFinish) < 0) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + if (isFinish) { + return TSDB_CODE_SUCCESS; + } + + // consume the block + int32_t qTaskInfoLenWithHead = 0; + pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead); + if (qTaskInfoLenWithHead < RSMA_QTASKINFO_HEAD_LEN) { + terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + return TSDB_CODE_FAILED; + } + + while (1) { + if ((pIter->nBufPos + qTaskInfoLenWithHead) <= pIter->nBytes) { + SRSmaQTaskInfoItem infoItem = {0}; + pIter->qBuf = taosDecodeFixedI8(pIter->qBuf, &infoItem.type); + pIter->qBuf = taosDecodeFixedI64(pIter->qBuf, &infoItem.suid); + infoItem.qTaskInfo = pIter->qBuf; + infoItem.len = tdRSmaQTaskInfoContLen(qTaskInfoLenWithHead); + // do the restore job + smaDebug("vgId:%d, restore the qtask info %s offset:%" PRIi64 "\n", SMA_VID(pSma), + TD_TFILE_FULL_NAME(pIter->pTFile), pIter->offset - pIter->nBytes + pIter->nBufPos); + tdRSmaQTaskInfoItemRestore(pSma, &infoItem); + + pIter->qBuf = POINTER_SHIFT(pIter->qBuf, infoItem.len); + pIter->nBufPos += qTaskInfoLenWithHead; + + if ((pIter->nBufPos + RSMA_QTASKINFO_HEAD_LEN) >= pIter->nBytes) { + // prepare and load next block in the file + pIter->offset -= (pIter->nBytes - pIter->nBufPos); + break; + } + + pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead); + continue; + } + // prepare and load next block in the file + pIter->offset -= (pIter->nBytes - pIter->nBufPos); + break; + } + } + + return TSDB_CODE_SUCCESS; +} + +static void tdRSmaQTaskInfoGetFName(int32_t vid, int8_t ftype, char *outputName) { + tdGetVndFileName(vid, VNODE_RSMA_DIR, tdQTaskInfoFname[ftype], outputName); } static void *tdRSmaPersistExec(void *param) { @@ -654,6 +962,7 @@ static void *tdRSmaPersistExec(void *param) { SRSmaStat *pRSmaStat = param; SSma *pSma = pRSmaStat->pSma; STfs *pTfs = pSma->pVnode->pTfs; + int32_t vid = SMA_VID(pSma); int64_t toffset = 0; bool isFileCreated = false; @@ -661,112 +970,99 @@ static void *tdRSmaPersistExec(void *param) { goto _end; } -#if 0 - SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); - if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { - ASSERT(0); - } else { - for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { - tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); - smaDebug("suid [%d] is %" PRIi64, i, suid); - } - } -#endif - void *infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL); if (!infoHash) { goto _end; } - STFile tFile = {0}; - int32_t vid = SMA_VID(pSma); - + STFile tFile = {0}; while (infoHash) { SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash; - -#if 0 - smaDebug("table %" PRIi64 " sleep 15s start ...", pRSmaInfo->items[0].pRsmaInfo->suid); - for (int32_t i = 15; i > 0; --i) { - taosSsleep(1); - smaDebug("table %" PRIi64 " countdown %d", pRSmaInfo->items[0].pRsmaInfo->suid, i); - } - smaDebug("table %" PRIi64 " sleep 15s end ...", pRSmaInfo->items[0].pRsmaInfo->suid); -#endif for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { qTaskInfo_t taskInfo = pRSmaInfo->items[i].taskInfo; if (!taskInfo) { smaDebug("vgId:%d, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1); continue; } + char *pOutput = NULL; int32_t len = 0; - int8_t type = 0; + int8_t type = (int8_t)(i + 1); if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) { smaError("vgId:%d, table %" PRIi64 " level %d serialize rsma task failed since %s", vid, pRSmaInfo->suid, i + 1, terrstr(terrno)); goto _err; - } else { - if (!pOutput) { - smaDebug("vgId:%d, table %" PRIi64 - " level %d serialize rsma task success but no output(len %d) and no need to persist", - vid, pRSmaInfo->suid, i + 1, len); - continue; - } else if (len <= 0) { - smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d and no need to persist", - vid, pRSmaInfo->suid, i + 1, len); - taosMemoryFree(pOutput); - } - smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d and need persist", vid, - pRSmaInfo->suid, i + 1, len); -#if 1 - if (qDeserializeTaskStatus(taskInfo, pOutput, len) < 0) { - smaError("vgId:%d, table %" PRIi64 "level %d deserialize rsma task failed since %s", vid, pRSmaInfo->suid, - i + 1, terrstr(terrno)); - } else { - smaDebug("vgId:%d, table %" PRIi64 " level %d deserialize rsma task success", vid, pRSmaInfo->suid, i + 1); - } -#endif } + if (!pOutput || len <= 0) { + smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success but no output(len %d), not persist", + vid, pRSmaInfo->suid, i + 1, len); + taosMemoryFreeClear(pOutput); + continue; + } + + smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d, need persist", vid, + pRSmaInfo->suid, i + 1, len); +#if 0 + if (qDeserializeTaskStatus(taskInfo, pOutput, len) < 0) { + smaError("vgId:%d, table %" PRIi64 "level %d deserialize rsma task failed since %s", vid, pRSmaInfo->suid, + i + 1, terrstr(terrno)); + } else { + smaDebug("vgId:%d, table %" PRIi64 " level %d deserialize rsma task success", vid, pRSmaInfo->suid, i + 1); + } +#endif if (!isFileCreated) { char qTaskInfoFName[TSDB_FILENAME_LEN]; - tdRSmaQTaskGetFName(vid, TD_QTASK_TMP_FILE, qTaskInfoFName); + tdRSmaQTaskInfoGetFName(vid, TD_QTASK_TMP_FILE, qTaskInfoFName); tdInitTFile(&tFile, pTfs, qTaskInfoFName); tdCreateTFile(&tFile, pTfs, true, -1); isFileCreated = true; } - len += (sizeof(len) + sizeof(pRSmaInfo->suid)); - tdAppendTFile(&tFile, &len, sizeof(len), &toffset); - tdAppendTFile(&tFile, &pRSmaInfo->suid, sizeof(pRSmaInfo->suid), &toffset); + + char tmpBuf[RSMA_QTASKINFO_HEAD_LEN] = {0}; + void *pTmpBuf = &tmpBuf; + int32_t headLen = 0; + headLen += taosEncodeFixedI32(&pTmpBuf, len + RSMA_QTASKINFO_HEAD_LEN); + headLen += taosEncodeFixedI8(&pTmpBuf, type); + headLen += taosEncodeFixedI64(&pTmpBuf, pRSmaInfo->suid); + + ASSERT(headLen <= RSMA_QTASKINFO_HEAD_LEN); + tdAppendTFile(&tFile, (void *)&tmpBuf, headLen, &toffset); + smaDebug("vgId:%d, table %" PRIi64 " level %d head part len:%d appended to offset:%" PRIi64, vid, pRSmaInfo->suid, + i + 1, headLen, toffset); tdAppendTFile(&tFile, pOutput, len, &toffset); + smaDebug("vgId:%d, table %" PRIi64 " level %d body part len:%d appended to offset:%" PRIi64, vid, pRSmaInfo->suid, + i + 1, len, toffset); taosMemoryFree(pOutput); } + infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), infoHash); } _normal: if (isFileCreated) { if (tdUpdateTFileHeader(&tFile) < 0) { - smaError("vgId:%d, failed to update tfile %s header since %s", vid, TD_FILE_FULL_NAME(&tFile), tstrerror(terrno)); + smaError("vgId:%d, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile), + tstrerror(terrno)); tdCloseTFile(&tFile); tdRemoveTFile(&tFile); goto _err; } else { - smaDebug("vgId:%d, succeed to update tfile %s header", vid, TD_FILE_FULL_NAME(&tFile)); + smaDebug("vgId:%d, succeed to update tfile %s header", vid, TD_TFILE_FULL_NAME(&tFile)); } tdCloseTFile(&tFile); char newFName[TSDB_FILENAME_LEN]; - strncpy(newFName, TD_FILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); + strncpy(newFName, TD_TFILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_FILE]); strncpy(pos, tdQTaskInfoFname[TD_QTASK_CUR_FILE], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); - if (taosRenameFile(TD_FILE_FULL_NAME(&tFile), newFName) != 0) { - smaError("vgId:%d, failed to rename %s to %s", vid, TD_FILE_FULL_NAME(&tFile), newFName); + if (taosRenameFile(TD_TFILE_FULL_NAME(&tFile), newFName) != 0) { + smaError("vgId:%d, failed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); goto _err; } else { - smaDebug("vgId:%d, succeed to rename %s to %s", vid, TD_FILE_FULL_NAME(&tFile), newFName); + smaDebug("vgId:%d, succeed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); } } goto _end; @@ -802,13 +1098,14 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { if (TASK_TRIGGER_STAT_INACTIVE == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INACTIVE, TASK_TRIGGER_STAT_ACTIVE)) { - smaDebug("persist task is active again"); + smaDebug("vgId:%d, persist task is active again", SMA_VID(pRSmaStat->pSma)); } else if (TASK_TRIGGER_STAT_CANCELLED == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { - smaDebug(" persist task is cancelled and set finished"); + smaDebug("vgId:%d, persist task is cancelled and set finished", SMA_VID(pRSmaStat->pSma)); } else { - smaWarn("persist task in abnormal stat %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); + smaWarn("vgId:%d, persist task in abnormal stat %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)), + SMA_VID(pRSmaStat->pSma)); ASSERT(0); } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); @@ -825,7 +1122,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { */ static void tdRSmaPersistTrigger(void *param, void *tmrId) { SRSmaStat *pRSmaStat = param; - int8_t tmrStat = + + int8_t tmrStat = atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); switch (tmrStat) { case TASK_TRIGGER_STAT_ACTIVE: { @@ -833,25 +1131,29 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { if (TASK_TRIGGER_STAT_CANCELLED != atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { - smaDebug("%s:%d rsma persistence start since active", __func__, __LINE__); + smaDebug("vgId:%d, rsma persistence start since active", SMA_VID(pRSmaStat->pSma)); + + // start persist task tdRSmaPersistTask(pRSmaStat); - taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId); + + taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASKINFO_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, + &pRSmaStat->tmrId); } else { atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); } } break; case TASK_TRIGGER_STAT_CANCELLED: { atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED); - smaDebug("%s:%d rsma persistence not start since cancelled and finished", __func__, __LINE__); + smaDebug("rsma persistence not start since cancelled and finished"); } break; case TASK_TRIGGER_STAT_INACTIVE: { - smaDebug("%s:%d rsma persistence not start since inactive", __func__, __LINE__); + smaDebug("rsma persistence not start since inactive"); } break; case TASK_TRIGGER_STAT_INIT: { - smaDebug("%s:%d rsma persistence not start since init", __func__, __LINE__); + smaDebug("rsma persistence not start since init"); } break; default: { - smaWarn("%s:%d rsma persistence not start since unknown stat %" PRIi8, __func__, __LINE__, tmrStat); + smaWarn("rsma persistence not start since unknown stat %" PRIi8, tmrStat); } break; } -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 85fddebf55..5f78aadddf 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -17,14 +17,11 @@ // smaFileUtil ================ -#define TD_FILE_HEAD_SIZE 512 - #define TD_FILE_STATE_OK 0 #define TD_FILE_STATE_BAD 1 #define TD_FILE_INIT_MAGIC 0xFFFFFFFF - static int32_t tdEncodeTFInfo(void **buf, STFInfo *pInfo); static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo); @@ -48,7 +45,7 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) { } int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte) { - ASSERT(TD_FILE_OPENED(pTFile)); + ASSERT(TD_TFILE_OPENED(pTFile)); int64_t nwrite = taosWriteFile(pTFile->pFile, buf, nbyte); if (nwrite < nbyte) { @@ -60,9 +57,9 @@ int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte) { } int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence) { - ASSERT(TD_FILE_OPENED(pTFile)); + ASSERT(TD_TFILE_OPENED(pTFile)); - int64_t loffset = taosLSeekFile(TD_FILE_PFILE(pTFile), offset, whence); + int64_t loffset = taosLSeekFile(TD_TFILE_PFILE(pTFile), offset, whence); if (loffset < 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -71,8 +68,13 @@ int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence) { return loffset; } +int64_t tdGetTFileSize(STFile *pTFile, int64_t *size) { + ASSERT(TD_TFILE_OPENED(pTFile)); + return taosFStatFile(pTFile->pFile, size, NULL); +} + int64_t tdReadTFile(STFile *pTFile, void *buf, int64_t nbyte) { - ASSERT(TD_FILE_OPENED(pTFile)); + ASSERT(TD_TFILE_OPENED(pTFile)); int64_t nread = taosReadFile(pTFile->pFile, buf, nbyte); if (nread < 0) { @@ -105,7 +107,7 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo) { char buf[TD_FILE_HEAD_SIZE] = "\0"; uint32_t _version; - ASSERT(TD_FILE_OPENED(pTFile)); + ASSERT(TD_TFILE_OPENED(pTFile)); if (tdSeekTFile(pTFile, 0, SEEK_SET) < 0) { return -1; @@ -130,7 +132,7 @@ void tdUpdateTFileMagic(STFile *pTFile, void *pCksm) { } int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset) { - ASSERT(TD_FILE_OPENED(pTFile)); + ASSERT(TD_TFILE_OPENED(pTFile)); int64_t toffset; @@ -138,6 +140,11 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset) return -1; } +#if 1 + smaDebug("append to file %s, offset:%" PRIi64 " + nbyte:%" PRIi64 " =%" PRIi64, TD_TFILE_FULL_NAME(pTFile), toffset, + nbyte, toffset + nbyte); +#endif + ASSERT(pTFile->info.fsize == toffset); if (offset) { @@ -154,9 +161,9 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset) } int32_t tdOpenTFile(STFile *pTFile, int flags) { - ASSERT(!TD_FILE_OPENED(pTFile)); + ASSERT(!TD_TFILE_OPENED(pTFile)); - pTFile->pFile = taosOpenFile(TD_FILE_FULL_NAME(pTFile), flags); + pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), flags); if (pTFile->pFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -166,9 +173,9 @@ int32_t tdOpenTFile(STFile *pTFile, int flags) { } void tdCloseTFile(STFile *pTFile) { - if (TD_FILE_OPENED(pTFile)) { + if (TD_TFILE_OPENED(pTFile)) { taosCloseFile(&pTFile->pFile); - TD_FILE_SET_CLOSED(pTFile); + TD_TFILE_SET_CLOSED(pTFile); } } @@ -180,8 +187,8 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) { char fullname[TSDB_FILENAME_LEN]; SDiskID did = {0}; - TD_FILE_SET_STATE(pTFile, TD_FILE_STATE_OK); - TD_FILE_SET_CLOSED(pTFile); + TD_TFILE_SET_STATE(pTFile, TD_FILE_STATE_OK); + TD_TFILE_SET_CLOSED(pTFile); memset(&(pTFile->info), 0, sizeof(pTFile->info)); pTFile->info.magic = TD_FILE_INIT_MAGIC; @@ -199,18 +206,18 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) { int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fType) { ASSERT(pTFile->info.fsize == 0 && pTFile->info.magic == TD_FILE_INIT_MAGIC); - pTFile->pFile = taosOpenFile(TD_FILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pTFile->pFile == NULL) { if (errno == ENOENT) { // Try to create directory recursively - char *s = strdup(TD_FILE_REL_NAME(pTFile)); - if (tfsMkdirRecurAt(pTfs, taosDirName(s), TD_FILE_DID(pTFile)) < 0) { + char *s = strdup(TD_TFILE_REL_NAME(pTFile)); + if (tfsMkdirRecurAt(pTfs, taosDirName(s), TD_TFILE_DID(pTFile)) < 0) { taosMemoryFreeClear(s); return -1; } taosMemoryFreeClear(s); - pTFile->pFile = taosOpenFile(TD_FILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + pTFile->pFile = taosOpenFile(TD_TFILE_FULL_NAME(pTFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pTFile->pFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -237,7 +244,7 @@ int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fTyp return 0; } -int32_t tdRemoveTFile(STFile *pTFile) { return tfsRemoveFile(TD_FILE_F(pTFile)); } +int32_t tdRemoveTFile(STFile *pTFile) { return tfsRemoveFile(TD_TFILE_F(pTFile)); } // smaXXXUtil ================ // ... \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index bd40fd4a1f..03f18cc766 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2886,6 +2886,9 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) { */ int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) { SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid); + if(!pCur) { + return TSDB_CODE_FAILED; + } while (1) { tb_uid_t id = metaStbCursorNext(pCur); diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 2834e0a2e7..57d7386667 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -152,14 +152,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { return pVnode; _err: - if (pVnode->pSma) smaClose(pVnode->pSma); + if (pVnode->pSma) smaCloseEnv(pVnode->pSma); if (pVnode->pQuery) vnodeQueryClose(pVnode); if (pVnode->pTq) tqClose(pVnode->pTq); if (pVnode->pWal) walClose(pVnode->pWal); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); + if (pVnode->pSma) smaCloseEx(pVnode->pSma); if (pVnode->pMeta) metaClose(pVnode->pMeta); - tsem_destroy(&(pVnode->canCommit)); taosMemoryFree(pVnode); return NULL; @@ -172,9 +172,9 @@ void vnodeClose(SVnode *pVnode) { vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); walClose(pVnode->pWal); - smaCloseEx(pVnode->pSma); tqClose(pVnode->pTq); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); + smaCloseEx(pVnode->pSma); metaClose(pVnode->pMeta); vnodeCloseBufPool(pVnode); // destroy handle diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 88bdea3ae7..72c766e0ae 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -299,7 +299,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, int64_t version, SRpcMsg *pMsg, SRp void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { // TODO - blockDebugShowData(data, __func__); + blockDebugShowDataBlocks(data, __func__); tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index b998f40195..d324a76438 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -243,7 +243,7 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { char *syncNodeStr = sync2SimpleStr(pVnode->sync); static int64_t vndTick = 0; if (++vndTick % 10 == 1) { - vGTrace("vgId:%d, sync heartbeat msg:%s, %s", syncGetVgId(pVnode->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); + vGTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pVnode->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); } if (gRaftDetailLog) { char logBuf[512] = {0}; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 29dd2b1656..1cc3f9b874 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -730,10 +730,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo); - -SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, int32_t numStreams, SSDataBlock* pInputBlock, - SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pColMatchColInfo, - SExecTaskInfo* pTaskInfo); +SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, @@ -811,7 +808,7 @@ int32_t getMaximumIdleDurationSec(); * nOptrWithVal: *nOptrWithVal save the number of optr with value * return: result code, 0 means success */ -int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length); +int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length, int32_t *nOptrWithVal); /* * ops: root operator, created by caller diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index 35bdd4ee55..972f4469e4 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -136,6 +136,13 @@ bool tsortIsNullVal(STupleHandle* pVHandle, int32_t colId); */ void* tsortGetValue(STupleHandle* pVHandle, int32_t colId); +/** + * + * @param pVHandle + * @return + */ +uint64_t tsortGetGroupId(STupleHandle* pVHandle); + /** * * @param pSortHandle diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 374a3a736d..be6ca5145a 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -159,7 +159,12 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { } SArray* createSortInfo(SNodeList* pNodeList) { - size_t numOfCols = LIST_LENGTH(pNodeList); + size_t numOfCols = 0; + if (pNodeList != NULL) { + numOfCols = LIST_LENGTH(pNodeList); + } else { + numOfCols = 0; + } SArray* pList = taosArrayInit(numOfCols, sizeof(SBlockOrderInfo)); if (pList == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index a9e1e03178..e4c0959185 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -222,7 +222,13 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) { return TSDB_CODE_INVALID_PARA; } - return encodeOperator(pTaskInfo->pRoot, pOutput, len); + int32_t nOptrWithVal = 0; + int32_t code = encodeOperator(pTaskInfo->pRoot, pOutput, len, &nOptrWithVal); + if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal = 0)) { + taosMemoryFreeClear(*pOutput); + *len = 0; + } + return code; } int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ff3baf64bd..ad0d5c1447 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -273,8 +273,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR } // 1. close current opened time window - if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId && - pResult->offset != pResultRowInfo->cur.offset))) { + if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) { SResultRowPosition pos = pResultRowInfo->cur; SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); releaseBufPage(pResultBuf, pPage); @@ -4269,17 +4268,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createGroupSortOperatorInfo(ops[0], (SGroupSortPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == type) { SMergePhysiNode* pMergePhyNode = (SMergePhysiNode*)pPhyNode; - - SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc; - SSDataBlock* pResBlock = createResDataBlock(pDescNode); - - SArray* sortInfo = createSortInfo(pMergePhyNode->pMergeKeys); - int32_t numOfOutputCols = 0; - SArray* pColList = - extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); - SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); - SSDataBlock* pInputDataBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc); - pOptr = createMultiwaySortMergeOperatorInfo(ops, size, pInputDataBlock, pResBlock, sortInfo, pColList, pTaskInfo); + pOptr = createMultiwayMergeOperatorInfo(ops, size, pMergePhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION == type) { SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; @@ -4472,12 +4461,12 @@ int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHa return 0; } -int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { +int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length, int32_t* nOptrWithVal) { int32_t code = TDB_CODE_SUCCESS; char* pCurrent = NULL; int32_t currLength = 0; if (ops->fpSet.encodeResultRow) { - if (result == NULL || length == NULL) { + if (result == NULL || length == NULL || nOptrWithVal == NULL) { return TSDB_CODE_TSC_INVALID_INPUT; } code = ops->fpSet.encodeResultRow(ops, &pCurrent, &currLength); @@ -4488,8 +4477,13 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { *result = NULL; } return code; + } else if (currLength == 0) { + ASSERT(!pCurrent); + goto _downstream; } - + + ++(*nOptrWithVal); + ASSERT(currLength >= 0); if (*result == NULL) { @@ -4516,8 +4510,10 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { taosMemoryFree(pCurrent); *length = *(int32_t*)(*result); } + +_downstream: for (int32_t i = 0; i < ops->numOfDownstream; ++i) { - code = encodeOperator(ops->pDownstream[i], result, length); + code = encodeOperator(ops->pDownstream[i], result, length, nOptrWithVal); if (code != TDB_CODE_SUCCESS) { return code; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index d89e6f8874..c51ef44154 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -2051,7 +2051,7 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId); return TSDB_CODE_SUCCESS; } - code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pGroupTags); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2455,7 +2455,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN if (pInfo == NULL || pOperator == NULL) { goto _error; } - if (pTableScanNode->pPartitionTags) { + if (pTableScanNode->pGroupTags) { taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid); } diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 09cc4e47be..44ff4c1c90 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -142,7 +142,8 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i SSDataBlock* loadNextDataBlock(void* param) { SOperatorInfo* pOperator = (SOperatorInfo*)param; - return pOperator->fpSet.getNextFn(pOperator); + SSDataBlock* pBlock = pOperator->fpSet.getNextFn(pOperator); + return pBlock; } // todo refactor: merged with fetch fp @@ -442,7 +443,7 @@ void destroyGroupSortOperatorInfo(void* param, int32_t numOfOutput) { SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo) { SGroupSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupSortOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) { goto _error; } @@ -474,8 +475,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort pOperator->exprSupp.numOfExprs = numOfCols; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, NULL, - NULL, getGroupSortExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, + NULL, NULL, getGroupSortExplainExecInfo); int32_t code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -493,7 +494,7 @@ _error: //===================================================================================== // Multiway Sort Merge operator -typedef struct SMultiwaySortMergeOperatorInfo { +typedef struct SMultiwayMergeOperatorInfo { SOptrBasicInfo binfo; int32_t bufPageSize; @@ -503,14 +504,17 @@ typedef struct SMultiwaySortMergeOperatorInfo { SSortHandle* pSortHandle; SArray* pColMatchInfo; // for index map from table scan output - SSDataBlock* pInputBlock; - int64_t startTs; // sort start time - uint64_t groupId; -} SMultiwaySortMergeOperatorInfo; + SSDataBlock* pInputBlock; + int64_t startTs; // sort start time + bool groupSort; + bool hasGroupId; + uint64_t groupId; + STupleHandle* prefetchedTuple; +} SMultiwayMergeOperatorInfo; -int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; +int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) { + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; if (OPTR_IS_OPENED(pOperator)) { return TSDB_CODE_SUCCESS; @@ -524,8 +528,9 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { pInfo->pInputBlock, pTaskInfo->id.str); tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL); - tsortSetCompareGroupId(pInfo->pSortHandle, true); - + + tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort); + for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) { SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource)); ps->param = pOperator->pDownstream[i]; @@ -547,8 +552,8 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, SArray* pColMatchInfo, SOperatorInfo* pOperator) { - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; blockDataCleanup(pDataBlock); @@ -560,18 +565,47 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData blockDataEnsureCapacity(p, capacity); while (1) { - STupleHandle* pTupleHandle = tsortNextTuple(pHandle); + STupleHandle* pTupleHandle = NULL; + if (pInfo->groupSort) { + if (pInfo->prefetchedTuple == NULL) { + pTupleHandle = tsortNextTuple(pHandle); + } else { + pTupleHandle = pInfo->prefetchedTuple; + pInfo->groupId = tsortGetGroupId(pTupleHandle); + pInfo->prefetchedTuple = NULL; + } + } + else { + pTupleHandle = tsortNextTuple(pHandle); + pInfo->groupId = 0; + } + if (pTupleHandle == NULL) { break; } - appendOneRowToDataBlock(p, pTupleHandle); + if (pInfo->groupSort) + { + uint64_t tupleGroupId = tsortGetGroupId(pTupleHandle); + if (!pInfo->hasGroupId) { + pInfo->groupId = tupleGroupId; + pInfo->hasGroupId = true; + appendOneRowToDataBlock(p, pTupleHandle); + } else if (pInfo->groupId == tupleGroupId) { + appendOneRowToDataBlock(p, pTupleHandle); + } else { + pInfo->prefetchedTuple = pTupleHandle; + break; + } + } else { + appendOneRowToDataBlock(p, pTupleHandle); + } if (p->info.rows >= capacity) { break; } } - if (p->info.rows > 0) {// todo extract method + if (p->info.rows > 0) { // todo extract method blockDataEnsureCapacity(pDataBlock, p->info.rows); int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { @@ -593,13 +627,13 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; } -SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { +SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; int32_t code = pOperator->fpSet._openFn(pOperator); if (code != TSDB_CODE_SUCCESS) { @@ -608,7 +642,6 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { SSDataBlock* pBlock = getMultiwaySortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, pInfo->pColMatchInfo, pOperator); - if (pBlock != NULL) { pOperator->resultInfo.totalRows += pBlock->info.rows; } else { @@ -617,8 +650,8 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { return pBlock; } -void destroyMultiwaySortMergeOperatorInfo(void* param, int32_t numOfOutput) { - SMultiwaySortMergeOperatorInfo* pInfo = (SMultiwaySortMergeOperatorInfo*)param; +void destroyMultiwayMergeOperatorInfo(void* param, int32_t numOfOutput) { + SMultiwayMergeOperatorInfo* pInfo = (SMultiwayMergeOperatorInfo*)param; pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes); pInfo->pInputBlock = blockDataDestroy(pInfo->pInputBlock); @@ -626,11 +659,11 @@ void destroyMultiwaySortMergeOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pColMatchInfo); } -int32_t getMultiwaySortMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { +int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { ASSERT(pOptr != NULL); SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo)); - SMultiwaySortMergeOperatorInfo* pOperatorInfo = (SMultiwaySortMergeOperatorInfo*)pOptr->info; + SMultiwayMergeOperatorInfo* pOperatorInfo = (SMultiwayMergeOperatorInfo*)pOptr->info; *pInfo = tsortGetSortExecInfo(pOperatorInfo->pSortHandle); *pOptrExplain = pInfo; @@ -638,24 +671,35 @@ int32_t getMultiwaySortMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrEx return TSDB_CODE_SUCCESS; } -SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, int32_t numStreams, - SSDataBlock* pInputBlock, SSDataBlock* pResBlock, SArray* pSortInfo, - SArray* pColMatchColInfo, SExecTaskInfo* pTaskInfo) { - SMultiwaySortMergeOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SMultiwaySortMergeOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - int32_t rowSize = pResBlock->info.rowSize; +SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size_t numStreams, + SMergePhysiNode* pMergePhyNode, SExecTaskInfo* pTaskInfo) { + SPhysiNode* pPhyNode = (SPhysiNode*)pMergePhyNode; + + SMultiwayMergeOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SMultiwayMergeOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc; + SSDataBlock* pResBlock = createResDataBlock(pDescNode); + + int32_t rowSize = pResBlock->info.rowSize; if (pInfo == NULL || pOperator == NULL || rowSize > 100 * 1024 * 1024) { goto _error; } + SArray* pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys); + int32_t numOfOutputCols = 0; + SArray* pColMatchColInfo = + extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); + SSDataBlock* pInputBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc); initResultSizeInfo(pOperator, 1024); + pInfo->groupSort = pMergePhyNode->groupSort; pInfo->binfo.pRes = pResBlock; pInfo->pSortInfo = pSortInfo; pInfo->pColMatchInfo = pColMatchColInfo; pInfo->pInputBlock = pInputBlock; - pOperator->name = "MultiwaySortMerge"; + pOperator->name = "MultiwayMerge"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE; pOperator->blocking = false; pOperator->status = OP_NOT_OPENED; @@ -667,9 +711,8 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, // one additional is reserved for merged result. pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); - pOperator->fpSet = - createOperatorFpSet(doOpenMultiwaySortMergeOperator, doMultiwaySortMerge, NULL, NULL, - destroyMultiwaySortMergeOperatorInfo, NULL, NULL, getMultiwaySortMergeExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, NULL, + destroyMultiwayMergeOperatorInfo, NULL, NULL, getMultiwayMergeExplainExecInfo); int32_t code = appendDownstream(pOperator, downStreams, numStreams); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 50474ff62e..7d44d41b55 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -752,6 +752,10 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) { } } +uint64_t tsortGetGroupId(STupleHandle* pVHandle) { + return pVHandle->pBlock->info.groupId; +} + SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) { SSortExecInfo info = {0}; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 0820e884ce..f7e22cb151 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -191,6 +191,11 @@ bool getUniqueFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool uniqueFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t uniqueFunction(SqlFunctionCtx *pCtx); +bool getModeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool modeFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +int32_t modeFunction(SqlFunctionCtx *pCtx); +int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); + bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool twaFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t twaFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index d41bc89a5f..fbebb12cc3 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1045,20 +1045,29 @@ static int32_t translateFirstLastMerge(SFunctionNode* pFunc, char* pErrBuf, int3 return translateFirstLastImpl(pFunc, pErrBuf, len, false); } -static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { +static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isUnique) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); if (!nodesExprHasColumn(pPara)) { - return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of UNIQUE must contain columns"); + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of %s must contain columns", + isUnique ? "UNIQUE" : "MODE"); } pFunc->node.resType = ((SExprNode*)pPara)->resType; return TSDB_CODE_SUCCESS; } +static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateUniqueMode(pFunc, pErrBuf, len, true); +} + +static int32_t translateMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateUniqueMode(pFunc, pErrBuf, len, false); +} + static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); if (numOfParams == 0 || numOfParams > 2) { @@ -1220,19 +1229,19 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // The number of parameters has been limited by the syntax definition - //uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + // uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; // The function return type has been set during syntax parsing uint8_t para2Type = pFunc->node.resType.type; - //if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT && - // para2Type != TSDB_DATA_TYPE_VARCHAR && para2Type != TSDB_DATA_TYPE_NCHAR && - // para2Type != TSDB_DATA_TYPE_TIMESTAMP) { - // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); - //} - //if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) || - // (para2Type == TSDB_DATA_TYPE_BINARY && para1Type == TSDB_DATA_TYPE_NCHAR)) { - // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); - //} + // if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT && + // para2Type != TSDB_DATA_TYPE_VARCHAR && para2Type != TSDB_DATA_TYPE_NCHAR && + // para2Type != TSDB_DATA_TYPE_TIMESTAMP) { + // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + // } + // if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) || + // (para2Type == TSDB_DATA_TYPE_BINARY && para1Type == TSDB_DATA_TYPE_NCHAR)) { + // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + // } int32_t para2Bytes = pFunc->node.resType.bytes; if (IS_VAR_DATA_TYPE(para2Type)) { @@ -1882,7 +1891,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "first", .type = FUNCTION_TYPE_FIRST, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1917,7 +1926,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last", .type = FUNCTION_TYPE_LAST, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2109,7 +2118,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "unique", .type = FUNCTION_TYPE_UNIQUE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | + .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC, .translateFunc = translateUnique, .getEnvFunc = getUniqueFuncEnv, @@ -2117,6 +2126,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .processFunc = uniqueFunction, .finalizeFunc = NULL }, + { + .name = "mode", + .type = FUNCTION_TYPE_MODE, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateMode, + .getEnvFunc = getModeFuncEnv, + .initFunc = modeFunctionSetup, + .processFunc = modeFunction, + .finalizeFunc = modeFinalize, + }, { .name = "abs", .type = FUNCTION_TYPE_ABS, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index c4d3a26ab4..06f24f39e7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -32,6 +32,7 @@ #define TAIL_MAX_OFFSET 100 #define UNIQUE_MAX_RESULT_SIZE (1024 * 1024 * 10) +#define MODE_MAX_RESULT_SIZE UNIQUE_MAX_RESULT_SIZE #define HLL_BUCKET_BITS 14 // The bits of the bucket #define HLL_DATA_BITS (64 - HLL_BUCKET_BITS) @@ -246,6 +247,19 @@ typedef struct SUniqueInfo { char pItems[]; } SUniqueInfo; +typedef struct SModeItem { + int64_t count; + char data[]; +} SModeItem; + +typedef struct SModeInfo { + int32_t numOfPoints; + uint8_t colType; + int16_t colBytes; + SHashObj* pHash; + char pItems[]; +} SModeInfo; + typedef struct SDerivInfo { double prevValue; // previous value TSKEY prevTs; // previous timestamp @@ -4694,21 +4708,100 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { return pInfo->numOfPoints; } -int32_t uniqueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { +bool getModeFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { + pEnv->calcMemSize = sizeof(SModeInfo) + MODE_MAX_RESULT_SIZE; + return true; +} + +bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { + if (!functionSetup(pCtx, pResInfo)) { + return false; + } + + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + pInfo->numOfPoints = 0; + pInfo->colType = pCtx->resDataInfo.type; + pInfo->colBytes = pCtx->resDataInfo.bytes; + if (pInfo->pHash != NULL) { + taosHashClear(pInfo->pHash); + } else { + pInfo->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + } + return true; +} + +static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) { + // ignore null elements + if (isNull) { + return; + } + + int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + if (pHashItem == NULL) { + int32_t size = sizeof(SModeItem) + pInfo->colBytes; + SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); + memcpy(pItem->data, data, pInfo->colBytes); + pItem->count += 1; + + taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); + pInfo->numOfPoints++; + } else { + (*pHashItem)->count += 1; + } +} + +int32_t modeFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SUniqueInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + + SInputColumnInfoData* pInput = &pCtx->input; + + SColumnInfoData* pInputCol = pInput->pData[0]; + SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; + + int32_t startOffset = pCtx->offset; + for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) { + char* data = colDataGetData(pInputCol, i); + doModeAdd(pInfo, data, colDataIsNull_s(pInputCol, i)); + + if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) { + taosHashCleanup(pInfo->pHash); + return TSDB_CODE_OUT_OF_MEMORY; + } + } + + SET_VAL(pResInfo, 1, 1); + + return TSDB_CODE_SUCCESS; +} + +int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + int32_t currentRow = pBlock->info.rows; - for (int32_t i = 0; i < pResInfo->numOfRes; ++i) { - SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); - colDataAppend(pCol, i, pItem->data, false); - // TODO: handle ts output + int32_t resIndex; + int32_t maxCount = 0; + for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { + SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes)); + if (pItem->count > maxCount) { + maxCount = pItem->count; + resIndex = i; + } else if (pItem->count == maxCount) { + resIndex = -1; + } } + SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); + colDataAppend(pCol, currentRow, pResItem->data, (resIndex == -1) ? true : false); + return pResInfo->numOfRes; } + bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(STwaInfo); return true; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 983cffe9dc..364ee0692f 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -110,7 +110,7 @@ static void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t udfdFillUdfInfoFromMNode(void *clientRpc, char *udfName, SUdf *udf); static int32_t udfdConnectToMnode(); static int32_t udfdLoadUdf(char *udfName, SUdf *udf); -static bool udfdRpcRfp(int32_t code); +static bool udfdRpcRfp(int32_t code, tmsg_t msgType); static int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet); static int32_t udfdOpenClientRpc(); static int32_t udfdCloseClientRpc(); @@ -546,9 +546,12 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { } return 0; } -static bool udfdRpcRfp(int32_t code) { +static bool udfdRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/libs/function/test/udf1.c b/source/libs/function/test/udf1.c index 9443d5cb94..dfbae357ef 100644 --- a/source/libs/function/test/udf1.c +++ b/source/libs/function/test/udf1.c @@ -2,12 +2,8 @@ #include #include -#include "tudf.h" +#include "taosudf.h" -#undef malloc -#define malloc malloc -#undef free -#define free free DLL_EXPORT int32_t udf1_init() { return 0; diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index 1c270f5cf4..975832209e 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -1,13 +1,9 @@ #include #include #include +#include -#include "tudf.h" - -#undef malloc -#define malloc malloc -#undef free -#define free free +#include "taosudf.h" DLL_EXPORT int32_t udf2_init() { return 0; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index ac197912cf..b372bf75fc 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -100,6 +100,7 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); + COPY_SCALAR_FIELD(orderAlias); return TSDB_CODE_SUCCESS; } @@ -351,7 +352,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(tsColId); COPY_SCALAR_FIELD(filesFactor); - CLONE_NODE_LIST_FIELD(pPartTags); + CLONE_NODE_LIST_FIELD(pGroupTags); return TSDB_CODE_SUCCESS; } @@ -401,6 +402,7 @@ static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst CLONE_NODE_LIST_FIELD(pInputs); COPY_SCALAR_FIELD(numOfChannels); COPY_SCALAR_FIELD(srcGroupId); + COPY_SCALAR_FIELD(groupSort); return TSDB_CODE_SUCCESS; } @@ -436,6 +438,7 @@ static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pSortKeys); + COPY_SCALAR_FIELD(groupSort); return TSDB_CODE_SUCCESS; } @@ -500,7 +503,7 @@ static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhy COPY_SCALAR_FIELD(ratio); COPY_SCALAR_FIELD(dataRequired); CLONE_NODE_LIST_FIELD(pDynamicScanFuncs); - CLONE_NODE_LIST_FIELD(pPartitionTags); + CLONE_NODE_LIST_FIELD(pGroupTags); COPY_SCALAR_FIELD(interval); COPY_SCALAR_FIELD(offset); COPY_SCALAR_FIELD(sliding); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 514d65d52e..df7429bd88 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -234,6 +234,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiMerge"; case QUERY_NODE_PHYSICAL_PLAN_SORT: return "PhysiSort"; + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: + return "PhysiGroupSort"; case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: return "PhysiHashInterval"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: @@ -539,7 +541,7 @@ static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols"; static const char* jkScanLogicPlanTableId = "TableId"; static const char* jkScanLogicPlanTableType = "TableType"; static const char* jkScanLogicPlanTagCond = "TagCond"; -static const char* jkScanLogicPlanPartTags = "PartTags"; +static const char* jkScanLogicPlanGroupTags = "GroupTags"; static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { const SScanLogicNode* pNode = (const SScanLogicNode*)pObj; @@ -561,7 +563,7 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond); } if (TSDB_CODE_SUCCESS == code) { - code = nodeListToJson(pJson, jkScanLogicPlanPartTags, pNode->pPartTags); + code = nodeListToJson(pJson, jkScanLogicPlanGroupTags, pNode->pGroupTags); } return code; @@ -588,7 +590,7 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) { code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond); } if (TSDB_CODE_SUCCESS == code) { - code = jsonToNodeList(pJson, jkScanLogicPlanPartTags, &pNode->pPartTags); + code = jsonToNodeList(pJson, jkScanLogicPlanGroupTags, &pNode->pGroupTags); } return code; @@ -1430,7 +1432,8 @@ static const char* jkTableScanPhysiPlanTriggerType = "triggerType"; static const char* jkTableScanPhysiPlanWatermark = "watermark"; static const char* jkTableScanPhysiPlanTsColId = "tsColId"; static const char* jkTableScanPhysiPlanFilesFactor = "FilesFactor"; -static const char* jkTableScanPhysiPlanPartitionTags = "PartitionTags"; +static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; +static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1485,7 +1488,10 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanFilesFactor, pNode->filesFactor); } if (TSDB_CODE_SUCCESS == code) { - code = nodeListToJson(pJson, jkTableScanPhysiPlanPartitionTags, pNode->pPartitionTags); + code = nodeListToJson(pJson, jkTableScanPhysiPlanGroupTags, pNode->pGroupTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanGroupSort, pNode->groupSort); } return code; @@ -1544,7 +1550,10 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanFilesFactor, &pNode->filesFactor); } if (TSDB_CODE_SUCCESS == code) { - code = jsonToNodeList(pJson, jkTableScanPhysiPlanPartitionTags, &pNode->pPartitionTags); + code = jsonToNodeList(pJson, jkTableScanPhysiPlanGroupTags, &pNode->pGroupTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanGroupSort, &pNode->groupSort); } return code; @@ -1725,6 +1734,7 @@ static const char* jkMergePhysiPlanMergeKeys = "MergeKeys"; static const char* jkMergePhysiPlanTargets = "Targets"; static const char* jkMergePhysiPlanNumOfChannels = "NumOfChannels"; static const char* jkMergePhysiPlanSrcGroupId = "SrcGroupId"; +static const char* jkMergePhysiPlanGroupSort = "GroupSort"; static int32_t physiMergeNodeToJson(const void* pObj, SJson* pJson) { const SMergePhysiNode* pNode = (const SMergePhysiNode*)pObj; @@ -1742,6 +1752,9 @@ static int32_t physiMergeNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkMergePhysiPlanSrcGroupId, pNode->srcGroupId); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkMergePhysiPlanGroupSort, pNode->groupSort); + } return code; } @@ -1762,6 +1775,9 @@ static int32_t jsonToPhysiMergeNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetIntValue(pJson, jkMergePhysiPlanSrcGroupId, &pNode->srcGroupId); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkMergePhysiPlanGroupSort, &pNode->groupSort); + } return code; } @@ -3369,6 +3385,7 @@ static const char* jkSlotDescSlotId = "SlotId"; static const char* jkSlotDescDataType = "DataType"; static const char* jkSlotDescReserve = "Reserve"; static const char* jkSlotDescOutput = "Output"; +static const char* jkSlotDescName = "Name"; static int32_t slotDescNodeToJson(const void* pObj, SJson* pJson) { const SSlotDescNode* pNode = (const SSlotDescNode*)pObj; @@ -3383,6 +3400,9 @@ static int32_t slotDescNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkSlotDescOutput, pNode->output); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkSlotDescName, pNode->name); + } return code; } @@ -3400,6 +3420,9 @@ static int32_t jsonToSlotDescNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkSlotDescOutput, &pNode->output); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkSlotDescName, pNode->name); + } return code; } @@ -4137,6 +4160,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_MERGE: return physiMergeNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_SORT: + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: return physiSortNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: @@ -4280,6 +4304,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_MERGE: return jsonToPhysiMergeNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_SORT: + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: return jsonToPhysiSortNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 1fb2db9f23..3747dde9ed 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -500,7 +500,8 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk } break; } - case QUERY_NODE_PHYSICAL_PLAN_SORT: { + case QUERY_NODE_PHYSICAL_PLAN_SORT: + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: { SSortPhysiNode* pSort = (SSortPhysiNode*)pNode; res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 734f287cfb..dc9d9b92ee 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -288,6 +288,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SMergePhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_SORT: return makeNode(type, sizeof(SSortPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: + return makeNode(type, sizeof(SGroupSortPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: return makeNode(type, sizeof(SIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: @@ -709,7 +711,7 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pLogicNode->pTagCond); nodesDestroyNode(pLogicNode->pTagIndexCond); taosArrayDestroy(pLogicNode->pSmaIndexes); - nodesDestroyList(pLogicNode->pPartTags); + nodesDestroyList(pLogicNode->pGroupTags); break; } case QUERY_NODE_LOGIC_PLAN_JOIN: { @@ -813,7 +815,7 @@ void nodesDestroyNode(SNode* pNode) { STableScanPhysiNode* pPhyNode = (STableScanPhysiNode*)pNode; destroyScanPhysiNode((SScanPhysiNode*)pNode); nodesDestroyList(pPhyNode->pDynamicScanFuncs); - nodesDestroyList(pPhyNode->pPartitionTags); + nodesDestroyList(pPhyNode->pGroupTags); break; } case QUERY_NODE_PHYSICAL_PLAN_PROJECT: { @@ -850,7 +852,8 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyList(pPhyNode->pTargets); break; } - case QUERY_NODE_PHYSICAL_PLAN_SORT: { + case QUERY_NODE_PHYSICAL_PLAN_SORT: + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: { SSortPhysiNode* pPhyNode = (SSortPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); nodesDestroyList(pPhyNode->pExprs); @@ -1497,7 +1500,8 @@ typedef struct SCollectFuncsCxt { static EDealRes collectFuncs(SNode* pNode, void* pContext) { SCollectFuncsCxt* pCxt = (SCollectFuncsCxt*)pContext; - if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId)) { + if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) && + !(((SExprNode*)pNode)->orderAlias)) { pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode)); return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index b68a4cc568..7106f8df96 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1355,25 +1355,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; } -static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode) { - SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); - if (NULL == pFunc) { - pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; - return DEAL_RES_ERROR; - } - - strcpy(pFunc->functionName, "_group_key"); - strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName); - pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode); - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - *pNode = (SNode*)pFunc; - pCxt->errCode = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len); - } - pCxt->pCurrSelectStmt->hasAggFuncs = true; - - return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); -} - static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext; if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) { @@ -1393,7 +1374,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { SNode* pGroupNode = NULL; FOREACH(pGroupNode, getGroupByList(pCxt->pTranslateCxt)) { if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) { - return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode); + return DEAL_RES_IGNORE_CHILD; + } + } + SNode* pPartKey = NULL; + FOREACH(pPartKey, pCxt->pTranslateCxt->pCurrSelectStmt->pPartitionByList) { + if (nodesEqualNode(pPartKey, *pNode)) { + return DEAL_RES_IGNORE_CHILD; } } if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { @@ -1451,25 +1438,6 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt* return pCxt->errCode; } -static EDealRes rewriteExprsToGroupKeyFuncImpl(SNode** pNode, void* pContext) { - STranslateContext* pCxt = pContext; - SNode* pPartKey = NULL; - FOREACH(pPartKey, pCxt->pCurrSelectStmt->pPartitionByList) { - if (nodesEqualNode(pPartKey, *pNode)) { - return rewriteExprToGroupKeyFunc(pCxt, pNode); - } - } - return DEAL_RES_CONTINUE; -} - -static int32_t rewriteExprsToGroupKeyFunc(STranslateContext* pCxt, SSelectStmt* pSelect) { - nodesRewriteExprs(pSelect->pProjectionList, rewriteExprsToGroupKeyFuncImpl, pCxt); - if (TSDB_CODE_SUCCESS == pCxt->errCode && !pSelect->isDistinct) { - nodesRewriteExprs(pSelect->pOrderByList, rewriteExprsToGroupKeyFuncImpl, pCxt); - } - return pCxt->errCode; -} - typedef struct CheckAggColCoexistCxt { STranslateContext* pTranslateCxt; bool existAggFunc; @@ -1529,9 +1497,6 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) if (cxt.existIndefiniteRowsFunc && cxt.existCol) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } - if (cxt.existAggFunc && NULL != pSelect->pPartitionByList) { - return rewriteExprsToGroupKeyFunc(pCxt, pSelect); - } return TSDB_CODE_SUCCESS; } @@ -2408,138 +2373,6 @@ static EDealRes rewriteSeletcValueFunc(STranslateContext* pCxt, SNode** pNode) { return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; } -static EDealRes rewriteUniqueFunc(SNode** pNode, void* pContext) { - SRwriteUniqueCxt* pCxt = pContext; - if (QUERY_NODE_FUNCTION == nodeType(*pNode)) { - SFunctionNode* pFunc = (SFunctionNode*)*pNode; - if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) { - SNode* pExpr = nodesListGetNode(pFunc->pParameterList, 0); - NODES_CLEAR_LIST(pFunc->pParameterList); - strcpy(((SExprNode*)pExpr)->aliasName, ((SExprNode*)*pNode)->aliasName); - nodesDestroyNode(*pNode); - *pNode = pExpr; - pCxt->pExpr = pExpr; - return DEAL_RES_IGNORE_CHILD; - } else if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) { - return rewriteSeletcValueFunc(pCxt->pTranslateCxt, pNode); - } - } - return DEAL_RES_CONTINUE; -} - -static SNode* createGroupingSet(SNode* pExpr) { - SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET); - if (NULL == pGroupingSet) { - return NULL; - } - pGroupingSet->groupingSetType = GP_TYPE_NORMAL; - if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, nodesCloneNode(pExpr))) { - nodesDestroyNode((SNode*)pGroupingSet); - return NULL; - } - return (SNode*)pGroupingSet; -} - -// from: select unique(expr), col1 + col2 from t where_clause partition_by_clause order_by_clause ... -// to: select expr, first(col1) + first(col2) from t where_clause partition_by_clause group by expr order_by_clause ... -static int32_t rewriteUniqueStmt(STranslateContext* pCxt, SSelectStmt* pSelect) { - if (!pSelect->hasUniqueFunc) { - return TSDB_CODE_SUCCESS; - } - - SRwriteUniqueCxt cxt = {.pTranslateCxt = pCxt, .pExpr = NULL}; - nodesRewriteExprs(pSelect->pProjectionList, rewriteUniqueFunc, &cxt); - if (TSDB_CODE_SUCCESS == cxt.pTranslateCxt->errCode) { - cxt.pTranslateCxt->errCode = nodesListMakeStrictAppend(&pSelect->pGroupByList, createGroupingSet(cxt.pExpr)); - } - pSelect->hasIndefiniteRowsFunc = false; - return cxt.pTranslateCxt->errCode; -} - -typedef struct SRwriteTailCxt { - STranslateContext* pTranslateCxt; - int64_t limit; - int64_t offset; -} SRwriteTailCxt; - -static EDealRes rewriteTailFunc(SNode** pNode, void* pContext) { - SRwriteTailCxt* pCxt = pContext; - if (QUERY_NODE_FUNCTION == nodeType(*pNode)) { - SFunctionNode* pFunc = (SFunctionNode*)*pNode; - if (FUNCTION_TYPE_TAIL == pFunc->funcType) { - pCxt->limit = ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i; - if (3 == LIST_LENGTH(pFunc->pParameterList)) { - pCxt->offset = ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 2))->datum.i; - } - SNode* pExpr = nodesListGetNode(pFunc->pParameterList, 0); - strcpy(((SExprNode*)pExpr)->aliasName, ((SExprNode*)*pNode)->aliasName); - NODES_CLEAR_LIST(pFunc->pParameterList); - nodesDestroyNode(*pNode); - *pNode = pExpr; - return DEAL_RES_IGNORE_CHILD; - } - } - return DEAL_RES_CONTINUE; -} - -static int32_t createLimieNode(SRwriteTailCxt* pCxt, SLimitNode** pOutput) { - *pOutput = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT); - if (NULL == *pOutput) { - return TSDB_CODE_OUT_OF_MEMORY; - } - (*pOutput)->limit = pCxt->limit; - (*pOutput)->offset = pCxt->offset; - return TSDB_CODE_SUCCESS; -} - -static SNode* createOrderByExpr(STranslateContext* pCxt) { - SOrderByExprNode* pOrder = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); - if (NULL == pOrder) { - return NULL; - } - pCxt->errCode = createPrimaryKeyCol(pCxt, &pOrder->pExpr); - if (TSDB_CODE_SUCCESS != pCxt->errCode) { - nodesDestroyNode((SNode*)pOrder); - return NULL; - } - pOrder->order = ORDER_DESC; - pOrder->nullOrder = NULL_ORDER_FIRST; - return (SNode*)pOrder; -} - -/* case 1: - * in: select tail(expr, k, f) from t where_clause - * out: select expr from t where_clause order by _rowts desc limit k offset f - * - * case 2: - * in: select tail(expr, k, f) from t where_clause partition_by_clause - * out: select expr from t where_clause partition_by_clause sort by _rowts desc limit k offset f - * - * case 3: - * in: select tail(expr, k, f) from t where_clause order_by_clause limit_clause - * out: select expr from ( - * select expr from t where_clause order by _rowts desc limit k offset f - * ) order_by_clause limit_clause - * - * case 4: - * in: select tail(expr, k, f) from t where_clause partition_by_clause limit_clause - * out: - */ -static int32_t rewriteTailStmt(STranslateContext* pCxt, SSelectStmt* pSelect) { - if (!pSelect->hasTailFunc) { - return TSDB_CODE_SUCCESS; - } - - SRwriteTailCxt cxt = {.pTranslateCxt = pCxt, .limit = -1, .offset = -1}; - nodesRewriteExprs(pSelect->pProjectionList, rewriteTailFunc, &cxt); - int32_t code = nodesListMakeStrictAppend(&pSelect->pOrderByList, createOrderByExpr(pCxt)); - if (TSDB_CODE_SUCCESS == code) { - code = createLimieNode(&cxt, &pSelect->pLimit); - } - pSelect->hasIndefiniteRowsFunc = false; - return code; -} - typedef struct SReplaceOrderByAliasCxt { STranslateContext* pTranslateCxt; SNodeList* pProjectionList; @@ -2558,6 +2391,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) { pCxt->pTranslateCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } + ((SExprNode*)pNew)->orderAlias = true; nodesDestroyNode(*pNode); *pNode = pNew; return DEAL_RES_CONTINUE; @@ -2613,12 +2447,6 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { code = translateInterp(pCxt, pSelect); } - if (TSDB_CODE_SUCCESS == code) { - code = rewriteUniqueStmt(pCxt, pSelect); - } - // if (TSDB_CODE_SUCCESS == code) { - // code = rewriteTailStmt(pCxt, pSelect); - // } if (TSDB_CODE_SUCCESS == code) { code = rewriteTimelineFunc(pCxt, pSelect); } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index c4f4624355..202dd96581 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -337,7 +337,11 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) { static bool isValidateTag(char* input) { if (!input) return false; for (size_t i = 0; i < strlen(input); ++i) { + #ifdef WINDOWS + if (input[i] < 0x20 || input[i] > 0x7E) return false; + #else if (isprint(input[i]) == 0) return false; + #endif } return true; } @@ -377,6 +381,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, SMs char* jsonKey = item->string; if (!isValidateTag(jsonKey)) { + fprintf(stdout,"%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__,__func__,taosGetSelfPthreadId());fflush(stdout); retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey); goto end; } diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index f8b8dc58fc..82e07b71af 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -232,8 +232,6 @@ TEST_F(ParserSelectTest, groupBySemanticCheck) { run("SELECT COUNT(*) cnt, c1 FROM t1 WHERE c1 > 0", TSDB_CODE_PAR_NOT_SINGLE_GROUP); run("SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 GROUP BY c1", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); - run("SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 PARTITION BY c2 GROUP BY c1", - TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); } TEST_F(ParserSelectTest, orderBy) { diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index a4cdcd35d3..ef8b109b62 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -437,6 +437,33 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) return pCol; } +static SNode* createGroupingSetNode(SNode* pExpr) { + SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET); + if (NULL == pGroupingSet) { + return NULL; + } + pGroupingSet->groupingSetType = GP_TYPE_NORMAL; + if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, nodesCloneNode(pExpr))) { + nodesDestroyNode((SNode*)pGroupingSet); + return NULL; + } + return (SNode*)pGroupingSet; +} + +static int32_t createGroupKeysFromPartKeys(SNodeList* pPartKeys, SNodeList** pOutput) { + SNodeList* pGroupKeys = NULL; + SNode* pPartKey = NULL; + FOREACH(pPartKey, pPartKeys) { + int32_t code = nodesListMakeStrictAppend(&pGroupKeys, createGroupingSetNode(pPartKey)); + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyList(pGroupKeys); + return code; + } + } + *pOutput = pGroupKeys; + return TSDB_CODE_SUCCESS; +} + static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { if (!pSelect->hasAggFuncs && NULL == pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; @@ -459,10 +486,18 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); } + if (NULL != pSelect->pPartitionByList) { + code = createGroupKeysFromPartKeys(pSelect->pPartitionByList, &pAgg->pGroupKeys); + } + if (NULL != pSelect->pGroupByList) { - pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); - if (NULL == pAgg->pGroupKeys) { - code = TSDB_CODE_OUT_OF_MEMORY; + if (NULL != pAgg->pGroupKeys) { + code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList)); + } else { + pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); + if (NULL == pAgg->pGroupKeys) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } } @@ -507,6 +542,9 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt return TSDB_CODE_OUT_OF_MEMORY; } + pIdfRowsFunc->isTailFunc = pSelect->hasTailFunc; + pIdfRowsFunc->isUniqueFunc = pSelect->hasUniqueFunc; + // indefinite rows functions and _select_values functions int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, fmIsVectorFunc, &pIdfRowsFunc->pFuncs); if (TSDB_CODE_SUCCESS == code) { @@ -733,6 +771,8 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return TSDB_CODE_OUT_OF_MEMORY; } + pSort->groupSort = pSelect->groupSort; + int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets); if (TSDB_CODE_SUCCESS == code && NULL == pSort->node.pTargets) { code = nodesListMakeStrictAppend(&pSort->node.pTargets, @@ -805,7 +845,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel } static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - if (NULL == pSelect->pPartitionByList) { + if (NULL == pSelect->pPartitionByList || (pSelect->hasAggFuncs && NULL == pSelect->pWindow) || + NULL != pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; } diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index f1cad6010c..42f7f744c5 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -20,9 +20,8 @@ #define OPTIMIZE_FLAG_MASK(n) (1 << n) -#define OPTIMIZE_FLAG_OSD OPTIMIZE_FLAG_MASK(0) -#define OPTIMIZE_FLAG_CPD OPTIMIZE_FLAG_MASK(1) -#define OPTIMIZE_FLAG_OPK OPTIMIZE_FLAG_MASK(2) +#define OPTIMIZE_FLAG_SCAN_PATH OPTIMIZE_FLAG_MASK(0) +#define OPTIMIZE_FLAG_PUSH_DOWN_CONDE OPTIMIZE_FLAG_MASK(1) #define OPTIMIZE_FLAG_SET_MASK(val, mask) (val) |= (mask) #define OPTIMIZE_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0) @@ -76,7 +75,7 @@ static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func) return NULL; } -EDealRes osdHaveNormalColImpl(SNode* pNode, void* pContext) { +EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { // *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); *((bool*)pContext) = true; @@ -85,14 +84,14 @@ EDealRes osdHaveNormalColImpl(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static bool osdHaveNormalCol(SNodeList* pList) { +static bool scanPathOptHaveNormalCol(SNodeList* pList) { bool res = false; - nodesWalkExprsPostOrder(pList, osdHaveNormalColImpl, &res); + nodesWalkExprsPostOrder(pList, scanPathOptHaveNormalColImpl, &res); return res; } -static bool osdMayBeOptimized(SLogicNode* pNode) { - if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_OSD)) { +static bool scanPathOptMayBeOptimized(SLogicNode* pNode) { + if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_SCAN_PATH)) { return false; } if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode)) { @@ -108,10 +107,10 @@ static bool osdMayBeOptimized(SLogicNode* pNode) { QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent->pParent))) { return true; } - return !osdHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys); + return !scanPathOptHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys); } -static SNodeList* osdGetAllFuncs(SLogicNode* pNode) { +static SNodeList* scanPathOptGetAllFuncs(SLogicNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_WINDOW: return ((SWindowLogicNode*)pNode)->pFuncs; @@ -123,7 +122,7 @@ static SNodeList* osdGetAllFuncs(SLogicNode* pNode) { return NULL; } -static bool needOptimizeDataRequire(const SFunctionNode* pFunc) { +static bool scanPathOptNeedOptimizeDataRequire(const SFunctionNode* pFunc) { if (!fmIsSpecialDataRequiredFunc(pFunc->funcId)) { return false; } @@ -136,7 +135,7 @@ static bool needOptimizeDataRequire(const SFunctionNode* pFunc) { return true; } -static bool needOptimizeDynamicScan(const SFunctionNode* pFunc) { +static bool scanPathOptNeedDynOptimize(const SFunctionNode* pFunc) { if (!fmIsDynamicScanOptimizedFunc(pFunc->funcId)) { return false; } @@ -149,17 +148,17 @@ static bool needOptimizeDynamicScan(const SFunctionNode* pFunc) { return true; } -static int32_t osdGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, SNodeList** pDsoFuncs) { - SNodeList* pAllFuncs = osdGetAllFuncs(pScan->node.pParent); +static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, SNodeList** pDsoFuncs) { + SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent); SNodeList* pTmpSdrFuncs = NULL; SNodeList* pTmpDsoFuncs = NULL; SNode* pFunc = NULL; bool otherFunc = false; FOREACH(pFunc, pAllFuncs) { int32_t code = TSDB_CODE_SUCCESS; - if (needOptimizeDataRequire((SFunctionNode*)pFunc)) { + if (scanPathOptNeedOptimizeDataRequire((SFunctionNode*)pFunc)) { code = nodesListMakeStrictAppend(&pTmpSdrFuncs, nodesCloneNode(pFunc)); - } else if (needOptimizeDynamicScan((SFunctionNode*)pFunc)) { + } else if (scanPathOptNeedDynOptimize((SFunctionNode*)pFunc)) { code = nodesListMakeStrictAppend(&pTmpDsoFuncs, nodesCloneNode(pFunc)); } else { otherFunc = true; @@ -180,15 +179,15 @@ static int32_t osdGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, return TSDB_CODE_SUCCESS; } -static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo* pInfo) { - pInfo->pScan = (SScanLogicNode*)optFindPossibleNode(pLogicNode, osdMayBeOptimized); +static int32_t scanPathOptMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo* pInfo) { + pInfo->pScan = (SScanLogicNode*)optFindPossibleNode(pLogicNode, scanPathOptMayBeOptimized); if (NULL == pInfo->pScan) { return TSDB_CODE_SUCCESS; } - return osdGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs); + return scanPathOptGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs); } -static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l, EFuncDataRequired r) { +static EFuncDataRequired scanPathOptPromoteDataRequired(EFuncDataRequired l, EFuncDataRequired r) { switch (l) { case FUNC_DATA_REQUIRED_DATA_LOAD: return l; @@ -202,19 +201,19 @@ static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l, EFuncDataRe return r; } -static int32_t osdGetDataRequired(SNodeList* pFuncs) { +static int32_t scanPathOptGetDataRequired(SNodeList* pFuncs) { if (NULL == pFuncs) { return FUNC_DATA_REQUIRED_DATA_LOAD; } EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_FILTEROUT; SNode* pFunc = NULL; FOREACH(pFunc, pFuncs) { - dataRequired = osdPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL)); + dataRequired = scanPathOptPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL)); } return dataRequired; } -static void setScanWindowInfo(SScanLogicNode* pScan) { +static void scanPathOptSetScanWin(SScanLogicNode* pScan) { SLogicNode* pParent = pScan->node.pParent; if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pParent) && pParent->pParent && QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pParent->pParent)) { @@ -233,23 +232,23 @@ static void setScanWindowInfo(SScanLogicNode* pScan) { } } -static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { +static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { SOsdInfo info = {0}; - int32_t code = osdMatch(pCxt, pLogicSubplan->pNode, &info); + int32_t code = scanPathOptMatch(pCxt, pLogicSubplan->pNode, &info); if (TSDB_CODE_SUCCESS == code && info.pScan) { - setScanWindowInfo((SScanLogicNode*)info.pScan); + scanPathOptSetScanWin((SScanLogicNode*)info.pScan); } if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) { - info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs); + info.pScan->dataRequired = scanPathOptGetDataRequired(info.pSdrFuncs); info.pScan->pDynamicScanFuncs = info.pDsoFuncs; - OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD); + OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_SCAN_PATH); pCxt->optimized = true; } nodesDestroyList(info.pSdrFuncs); return code; } -static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { +static int32_t pushDownCondOptMergeCond(SNode** pDst, SNode** pSrc) { SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pLogicCond) { return TSDB_CODE_OUT_OF_MEMORY; @@ -270,7 +269,7 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { return code; } -static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) { +static int32_t pushDownCondOptAppendCond(SNode** pCond, SNode** pAdditionalCond) { if (NULL == *pCond) { TSWAP(*pCond, *pAdditionalCond); return TSDB_CODE_SUCCESS; @@ -283,16 +282,16 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) { *pAdditionalCond = NULL; } } else { - code = cpdMergeCond(pCond, pAdditionalCond); + code = pushDownCondOptMergeCond(pCond, pAdditionalCond); } return code; } -static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, - SNode** pOtherCond) { +static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, + SNode** pOtherCond) { int32_t code = TSDB_CODE_SUCCESS; if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { - code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + code = pushDownCondOptAppendCond(pOtherCond, pPrimaryKeyCond); } else { bool isStrict = false; code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); @@ -300,7 +299,7 @@ static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, S if (isStrict) { nodesDestroyNode(*pPrimaryKeyCond); } else { - code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + code = pushDownCondOptAppendCond(pOtherCond, pPrimaryKeyCond); } *pPrimaryKeyCond = NULL; } @@ -308,8 +307,9 @@ static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, S return code; } -static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* pScan) { - if (NULL == pScan->node.pConditions || OPTIMIZE_FLAG_TEST_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_CPD) || +static int32_t pushDownCondOptDealScan(SOptimizeContext* pCxt, SScanLogicNode* pScan) { + if (NULL == pScan->node.pConditions || + OPTIMIZE_FLAG_TEST_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE) || TSDB_SYSTEM_TABLE == pScan->tableType) { return TSDB_CODE_SUCCESS; } @@ -319,14 +319,14 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* int32_t code = nodesPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pScan->pTagIndexCond, &pScan->pTagCond, &pOtherCond); if (TSDB_CODE_SUCCESS == code && NULL != pPrimaryKeyCond) { - code = cpdCalcTimeRange(pCxt, pScan, &pPrimaryKeyCond, &pOtherCond); + code = pushDownCondOptCalcTimeRange(pCxt, pScan, &pPrimaryKeyCond, &pOtherCond); } if (TSDB_CODE_SUCCESS == code) { pScan->node.pConditions = pOtherCond; } if (TSDB_CODE_SUCCESS == code) { - OPTIMIZE_FLAG_SET_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_CPD); + OPTIMIZE_FLAG_SET_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE); pCxt->optimized = true; } else { nodesDestroyNode(pPrimaryKeyCond); @@ -336,7 +336,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* return code; } -static bool cpdBelongThisTable(SNode* pCondCol, SNodeList* pTableCols) { +static bool pushDownCondOptBelongThisTable(SNode* pCondCol, SNodeList* pTableCols) { SNode* pTableCol = NULL; FOREACH(pTableCol, pTableCols) { if (nodesEqualNode(pCondCol, pTableCol)) { @@ -346,12 +346,12 @@ static bool cpdBelongThisTable(SNode* pCondCol, SNodeList* pTableCols) { return false; } -static EDealRes cpdIsMultiTableCondImpl(SNode* pNode, void* pContext) { +static EDealRes pushDownCondOptIsCrossTableCond(SNode* pNode, void* pContext) { SCpdIsMultiTableCondCxt* pCxt = pContext; if (QUERY_NODE_COLUMN == nodeType(pNode)) { - if (cpdBelongThisTable(pNode, pCxt->pLeftCols)) { + if (pushDownCondOptBelongThisTable(pNode, pCxt->pLeftCols)) { pCxt->havaLeftCol = true; - } else if (cpdBelongThisTable(pNode, pCxt->pRightCols)) { + } else if (pushDownCondOptBelongThisTable(pNode, pCxt->pRightCols)) { pCxt->haveRightCol = true; } return pCxt->havaLeftCol && pCxt->haveRightCol ? DEAL_RES_END : DEAL_RES_CONTINUE; @@ -359,10 +359,11 @@ static EDealRes cpdIsMultiTableCondImpl(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static ECondAction cpdCondAction(EJoinType joinType, SNodeList* pLeftCols, SNodeList* pRightCols, SNode* pNode) { +static ECondAction pushDownCondOptGetCondAction(EJoinType joinType, SNodeList* pLeftCols, SNodeList* pRightCols, + SNode* pNode) { SCpdIsMultiTableCondCxt cxt = { .pLeftCols = pLeftCols, .pRightCols = pRightCols, .havaLeftCol = false, .haveRightCol = false}; - nodesWalkExpr(pNode, cpdIsMultiTableCondImpl, &cxt); + nodesWalkExpr(pNode, pushDownCondOptIsCrossTableCond, &cxt); return (JOIN_TYPE_INNER != joinType ? COND_ACTION_STAY : (cxt.havaLeftCol && cxt.haveRightCol @@ -370,8 +371,8 @@ static ECondAction cpdCondAction(EJoinType joinType, SNodeList* pLeftCols, SNode : (cxt.havaLeftCol ? COND_ACTION_PUSH_LEFT_CHILD : COND_ACTION_PUSH_RIGHT_CHILD))); } -static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, - SNode** pRightChildCond) { +static int32_t pushDownCondOptPartLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, + SNode** pRightChildCond) { SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pJoin->node.pConditions; if (LOGIC_COND_TYPE_AND != pLogicCond->condType) { return TSDB_CODE_SUCCESS; @@ -387,7 +388,7 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo SNodeList* pRemainConds = NULL; SNode* pCond = NULL; FOREACH(pCond, pLogicCond->pParameterList) { - ECondAction condAction = cpdCondAction(pJoin->joinType, pLeftCols, pRightCols, pCond); + ECondAction condAction = pushDownCondOptGetCondAction(pJoin->joinType, pLeftCols, pRightCols, pCond); if (COND_ACTION_PUSH_JOIN == condAction) { code = nodesListMakeAppend(&pOnConds, nodesCloneNode(pCond)); } else if (COND_ACTION_PUSH_LEFT_CHILD == condAction) { @@ -439,11 +440,12 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo return code; } -static int32_t cpdPartitionOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, - SNode** pRightChildCond) { +static int32_t pushDownCondOptPartOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, + SNode** pRightChildCond) { SNodeList* pLeftCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0))->pTargets; SNodeList* pRightCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1))->pTargets; - ECondAction condAction = cpdCondAction(pJoin->joinType, pLeftCols, pRightCols, pJoin->node.pConditions); + ECondAction condAction = + pushDownCondOptGetCondAction(pJoin->joinType, pLeftCols, pRightCols, pJoin->node.pConditions); if (COND_ACTION_STAY == condAction) { return TSDB_CODE_SUCCESS; } else if (COND_ACTION_PUSH_JOIN == condAction) { @@ -457,35 +459,35 @@ static int32_t cpdPartitionOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode* return TSDB_CODE_SUCCESS; } -static int32_t cpdPartitionCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, - SNode** pRightChildCond) { +static int32_t pushDownCondOptPartCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, + SNode** pRightChildCond) { if (QUERY_NODE_LOGIC_CONDITION == nodeType(pJoin->node.pConditions)) { - return cpdPartitionLogicCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond); + return pushDownCondOptPartLogicCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond); } else { - return cpdPartitionOpCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond); + return pushDownCondOptPartOpCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond); } } -static int32_t cpdPushCondToOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** pCond) { - return cpdCondAppend(&pJoin->pOnConditions, pCond); +static int32_t pushDownCondOptPushCondToOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** pCond) { + return pushDownCondOptAppendCond(&pJoin->pOnConditions, pCond); } -static int32_t cpdPushCondToScan(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pCond) { - return cpdCondAppend(&pScan->node.pConditions, pCond); +static int32_t pushDownCondOptPushCondToScan(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pCond) { + return pushDownCondOptAppendCond(&pScan->node.pConditions, pCond); } -static int32_t cpdPushCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) { +static int32_t pushDownCondOptPushCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) { switch (nodeType(pChild)) { case QUERY_NODE_LOGIC_PLAN_SCAN: - return cpdPushCondToScan(pCxt, (SScanLogicNode*)pChild, pCond); + return pushDownCondOptPushCondToScan(pCxt, (SScanLogicNode*)pChild, pCond); default: break; } - planError("cpdPushCondToChild failed, invalid logic plan node %s", nodesNodeName(nodeType(pChild))); + planError("pushDownCondOptPushCondToChild failed, invalid logic plan node %s", nodesNodeName(nodeType(pChild))); return TSDB_CODE_PLAN_INTERNAL_ERROR; } -static bool cpdIsPrimaryKey(SNode* pNode, SNodeList* pTableCols) { +static bool pushDownCondOptIsPriKey(SNode* pNode, SNodeList* pTableCols) { if (QUERY_NODE_COLUMN != nodeType(pNode)) { return false; } @@ -493,10 +495,10 @@ static bool cpdIsPrimaryKey(SNode* pNode, SNodeList* pTableCols) { if (PRIMARYKEY_TIMESTAMP_COL_ID != pCol->colId) { return false; } - return cpdBelongThisTable(pNode, pTableCols); + return pushDownCondOptBelongThisTable(pNode, pTableCols); } -static bool cpdIsPrimaryKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { +static bool pushDownCondOptIsPriKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { if (QUERY_NODE_OPERATOR != nodeType(pCond)) { return false; } @@ -508,15 +510,15 @@ static bool cpdIsPrimaryKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { SNodeList* pLeftCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0))->pTargets; SNodeList* pRightCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1))->pTargets; - if (cpdIsPrimaryKey(pOper->pLeft, pLeftCols)) { - return cpdIsPrimaryKey(pOper->pRight, pRightCols); - } else if (cpdIsPrimaryKey(pOper->pLeft, pRightCols)) { - return cpdIsPrimaryKey(pOper->pRight, pLeftCols); + if (pushDownCondOptIsPriKey(pOper->pLeft, pLeftCols)) { + return pushDownCondOptIsPriKey(pOper->pRight, pRightCols); + } else if (pushDownCondOptIsPriKey(pOper->pLeft, pRightCols)) { + return pushDownCondOptIsPriKey(pOper->pRight, pLeftCols); } return false; } -static bool cpdContainPrimaryKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { +static bool pushDownCondOptContainPriKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { if (QUERY_NODE_LOGIC_CONDITION == nodeType(pCond)) { SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pCond; if (LOGIC_COND_TYPE_AND != pLogicCond->condType) { @@ -525,54 +527,56 @@ static bool cpdContainPrimaryKeyEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { bool hasPrimaryKeyEqualCond = false; SNode* pCond = NULL; FOREACH(pCond, pLogicCond->pParameterList) { - if (cpdContainPrimaryKeyEqualCond(pJoin, pCond)) { + if (pushDownCondOptContainPriKeyEqualCond(pJoin, pCond)) { hasPrimaryKeyEqualCond = true; break; } } return hasPrimaryKeyEqualCond; } else { - return cpdIsPrimaryKeyEqualCond(pJoin, pCond); + return pushDownCondOptIsPriKeyEqualCond(pJoin, pCond); } } -static int32_t cpdCheckJoinOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { +static int32_t pushDownCondOptCheckJoinOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { if (NULL == pJoin->pOnConditions) { return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_NOT_SUPPORT_CROSS_JOIN); } - if (!cpdContainPrimaryKeyEqualCond(pJoin, pJoin->pOnConditions)) { + if (!pushDownCondOptContainPriKeyEqualCond(pJoin, pJoin->pOnConditions)) { return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_EXPECTED_TS_EQUAL); } return TSDB_CODE_SUCCESS; } -static int32_t cpdPushJoinCondition(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { - if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_CPD)) { +static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { + if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) { return TSDB_CODE_SUCCESS; } if (NULL == pJoin->node.pConditions) { - return cpdCheckJoinOnCond(pCxt, pJoin); + return pushDownCondOptCheckJoinOnCond(pCxt, pJoin); } SNode* pOnCond = NULL; SNode* pLeftChildCond = NULL; SNode* pRightChildCond = NULL; - int32_t code = cpdPartitionCond(pJoin, &pOnCond, &pLeftChildCond, &pRightChildCond); + int32_t code = pushDownCondOptPartCond(pJoin, &pOnCond, &pLeftChildCond, &pRightChildCond); if (TSDB_CODE_SUCCESS == code && NULL != pOnCond) { - code = cpdPushCondToOnCond(pCxt, pJoin, &pOnCond); + code = pushDownCondOptPushCondToOnCond(pCxt, pJoin, &pOnCond); } if (TSDB_CODE_SUCCESS == code && NULL != pLeftChildCond) { - code = cpdPushCondToChild(pCxt, (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0), &pLeftChildCond); + code = + pushDownCondOptPushCondToChild(pCxt, (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0), &pLeftChildCond); } if (TSDB_CODE_SUCCESS == code && NULL != pRightChildCond) { - code = cpdPushCondToChild(pCxt, (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1), &pRightChildCond); + code = + pushDownCondOptPushCondToChild(pCxt, (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1), &pRightChildCond); } if (TSDB_CODE_SUCCESS == code) { - OPTIMIZE_FLAG_SET_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_CPD); + OPTIMIZE_FLAG_SET_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE); pCxt->optimized = true; - code = cpdCheckJoinOnCond(pCxt, pJoin); + code = pushDownCondOptCheckJoinOnCond(pCxt, pJoin); } else { nodesDestroyNode(pOnCond); nodesDestroyNode(pLeftChildCond); @@ -582,22 +586,22 @@ static int32_t cpdPushJoinCondition(SOptimizeContext* pCxt, SJoinLogicNode* pJoi return code; } -static int32_t cpdPushAggCondition(SOptimizeContext* pCxt, SAggLogicNode* pAgg) { +static int32_t pushDownCondOptDealAgg(SOptimizeContext* pCxt, SAggLogicNode* pAgg) { // todo return TSDB_CODE_SUCCESS; } -static int32_t cpdPushCondition(SOptimizeContext* pCxt, SLogicNode* pLogicNode) { +static int32_t pushDownCondOptimizeImpl(SOptimizeContext* pCxt, SLogicNode* pLogicNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pLogicNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: - code = cpdOptimizeScanCondition(pCxt, (SScanLogicNode*)pLogicNode); + code = pushDownCondOptDealScan(pCxt, (SScanLogicNode*)pLogicNode); break; case QUERY_NODE_LOGIC_PLAN_JOIN: - code = cpdPushJoinCondition(pCxt, (SJoinLogicNode*)pLogicNode); + code = pushDownCondOptDealJoin(pCxt, (SJoinLogicNode*)pLogicNode); break; case QUERY_NODE_LOGIC_PLAN_AGG: - code = cpdPushAggCondition(pCxt, (SAggLogicNode*)pLogicNode); + code = pushDownCondOptDealAgg(pCxt, (SAggLogicNode*)pLogicNode); break; default: break; @@ -605,7 +609,7 @@ static int32_t cpdPushCondition(SOptimizeContext* pCxt, SLogicNode* pLogicNode) if (TSDB_CODE_SUCCESS == code) { SNode* pChild = NULL; FOREACH(pChild, pLogicNode->pChildren) { - code = cpdPushCondition(pCxt, (SLogicNode*)pChild); + code = pushDownCondOptimizeImpl(pCxt, (SLogicNode*)pChild); if (TSDB_CODE_SUCCESS != code) { break; } @@ -614,11 +618,11 @@ static int32_t cpdPushCondition(SOptimizeContext* pCxt, SLogicNode* pLogicNode) return code; } -static int32_t cpdOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { - return cpdPushCondition(pCxt, pLogicSubplan->pNode); +static int32_t pushDownCondOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + return pushDownCondOptimizeImpl(pCxt, pLogicSubplan->pNode); } -static bool opkIsPrimaryKeyOrderBy(SNodeList* pSortKeys) { +static bool sortPriKeyOptIsPriKeyOrderBy(SNodeList* pSortKeys) { if (1 != LIST_LENGTH(pSortKeys)) { return false; } @@ -626,17 +630,18 @@ static bool opkIsPrimaryKeyOrderBy(SNodeList* pSortKeys) { return (QUERY_NODE_COLUMN == nodeType(pNode) ? (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pNode)->colId) : false); } -static bool opkSortMayBeOptimized(SLogicNode* pNode) { +static bool sortPriKeyOptMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SORT != nodeType(pNode)) { return false; } - if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_OPK)) { - return false; + SSortLogicNode* pSort = (SSortLogicNode*)pNode; + if (pSort->groupSort || !sortPriKeyOptIsPriKeyOrderBy(pSort->pSortKeys) || 1 != LIST_LENGTH(pSort->node.pChildren)) { + return TSDB_CODE_SUCCESS; } return true; } -static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeList** pScanNodes) { +static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeList** pScanNodes) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -646,9 +651,11 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL } break; case QUERY_NODE_LOGIC_PLAN_JOIN: - code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + code = + sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); if (TSDB_CODE_SUCCESS == code) { - code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); + code = + sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); } return code; case QUERY_NODE_LOGIC_PLAN_AGG: @@ -663,77 +670,58 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL return TSDB_CODE_SUCCESS; } - return opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + return sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); } -static int32_t opkGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) { +static int32_t sortPriKeyOptGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) { bool notOptimize = false; - int32_t code = opkGetScanNodesImpl(pNode, ¬Optimize, pScanNodes); + int32_t code = sortPriKeyOptGetScanNodesImpl(pNode, ¬Optimize, pScanNodes); if (TSDB_CODE_SUCCESS != code || notOptimize) { nodesClearList(*pScanNodes); } return code; } -static EOrder opkGetPrimaryKeyOrder(SSortLogicNode* pSort) { +static EOrder sortPriKeyOptGetPriKeyOrder(SSortLogicNode* pSort) { return ((SOrderByExprNode*)nodesListGetNode(pSort->pSortKeys, 0))->order; } -static SNode* opkRewriteDownNode(SSortLogicNode* pSort) { - SNode* pDownNode = nodesListGetNode(pSort->node.pChildren, 0); - // todo - NODES_CLEAR_LIST(pSort->node.pChildren); - return pDownNode; -} - -static int32_t opkDoOptimized(SOptimizeContext* pCxt, SSortLogicNode* pSort, SNodeList* pScanNodes) { - EOrder order = opkGetPrimaryKeyOrder(pSort); +static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort, + SNodeList* pScanNodes) { + EOrder order = sortPriKeyOptGetPriKeyOrder(pSort); if (ORDER_DESC == order) { SNode* pScan = NULL; FOREACH(pScan, pScanNodes) { TSWAP(((SScanLogicNode*)pScan)->scanSeq[0], ((SScanLogicNode*)pScan)->scanSeq[1]); } } - if (NULL == pSort->node.pParent) { - // todo - return TSDB_CODE_SUCCESS; + int32_t code = + replaceLogicNode(pLogicSubplan, (SLogicNode*)pSort, (SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0)); + if (TSDB_CODE_SUCCESS == code) { + NODES_CLEAR_LIST(pSort->node.pChildren); + nodesDestroyNode((SNode*)pSort); } - - SNode* pDownNode = opkRewriteDownNode(pSort); - SNode* pNode; - FOREACH(pNode, pSort->node.pParent->pChildren) { - if (nodesEqualNode(pNode, (SNode*)pSort)) { - REPLACE_NODE(pDownNode); - ((SLogicNode*)pDownNode)->pParent = pSort->node.pParent; - break; - } - } - nodesDestroyNode((SNode*)pSort); - return TSDB_CODE_SUCCESS; + return code; } -static int32_t opkOptimizeImpl(SOptimizeContext* pCxt, SSortLogicNode* pSort) { - OPTIMIZE_FLAG_SET_MASK(pSort->node.optimizedFlag, OPTIMIZE_FLAG_OPK); - if (!opkIsPrimaryKeyOrderBy(pSort->pSortKeys) || 1 != LIST_LENGTH(pSort->node.pChildren)) { - return TSDB_CODE_SUCCESS; - } +static int32_t sortPrimaryKeyOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort) { SNodeList* pScanNodes = NULL; - int32_t code = opkGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); + int32_t code = sortPriKeyOptGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) { - code = opkDoOptimized(pCxt, pSort, pScanNodes); + code = sortPriKeyOptApply(pCxt, pLogicSubplan, pSort, pScanNodes); } nodesClearList(pScanNodes); return code; } -static int32_t opkOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { - SSortLogicNode* pSort = (SSortLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, opkSortMayBeOptimized); +static int32_t sortPrimaryKeyOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SSortLogicNode* pSort = (SSortLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, sortPriKeyOptMayBeOptimized); if (NULL == pSort) { return TSDB_CODE_SUCCESS; } - return opkOptimizeImpl(pCxt, pSort); + return sortPrimaryKeyOptimizeImpl(pCxt, pLogicSubplan, pSort); } -static bool smaOptMayBeOptimized(SLogicNode* pNode) { +static bool smaIndexOptMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) || WINDOW_TYPE_INTERVAL != ((SWindowLogicNode*)pNode->pParent)->winType) { @@ -748,7 +736,8 @@ static bool smaOptMayBeOptimized(SLogicNode* pNode) { return true; } -static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNodeList* pTargets, SLogicNode** pOutput) { +static int32_t smaIndexOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNodeList* pTargets, + SLogicNode** pOutput) { SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; @@ -767,8 +756,8 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod return TSDB_CODE_SUCCESS; } -static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* pInterval, SLogicNode* pMerge, - SLogicNode* pSmaScan) { +static int32_t smaIndexOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* pInterval, SLogicNode* pMerge, + SLogicNode* pSmaScan) { int32_t code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pInterval); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pSmaScan); @@ -781,8 +770,8 @@ static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* return code; } -static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList* pCols, - SLogicNode** pOutput) { +static int32_t smaIndexOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList* pCols, + SLogicNode** pOutput) { SScanLogicNode* pSmaScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); if (NULL == pSmaScan) { return TSDB_CODE_OUT_OF_MEMORY; @@ -811,7 +800,7 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde return TSDB_CODE_SUCCESS; } -static bool smaOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow, STableIndexInfo* pIndex) { +static bool smaIndexOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow, STableIndexInfo* pIndex) { if (pWindow->interval != pIndex->interval || pWindow->intervalUnit != pIndex->intervalUnit || pWindow->offset != pIndex->offset || pWindow->sliding != pIndex->sliding || pWindow->slidingUnit != pIndex->slidingUnit) { @@ -831,7 +820,7 @@ static bool smaOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow return true; } -static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) { +static SNode* smaIndexOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; @@ -846,7 +835,7 @@ static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) return (SNode*)pCol; } -static int32_t smaOptFindSmaFunc(SNode* pQueryFunc, SNodeList* pSmaFuncs) { +static int32_t smaIndexOptFindSmaFunc(SNode* pQueryFunc, SNodeList* pSmaFuncs) { int32_t index = 0; SNode* pSmaFunc = NULL; FOREACH(pSmaFunc, pSmaFuncs) { @@ -858,8 +847,8 @@ static int32_t smaOptFindSmaFunc(SNode* pQueryFunc, SNodeList* pSmaFuncs) { return -1; } -static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeList* pSmaFuncs, SNodeList** pOutput, - int32_t* pWStrartIndex) { +static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeList* pSmaFuncs, SNodeList** pOutput, + int32_t* pWStrartIndex) { SNodeList* pCols = NULL; SNode* pFunc = NULL; int32_t code = TSDB_CODE_SUCCESS; @@ -870,11 +859,11 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) { *pWStrartIndex = index; } - smaFuncIndex = smaOptFindSmaFunc(pFunc, pSmaFuncs); + smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs); if (smaFuncIndex < 0) { break; } else { - code = nodesListMakeStrictAppend(&pCols, smaOptCreateSmaCol(pFunc, tableId, smaFuncIndex + 2)); + code = nodesListMakeStrictAppend(&pCols, smaIndexOptCreateSmaCol(pFunc, tableId, smaFuncIndex + 2)); if (TSDB_CODE_SUCCESS != code) { break; } @@ -891,22 +880,22 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis return code; } -static int32_t smaOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList** pCols, - int32_t* pWStrartIndex) { +static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList** pCols, + int32_t* pWStrartIndex) { SWindowLogicNode* pWindow = (SWindowLogicNode*)pScan->node.pParent; - if (!smaOptEqualInterval(pScan, pWindow, pIndex)) { + if (!smaIndexOptEqualInterval(pScan, pWindow, pIndex)) { return TSDB_CODE_SUCCESS; } SNodeList* pSmaFuncs = NULL; int32_t code = nodesStringToList(pIndex->expr, &pSmaFuncs); if (TSDB_CODE_SUCCESS == code) { - code = smaOptCreateSmaCols(pWindow->pFuncs, pIndex->dstTbUid, pSmaFuncs, pCols, pWStrartIndex); + code = smaIndexOptCreateSmaCols(pWindow->pFuncs, pIndex->dstTbUid, pSmaFuncs, pCols, pWStrartIndex); } nodesDestroyList(pSmaFuncs); return code; } -static SNode* smaOptCreateWStartTs() { +static SNode* smaIndexOptCreateWStartTs() { SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pWStart) { return NULL; @@ -920,7 +909,7 @@ static SNode* smaOptCreateWStartTs() { return (SNode*)pWStart; } -static int32_t smaOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) { +static int32_t smaIndexOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) { SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pMergeKey) { return TSDB_CODE_OUT_OF_MEMORY; @@ -935,9 +924,9 @@ static int32_t smaOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) { return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey); } -static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) { +static int32_t smaIndexOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) { if (wstrartIndex < 0) { - SNode* pWStart = smaOptCreateWStartTs(); + SNode* pWStart = smaIndexOptCreateWStartTs(); if (NULL == pWStart) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -948,11 +937,11 @@ static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrar } wstrartIndex = LIST_LENGTH(pInterval->node.pTargets) - 1; } - return smaOptCreateMergeKey(nodesListGetNode(pInterval->node.pTargets, wstrartIndex), pMergeKeys); + return smaIndexOptCreateMergeKey(nodesListGetNode(pInterval->node.pTargets, wstrartIndex), pMergeKeys); } -static int32_t smaOptApplyIndexExt(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex, - SNodeList* pSmaCols, int32_t wstrartIndex) { +static int32_t smaIndexOptApplyIndexExt(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex, + SNodeList* pSmaCols, int32_t wstrartIndex) { SWindowLogicNode* pInterval = (SWindowLogicNode*)pScan->node.pParent; SNodeList* pMergeTargets = nodesCloneList(pInterval->node.pTargets); if (NULL == pMergeTargets) { @@ -961,55 +950,56 @@ static int32_t smaOptApplyIndexExt(SLogicSubplan* pLogicSubplan, SScanLogicNode* SLogicNode* pSmaScan = NULL; SLogicNode* pMerge = NULL; SNodeList* pMergeKeys = NULL; - int32_t code = smaOptRewriteInterval(pInterval, wstrartIndex, &pMergeKeys); + int32_t code = smaIndexOptRewriteInterval(pInterval, wstrartIndex, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = smaOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan); + code = smaIndexOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan); } if (TSDB_CODE_SUCCESS == code) { - code = smaOptCreateMerge(pScan->node.pParent, pMergeKeys, pMergeTargets, &pMerge); + code = smaIndexOptCreateMerge(pScan->node.pParent, pMergeKeys, pMergeTargets, &pMerge); } if (TSDB_CODE_SUCCESS == code) { - code = smaOptRecombinationNode(pLogicSubplan, pScan->node.pParent, pMerge, pSmaScan); + code = smaIndexOptRecombinationNode(pLogicSubplan, pScan->node.pParent, pMerge, pSmaScan); } return code; } -static int32_t smaOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex, - SNodeList* pSmaCols, int32_t wstrartIndex) { +static int32_t smaIndexOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex, + SNodeList* pSmaCols, int32_t wstrartIndex) { SLogicNode* pSmaScan = NULL; - int32_t code = smaOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan); + int32_t code = smaIndexOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan); if (TSDB_CODE_SUCCESS == code) { code = replaceLogicNode(pLogicSubplan, pScan->node.pParent, pSmaScan); } return code; } -static void smaOptDestroySmaIndex(void* p) { taosMemoryFree(((STableIndexInfo*)p)->expr); } +static void smaIndexOptDestroySmaIndex(void* p) { taosMemoryFree(((STableIndexInfo*)p)->expr); } -static int32_t smaOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan) { +static int32_t smaIndexOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan) { int32_t code = TSDB_CODE_SUCCESS; int32_t nindexes = taosArrayGetSize(pScan->pSmaIndexes); for (int32_t i = 0; i < nindexes; ++i) { STableIndexInfo* pIndex = taosArrayGet(pScan->pSmaIndexes, i); SNodeList* pSmaCols = NULL; int32_t wstrartIndex = -1; - code = smaOptCouldApplyIndex(pScan, pIndex, &pSmaCols, &wstrartIndex); + code = smaIndexOptCouldApplyIndex(pScan, pIndex, &pSmaCols, &wstrartIndex); if (TSDB_CODE_SUCCESS == code && NULL != pSmaCols) { - code = smaOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols, wstrartIndex); - taosArrayDestroyEx(pScan->pSmaIndexes, smaOptDestroySmaIndex); + code = smaIndexOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols, wstrartIndex); + taosArrayDestroyEx(pScan->pSmaIndexes, smaIndexOptDestroySmaIndex); pScan->pSmaIndexes = NULL; + pCxt->optimized = true; break; } } return code; } -static int32_t smaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { - SScanLogicNode* pScan = (SScanLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, smaOptMayBeOptimized); +static int32_t smaIndexOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SScanLogicNode* pScan = (SScanLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, smaIndexOptMayBeOptimized); if (NULL == pScan) { return TSDB_CODE_SUCCESS; } - return smaOptimizeImpl(pCxt, pLogicSubplan, pScan); + return smaIndexOptimizeImpl(pCxt, pLogicSubplan, pScan); } static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) { @@ -1044,12 +1034,30 @@ static SNodeList* partTagsGetPartKeys(SLogicNode* pNode) { } } +static SNodeList* partTagsGetFuncs(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) { + return NULL; + } else { + return ((SAggLogicNode*)pNode)->pAggFuncs; + } +} + +static bool partTagsOptAreSupportedFuncs(SNodeList* pFuncs) { + SNode* pFunc = NULL; + FOREACH(pFunc, pFuncs) { + if (fmIsIndefiniteRowsFunc(((SFunctionNode*)pFunc)->funcId) && !fmIsSelectFunc(((SFunctionNode*)pFunc)->funcId)) { + return false; + } + } + return true; +} + static bool partTagsOptMayBeOptimized(SLogicNode* pNode) { if (!partTagsIsOptimizableNode(pNode)) { return false; } - return !partTagsOptHasCol(partTagsGetPartKeys(pNode)); + return !partTagsOptHasCol(partTagsGetPartKeys(pNode)) && partTagsOptAreSupportedFuncs(partTagsGetFuncs(pNode)); } static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) { @@ -1075,6 +1083,59 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) { return code; } +static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return NULL; + } + + strcpy(pFunc->functionName, pFuncName); + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + SColumnNode* pCol = (SColumnNode*)pNode; + sprintf(pFunc->node.aliasName, "%s.%s", pCol->tableAlias, pCol->colName); + } else { + strcpy(pFunc->node.aliasName, ((SExprNode*)pNode)->aliasName); + } + int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pNode)); + if (TSDB_CODE_SUCCESS == code) { + code = fmGetFuncInfo(pFunc, NULL, 0); + } + + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode((SNode*)pFunc); + return NULL; + } + + return (SNode*)pFunc; +} + +static bool partTagsHasIndefRowsSelectFunc(SNodeList* pFuncs) { + SNode* pFunc = NULL; + FOREACH(pFunc, pFuncs) { + if (fmIsIndefiniteRowsFunc(((SFunctionNode*)pFunc)->funcId)) { + return true; + } + } + return false; +} + +static int32_t partTagsRewriteGroupTagsToFuncs(SNodeList* pGroupTags, SNodeList* pAggFuncs) { + bool hasIndefRowsSelectFunc = partTagsHasIndefRowsSelectFunc(pAggFuncs); + int32_t code = TSDB_CODE_SUCCESS; + SNode* pNode = NULL; + FOREACH(pNode, pGroupTags) { + if (hasIndefRowsSelectFunc) { + code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_select_value", pNode)); + } else { + code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_group_key", pNode)); + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + return code; +} + static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { SLogicNode* pNode = optFindPossibleNode(pLogicSubplan->pNode, partTagsOptMayBeOptimized); if (NULL == pNode) { @@ -1084,31 +1145,31 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub int32_t code = TSDB_CODE_SUCCESS; SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0); if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) { - TSWAP(((SPartitionLogicNode*)pNode)->pPartitionKeys, pScan->pPartTags); + TSWAP(((SPartitionLogicNode*)pNode)->pPartitionKeys, pScan->pGroupTags); int32_t code = replaceLogicNode(pLogicSubplan, pNode, (SLogicNode*)pScan); if (TSDB_CODE_SUCCESS == code) { NODES_CLEAR_LIST(pNode->pChildren); nodesDestroyNode((SNode*)pNode); } } else { - SNode* pGroupKey = NULL; - FOREACH(pGroupKey, ((SAggLogicNode*)pNode)->pGroupKeys) { + SAggLogicNode* pAgg = (SAggLogicNode*)pNode; + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, pAgg->pGroupKeys) { code = nodesListMakeStrictAppend( - &pScan->pPartTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0))); + &pScan->pGroupTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0))); if (TSDB_CODE_SUCCESS != code) { break; } } - NODES_DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); + NODES_DESTORY_LIST(pAgg->pGroupKeys); + code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, pAgg->pAggFuncs); } if (TSDB_CODE_SUCCESS == code) { - code = partTagsOptRebuildTbanme(pScan->pPartTags); + code = partTagsOptRebuildTbanme(pScan->pGroupTags); } return code; } -//===================================================================================================================== -// eliminate project optimization static bool eliminateProjOptCheckProjColumnNames(SProjectLogicNode* pProjectNode) { SHashObj* pProjColNameHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); SNode* pProjection; @@ -1138,11 +1199,12 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { } SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode; - if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) { + if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit || + NULL != pProjectNode->node.pConditions) { return false; } - SNode* pProjection; + SNode* pProjection; FOREACH(pProjection, pProjectNode->pProjections) { SExprNode* pExprNode = (SExprNode*)pProjection; if (QUERY_NODE_COLUMN != nodeType(pExprNode)) { @@ -1176,6 +1238,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* NODES_CLEAR_LIST(pProjectNode->node.pChildren); nodesDestroyNode((SNode*)pProjectNode); } + pCxt->optimized = true; return code; } @@ -1190,35 +1253,175 @@ static int32_t eliminateProjOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog return eliminateProjOptimizeImpl(pCxt, pLogicSubplan, pProjectNode); } -//===================================================================================================================== -// eliminate Set Operator optimization +static bool rewriteTailOptMayBeOptimized(SLogicNode* pNode) { + return QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC == nodeType(pNode) && ((SIndefRowsFuncLogicNode*)pNode)->isTailFunc; +} + +static SNode* rewriteTailOptCreateOrderByExpr(SNode* pSortKey) { + SOrderByExprNode* pOrder = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + if (NULL == pOrder) { + return NULL; + } + pOrder->order = ORDER_DESC; + pOrder->pExpr = nodesCloneNode(pSortKey); + if (NULL == pOrder->pExpr) { + nodesDestroyNode((SNode*)pOrder); + return NULL; + } + return (SNode*)pOrder; +} + +static int32_t rewriteTailOptCreateLimit(SNode* pLimit, SNode* pOffset, SNode** pOutput) { + SLimitNode* pLimitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT); + if (NULL == pLimitNode) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pLimitNode->limit = NULL == pLimit ? -1 : ((SValueNode*)pLimit)->datum.i; + pLimitNode->offset = NULL == pOffset ? -1 : ((SValueNode*)pOffset)->datum.i; + *pOutput = (SNode*)pLimitNode; + return TSDB_CODE_SUCCESS; +} + +static bool rewriteTailOptNeedGroupSort(SIndefRowsFuncLogicNode* pIndef) { + if (1 != LIST_LENGTH(pIndef->node.pChildren)) { + return false; + } + SNode* pChild = nodesListGetNode(pIndef->node.pChildren, 0); + return QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pChild) || + (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && NULL != ((SScanLogicNode*)pChild)->pGroupTags); +} + +static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) { + SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); + if (NULL == pSort) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pSort->groupSort = rewriteTailOptNeedGroupSort(pIndef); + TSWAP(pSort->node.pChildren, pIndef->node.pChildren); + pSort->node.precision = pIndef->node.precision; + + // tail(expr, [limit, offset,] _rowts) + SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0); + int32_t rowtsIndex = LIST_LENGTH(pTail->pParameterList) - 1; + + int32_t code = nodesListMakeStrictAppend( + &pSort->pSortKeys, rewriteTailOptCreateOrderByExpr(nodesListGetNode(pTail->pParameterList, rowtsIndex))); + if (TSDB_CODE_SUCCESS == code) { + pSort->node.pTargets = nodesCloneList(((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0))->pTargets); + if (NULL == pSort->node.pTargets) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = (SLogicNode*)pSort; + } else { + nodesDestroyNode((SNode*)pSort); + } + + return code; +} + +static SNode* rewriteTailOptCreateProjectExpr(SFunctionNode* pTail) { + SNode* pExpr = nodesCloneNode(nodesListGetNode(pTail->pParameterList, 0)); + if (NULL == pExpr) { + return NULL; + } + strcpy(((SExprNode*)pExpr)->aliasName, pTail->node.aliasName); + return pExpr; +} + +static int32_t rewriteTailOptCreateProject(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) { + SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); + if (NULL == pProject) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + TSWAP(pProject->node.pTargets, pIndef->node.pTargets); + pProject->node.precision = pIndef->node.precision; + + // tail(expr, [limit, offset,] _rowts) + SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0); + int32_t limitIndex = LIST_LENGTH(pTail->pParameterList) > 2 ? 1 : -1; + int32_t offsetIndex = LIST_LENGTH(pTail->pParameterList) > 3 ? 2 : -1; + + int32_t code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteTailOptCreateProjectExpr(pTail)); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteTailOptCreateLimit(limitIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, limitIndex), + offsetIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, offsetIndex), + &pProject->node.pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + *pOutput = (SLogicNode*)pProject; + } else { + nodesDestroyNode((SNode*)pProject); + } + return code; +} + +static int32_t rewriteTailOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, + SIndefRowsFuncLogicNode* pIndef) { + SLogicNode* pSort = NULL; + SLogicNode* pProject = NULL; + int32_t code = rewriteTailOptCreateSort(pIndef, &pSort); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteTailOptCreateProject(pIndef, &pProject); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeAppend(&pProject->pChildren, (SNode*)pSort); + pSort->pParent = pProject; + pSort = NULL; + } + if (TSDB_CODE_SUCCESS == code) { + code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pIndef, pProject); + } + if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode((SNode*)pIndef); + } else { + nodesDestroyNode((SNode*)pSort); + nodesDestroyNode((SNode*)pProject); + } + pCxt->optimized = true; + return code; +} + +static int32_t rewriteTailOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SIndefRowsFuncLogicNode* pIndef = + (SIndefRowsFuncLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, rewriteTailOptMayBeOptimized); + + if (NULL == pIndef) { + return TSDB_CODE_SUCCESS; + } + + return rewriteTailOptimizeImpl(pCxt, pLogicSubplan, pIndef); +} static bool eliminateSetOpMayBeOptimized(SLogicNode* pNode) { SLogicNode* pParent = pNode->pParent; if (NULL == pParent || - QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pParent) && QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pParent) || + QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pParent) && QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pParent) || LIST_LENGTH(pParent->pChildren) < 2) { return false; } - if (nodeType(pNode) != nodeType(pNode->pParent) || - LIST_LENGTH(pNode->pChildren) < 2) { + if (nodeType(pNode) != nodeType(pNode->pParent) || LIST_LENGTH(pNode->pChildren) < 2) { return false; } return true; } -static int32_t eliminateSetOpOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSetOpNode) { +static int32_t eliminateSetOpOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, + SLogicNode* pSetOpNode) { SNode* pSibling; FOREACH(pSibling, pSetOpNode->pParent->pChildren) { if (nodesEqualNode(pSibling, (SNode*)pSetOpNode)) { SNode* pChild; - FOREACH(pChild, pSetOpNode->pChildren) { - ((SLogicNode*)pChild)->pParent = pSetOpNode->pParent; - } + FOREACH(pChild, pSetOpNode->pChildren) { ((SLogicNode*)pChild)->pParent = pSetOpNode->pParent; } INSERT_LIST(pSetOpNode->pParent->pChildren, pSetOpNode->pChildren); pSetOpNode->pChildren = NULL; ERASE_NODE(pSetOpNode->pParent->pChildren); + pCxt->optimized = true; return TSDB_CODE_SUCCESS; } } @@ -1235,31 +1438,302 @@ static int32_t eliminateSetOpOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo return eliminateSetOpOptimizeImpl(pCxt, pLogicSubplan, pSetOpNode); } +static bool rewriteUniqueOptMayBeOptimized(SLogicNode* pNode) { + return QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC == nodeType(pNode) && ((SIndefRowsFuncLogicNode*)pNode)->isUniqueFunc; +} + +static SNode* rewriteUniqueOptCreateGroupingSet(SNode* pExpr) { + SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET); + if (NULL == pGroupingSet) { + return NULL; + } + pGroupingSet->groupingSetType = GP_TYPE_NORMAL; + SExprNode* pGroupExpr = (SExprNode*)nodesCloneNode(pExpr); + if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, (SNode*)pGroupExpr)) { + nodesDestroyNode((SNode*)pGroupingSet); + return NULL; + } + return (SNode*)pGroupingSet; +} + +static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode* pCol) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return NULL; + } + + strcpy(pFunc->functionName, "first"); + if (NULL != pSelectValue) { + sprintf(pFunc->node.aliasName, "%s", pSelectValue->node.aliasName); + } else { + sprintf(pFunc->node.aliasName, "%s.%p", pFunc->functionName, pFunc); + } + int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pCol)); + if (TSDB_CODE_SUCCESS == code) { + code = fmGetFuncInfo(pFunc, NULL, 0); + } + + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode((SNode*)pFunc); + return NULL; + } + + return (SNode*)pFunc; +} + +static int32_t rewriteUniqueOptCreateAgg(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) { + SAggLogicNode* pAgg = (SAggLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG); + if (NULL == pAgg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + TSWAP(pAgg->node.pChildren, pIndef->node.pChildren); + pAgg->node.precision = pIndef->node.precision; + + int32_t code = TSDB_CODE_SUCCESS; + bool hasSelectPrimaryKey = false; + SNode* pPrimaryKey = NULL; + SNode* pNode = NULL; + FOREACH(pNode, pIndef->pFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + SNode* pExpr = nodesListGetNode(pFunc->pParameterList, 0); + if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) { + pPrimaryKey = nodesListGetNode(pFunc->pParameterList, 1); + code = nodesListMakeStrictAppend(&pAgg->pGroupKeys, rewriteUniqueOptCreateGroupingSet(pExpr)); + } else if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId) { // _select_value(ts) => first(ts) + hasSelectPrimaryKey = true; + code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, rewriteUniqueOptCreateFirstFunc(pFunc, pExpr)); + } else { // _select_value(other_col) + code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, nodesCloneNode(pNode)); + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExprs(pAgg->pGroupKeys, &pAgg->node.pTargets); + } + if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pAggFuncs) { + code = createColumnByRewriteExprs(pAgg->pAggFuncs, &pAgg->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code && !hasSelectPrimaryKey && NULL != pAgg->pAggFuncs) { + code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, rewriteUniqueOptCreateFirstFunc(NULL, pPrimaryKey)); + } + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = (SLogicNode*)pAgg; + } else { + nodesDestroyNode((SNode*)pAgg); + } + return code; +} + +static SNode* rewriteUniqueOptCreateProjectCol(SFunctionNode* pFunc) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return NULL; + } + + pCol->node.resType = pFunc->node.resType; + if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) { + SExprNode* pExpr = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); + if (QUERY_NODE_COLUMN == nodeType(pExpr)) { + strcpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias); + strcpy(pCol->colName, ((SColumnNode*)pExpr)->colName); + } else { + strcpy(pCol->colName, pExpr->aliasName); + } + } else { + strcpy(pCol->colName, pFunc->node.aliasName); + } + strcpy(pCol->node.aliasName, pFunc->node.aliasName); + + return (SNode*)pCol; +} + +static int32_t rewriteUniqueOptCreateProject(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) { + SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); + if (NULL == pProject) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + TSWAP(pProject->node.pTargets, pIndef->node.pTargets); + pProject->node.precision = pIndef->node.precision; + + int32_t code = TSDB_CODE_SUCCESS; + SNode* pNode = NULL; + FOREACH(pNode, pIndef->pFuncs) { + code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteUniqueOptCreateProjectCol((SFunctionNode*)pNode)); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = (SLogicNode*)pProject; + } else { + nodesDestroyNode((SNode*)pProject); + } + return code; +} + +static int32_t rewriteUniqueOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, + SIndefRowsFuncLogicNode* pIndef) { + SLogicNode* pAgg = NULL; + SLogicNode* pProject = NULL; + int32_t code = rewriteUniqueOptCreateAgg(pIndef, &pAgg); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteUniqueOptCreateProject(pIndef, &pProject); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeAppend(&pProject->pChildren, (SNode*)pAgg); + pAgg->pParent = pProject; + pAgg = NULL; + } + if (TSDB_CODE_SUCCESS == code) { + code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pIndef, pProject); + } + if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode((SNode*)pIndef); + } else { + nodesDestroyNode((SNode*)pAgg); + nodesDestroyNode((SNode*)pProject); + } + pCxt->optimized = true; + return code; +} + +static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SIndefRowsFuncLogicNode* pIndef = + (SIndefRowsFuncLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, rewriteUniqueOptMayBeOptimized); + + if (NULL == pIndef) { + return TSDB_CODE_SUCCESS; + } + + return rewriteUniqueOptimizeImpl(pCxt, pLogicSubplan, pIndef); +} + +// merge projects +static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { + return false; + } + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pChild) || 1 < LIST_LENGTH(pChild->pChildren) || + NULL != pChild->pConditions || NULL != pChild->pLimit || NULL != pChild->pSlimit) { + return false; + } + return true; +} + +typedef struct SMergeProjectionsContext { + SProjectLogicNode* pChildProj; + int32_t errCode; +} SMergeProjectionsContext; + +static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { + SMergeProjectionsContext* pCxt = pContext; + SProjectLogicNode* pChildProj = pCxt->pChildProj; + if (QUERY_NODE_COLUMN == nodeType(*pNode)) { + SNode* pTarget; + FOREACH(pTarget, ((SLogicNode*)pChildProj)->pTargets) { + if (nodesEqualNode(pTarget, *pNode)) { + SNode* pProjection; + FOREACH(pProjection, pChildProj->pProjections) { + if (0 == strcmp(((SColumnNode*)pTarget)->colName, ((SExprNode*)pProjection)->aliasName)) { + SNode* pExpr = nodesCloneNode(pProjection); + if (pExpr == NULL) { + pCxt->errCode = terrno; + return DEAL_RES_ERROR; + } + nodesDestroyNode(*pNode); + *pNode = pExpr; + } + } + } + } + return DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) { + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0); + SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS}; + + nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt); + int32_t code = cxt.errCode; + + if (TSDB_CODE_SUCCESS == code) { + if (1 == LIST_LENGTH(pChild->pChildren)) { + SLogicNode* pGrandChild = (SLogicNode*)nodesListGetNode(pChild->pChildren, 0); + code = replaceLogicNode(pLogicSubplan, pChild, pGrandChild); + } else { // no grand child + NODES_CLEAR_LIST(pSelfNode->pChildren); + } + } + + if (TSDB_CODE_SUCCESS == code) { + NODES_CLEAR_LIST(pChild->pChildren); + } + nodesDestroyNode((SNode*)pChild); + pCxt->optimized = true; + return code; +} + +static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SLogicNode* pProjectNode = optFindPossibleNode(pLogicSubplan->pNode, mergeProjectsMayBeOptimized); + if (NULL == pProjectNode) { + return TSDB_CODE_SUCCESS; + } + + return mergeProjectsOptimizeImpl(pCxt, pLogicSubplan, pProjectNode); +} + // clang-format off static const SOptimizeRule optimizeRuleSet[] = { - {.pName = "OptimizeScanData", .optimizeFunc = osdOptimize}, - {.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize}, - {.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize}, - {.pName = "SmaIndex", .optimizeFunc = smaOptimize}, + {.pName = "ScanPath", .optimizeFunc = scanPathOptimize}, + {.pName = "PushDownCondition", .optimizeFunc = pushDownCondOptimize}, + {.pName = "SortPrimaryKey", .optimizeFunc = sortPrimaryKeyOptimize}, + {.pName = "SmaIndex", .optimizeFunc = smaIndexOptimize}, {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize}, + {.pName = "MergeProjects", .optimizeFunc = mergeProjectsOptimize}, {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}, - {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize} + {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, + {.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize}, + {.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize} }; // clang-format on static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule)); +static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { + char* pStr = NULL; + nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL); + qDebugL("apply optimize %s rule: %s", pRuleName, pStr); + taosMemoryFree(pStr); +} + static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan) { SOptimizeContext cxt = {.pPlanCxt = pCxt, .optimized = false}; + bool optimized = false; do { - cxt.optimized = false; + optimized = false; for (int32_t i = 0; i < optimizeRuleNum; ++i) { + cxt.optimized = false; int32_t code = optimizeRuleSet[i].optimizeFunc(&cxt, pLogicSubplan); if (TSDB_CODE_SUCCESS != code) { return code; } + if (cxt.optimized) { + optimized = true; + dumpLogicSubplan(optimizeRuleSet[i].pName, pLogicSubplan); + } } - } while (cxt.optimized); + } while (optimized); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 4f46abd8da..46747af3a9 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -41,8 +41,12 @@ typedef struct SPhysiPlanContext { static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; - if (NULL != pStmtName && '\0' != pStmtName[0]) { - return sprintf(pKey, "%s.%s", pStmtName, pCol->node.aliasName); + if (NULL != pStmtName) { + if ('\0' != pStmtName[0]) { + return sprintf(pKey, "%s.%s", pStmtName, pCol->node.aliasName); + } else { + return sprintf(pKey, "%s", pCol->node.aliasName); + } } if ('\0' == pCol->tableAlias[0]) { return sprintf(pKey, "%s", pCol->colName); @@ -56,11 +60,13 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) { return sprintf(pKey, "%s", ((SExprNode*)pNode)->aliasName); } -static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const SNode* pNode, int16_t slotId, bool output, bool reserve) { +static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const char* pName, const SNode* pNode, int16_t slotId, + bool output, bool reserve) { SSlotDescNode* pSlot = (SSlotDescNode*)nodesMakeNode(QUERY_NODE_SLOT_DESC); if (NULL == pSlot) { return NULL; } + strcpy(pSlot->name, pName); pSlot->slotId = slotId; pSlot->dataType = ((SExprNode*)pNode)->resType; pSlot->reserve = reserve; @@ -99,10 +105,8 @@ static int32_t putSlotToHashImpl(int16_t dataBlockId, int16_t slotId, const char return taosHashPut(pHash, pName, len, &index, sizeof(SSlotIndex)); } -static int32_t putSlotToHash(int16_t dataBlockId, int16_t slotId, SNode* pNode, SHashObj* pHash) { - char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN]; - int32_t len = getSlotKey(pNode, NULL, name); - return putSlotToHashImpl(dataBlockId, slotId, name, len, pHash); +static int32_t putSlotToHash(const char* pName, int16_t dataBlockId, int16_t slotId, SNode* pNode, SHashObj* pHash) { + return putSlotToHashImpl(dataBlockId, slotId, pName, strlen(pName), pHash); } static int32_t createDataBlockDescHash(SPhysiPlanContext* pCxt, int32_t capacity, int16_t dataBlockId, @@ -131,9 +135,11 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD int16_t slotId = 0; SNode* pNode = NULL; FOREACH(pNode, pList) { - code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, slotId, true, false)); + char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN]; + getSlotKey(pNode, NULL, name); + code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, name, pNode, slotId, true, false)); if (TSDB_CODE_SUCCESS == code) { - code = putSlotToHash(pDataBlockDesc->dataBlockId, slotId, pNode, pHash); + code = putSlotToHash(name, pDataBlockDesc->dataBlockId, slotId, pNode, pHash); } if (TSDB_CODE_SUCCESS == code) { pDataBlockDesc->totalRowSize += ((SExprNode*)pNode)->resType.bytes; @@ -196,7 +202,8 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, int32_t len = getSlotKey(pExpr, pStmtName, name); SSlotIndex* pIndex = taosHashGet(pHash, name, len); if (NULL == pIndex) { - code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output, reserve)); + code = + nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, name, pExpr, nextSlotId, output, reserve)); if (TSDB_CODE_SUCCESS == code) { code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash); } @@ -513,12 +520,13 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName); pTableScan->dataRequired = pScanLogicNode->dataRequired; pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs); - pTableScan->pPartitionTags = nodesCloneList(pScanLogicNode->pPartTags); + pTableScan->pGroupTags = nodesCloneList(pScanLogicNode->pGroupTags); if ((NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) || - (NULL != pScanLogicNode->pPartTags && NULL == pTableScan->pPartitionTags)) { + (NULL != pScanLogicNode->pGroupTags && NULL == pTableScan->pGroupTags)) { nodesDestroyNode((SNode*)pTableScan); return TSDB_CODE_OUT_OF_MEMORY; } + pTableScan->groupSort = pScanLogicNode->groupSort; pTableScan->interval = pScanLogicNode->interval; pTableScan->offset = pScanLogicNode->offset; pTableScan->sliding = pScanLogicNode->sliding; @@ -1170,8 +1178,9 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode, SPhysiNode** pPhyNode) { - SSortPhysiNode* pSort = - (SSortPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT); + SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode( + pCxt, (SLogicNode*)pSortLogicNode, + pSortLogicNode->groupSort ? QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT : QUERY_NODE_PHYSICAL_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1185,7 +1194,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code && NULL != pPrecalcExprs) { code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPrecalcExprs, &pSort->pExprs); if (TSDB_CODE_SUCCESS == code) { - code = addDataBlockSlots(pCxt, pSort->pExprs, pChildTupe); + code = pushdownDataBlockSlots(pCxt, pSort->pExprs, pChildTupe); } } @@ -1322,6 +1331,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM pMerge->numOfChannels = pMergeLogicNode->numOfChannels; pMerge->srcGroupId = pMergeLogicNode->srcGroupId; + pMerge->groupSort = pMergeLogicNode->groupSort; int32_t code = addDataBlockSlots(pCxt, pMergeLogicNode->pInputs, pMerge->node.pOutputDataBlockDesc); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index b4a966f206..9d23df5bda 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -362,7 +362,7 @@ static int32_t stbSplGetNumOfVgroups(SLogicNode* pNode) { } static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode, - SNodeList* pMergeKeys, SLogicNode* pPartChild) { + SNodeList* pMergeKeys, SLogicNode* pPartChild, bool groupSort) { SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; @@ -371,6 +371,7 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla pMerge->srcGroupId = pCxt->groupId; pMerge->node.precision = pPartChild->precision; pMerge->pMergeKeys = pMergeKeys; + pMerge->groupSort = groupSort; int32_t code = TSDB_CODE_SUCCESS; pMerge->pInputs = nodesCloneList(pPartChild->pTargets); @@ -430,7 +431,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo SNodeList* pMergeKeys = NULL; code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow); + code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow, false); } if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(pMergeKeys); @@ -497,12 +498,16 @@ static int32_t stbSplSplitSessionForStream(SSplitContext* pCxt, SStableSplitInfo return code; } -static void splSetTableScanType(SLogicNode* pNode, EScanType scanType) { +static void stbSplSetTableMergeScan(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { - ((SScanLogicNode*)pNode)->scanType = scanType; + SScanLogicNode* pScan = (SScanLogicNode*)pNode; + pScan->scanType = SCAN_TYPE_TABLE_MERGE; + if (NULL != pScan->pGroupTags) { + pScan->groupSort = true; + } } else { if (1 == LIST_LENGTH(pNode->pChildren)) { - splSetTableScanType((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), scanType); + stbSplSetTableMergeScan((SLogicNode*)nodesListGetNode(pNode->pChildren, 0)); } } } @@ -515,7 +520,7 @@ static int32_t stbSplSplitSessionOrStateForBatch(SSplitContext* pCxt, SStableSpl int32_t code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pWindow)->pTspk, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pChild, pMergeKeys, (SLogicNode*)pChild); + code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pChild, pMergeKeys, (SLogicNode*)pChild, true); } if (TSDB_CODE_SUCCESS == code) { @@ -524,13 +529,10 @@ static int32_t stbSplSplitSessionOrStateForBatch(SSplitContext* pCxt, SStableSpl } if (TSDB_CODE_SUCCESS == code) { - splSetTableScanType(pChild, SCAN_TYPE_TABLE_MERGE); - ++(pCxt->groupId); - } - - if (TSDB_CODE_SUCCESS == code) { + stbSplSetTableMergeScan(pChild); pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT); + ++(pCxt->groupId); } else { nodesDestroyList(pMergeKeys); } @@ -560,7 +562,7 @@ static int32_t stbSplSplitState(SSplitContext* pCxt, SStableSplitInfo* pInfo) { static SNodeList* stbSplGetPartKeys(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { - return ((SScanLogicNode*)pNode)->pPartTags; + return ((SScanLogicNode*)pNode)->pGroupTags; } else if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) { return ((SPartitionLogicNode*)pNode)->pPartitionKeys; } else { @@ -775,6 +777,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut pPartSort->node.pChildren = pChildren; splSetParent((SLogicNode*)pPartSort); pPartSort->pSortKeys = pSortKeys; + pPartSort->groupSort = pSort->groupSort; code = stbSplCreateMergeKeys(pPartSort->pSortKeys, pPartSort->node.pTargets, &pMergeKeys); } @@ -789,12 +792,29 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut return code; } +static void stbSplSetScanPartSort(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + SScanLogicNode* pScan = (SScanLogicNode*)pNode; + if (NULL != pScan->pGroupTags) { + pScan->groupSort = true; + } + } else { + if (1 == LIST_LENGTH(pNode->pChildren)) { + stbSplSetScanPartSort((SLogicNode*)nodesListGetNode(pNode->pChildren, 0)); + } + } +} + static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { SLogicNode* pPartSort = NULL; SNodeList* pMergeKeys = NULL; + bool groupSort = ((SSortLogicNode*)pInfo->pSplitNode)->groupSort; int32_t code = stbSplCreatePartSortNode((SSortLogicNode*)pInfo->pSplitNode, &pPartSort, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, pMergeKeys, pPartSort); + code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, pMergeKeys, pPartSort, groupSort); + } + if (TSDB_CODE_SUCCESS == code && groupSort) { + stbSplSetScanPartSort(pPartSort); } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, @@ -829,7 +849,7 @@ static int32_t stbSplSplitScanNodeForJoin(SSplitContext* pCxt, SLogicSubplan* pS SNodeList* pMergeKeys = NULL; int32_t code = stbSplCreateMergeKeysByPrimaryKey(stbSplFindPrimaryKeyFromScan(pScan), &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, (SLogicNode*)pScan); + code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, (SLogicNode*)pScan, false); } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pSubplan->pChildren, @@ -1217,7 +1237,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { char* pStr = NULL; nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL); - qDebugL("apply %s rule: %s", pRuleName, pStr); + qDebugL("apply split %s rule: %s", pRuleName, pStr); taosMemoryFree(pStr); } diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index e75c8375fb..1b9d16311c 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -85,6 +85,11 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream return setSubplanExecutionNode(subplan->pNode, groupId, pSource); } +int32_t qClearSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId) { + // todo + return TSDB_CODE_FAILED; +} + int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) { if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) { SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink; diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index ea40567dae..ff725c444e 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -56,6 +56,8 @@ TEST_F(PlanBasicTest, uniqueFunc) { run("SELECT UNIQUE(c2 + 10) FROM t1 WHERE c1 > 10"); + run("SELECT UNIQUE(c2 + 10), c2 FROM t1 WHERE c1 > 10"); + run("SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10"); run("SELECT UNIQUE(c1) a FROM t1 ORDER BY a"); @@ -67,6 +69,16 @@ TEST_F(PlanBasicTest, tailFunc) { run("SELECT TAIL(c1, 10) FROM t1"); run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10"); + + run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1"); + + run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 ORDER BY 1"); + + run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 LIMIT 5"); + + run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5"); + + run("SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2"); } TEST_F(PlanBasicTest, interpFunc) { @@ -89,6 +101,16 @@ TEST_F(PlanBasicTest, lastRowFunc) { run("SELECT LAST_ROW(c1) FROM st1"); } +TEST_F(PlanBasicTest, sampleFunc) { + useDb("root", "test"); + + run("SELECT SAMPLE(c1, 10) FROM t1"); + + run("SELECT SAMPLE(c1, 10) FROM st1"); + + run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME"); +} + TEST_F(PlanBasicTest, withoutFrom) { useDb("root", "test"); diff --git a/source/libs/planner/test/planOptimizeTest.cpp b/source/libs/planner/test/planOptimizeTest.cpp index 9bd95a79f9..6a9a711dac 100644 --- a/source/libs/planner/test/planOptimizeTest.cpp +++ b/source/libs/planner/test/planOptimizeTest.cpp @@ -20,7 +20,7 @@ using namespace std; class PlanOptimizeTest : public PlannerTestBase {}; -TEST_F(PlanOptimizeTest, optimizeScanData) { +TEST_F(PlanOptimizeTest, scanPath) { useDb("root", "test"); run("SELECT COUNT(*) FROM t1"); @@ -32,7 +32,7 @@ TEST_F(PlanOptimizeTest, optimizeScanData) { run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1"); } -TEST_F(PlanOptimizeTest, ConditionPushDown) { +TEST_F(PlanOptimizeTest, pushDownCondition) { useDb("root", "test"); run("SELECT ts, c1 FROM st1 WHERE tag1 > 4"); @@ -42,9 +42,11 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) { run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"); run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello' AND c1 > 10"); + + run("SELECT ts, c1 FROM (SELECT * FROM st1) WHERE tag1 > 4"); } -TEST_F(PlanOptimizeTest, orderByPrimaryKey) { +TEST_F(PlanOptimizeTest, sortPrimaryKey) { useDb("root", "test"); run("SELECT c1 FROM t1 ORDER BY ts"); diff --git a/source/libs/planner/test/planTestMain.cpp b/source/libs/planner/test/planTestMain.cpp index 43b6bf5772..46c2f33048 100644 --- a/source/libs/planner/test/planTestMain.cpp +++ b/source/libs/planner/test/planTestMain.cpp @@ -76,6 +76,7 @@ static void parseArg(int argc, char* argv[]) { static struct option long_options[] = { {"dump", optional_argument, NULL, 'd'}, {"skipSql", required_argument, NULL, 's'}, + {"limitSql", required_argument, NULL, 'i'}, {"log", required_argument, NULL, 'l'}, {0, 0, 0, 0} }; @@ -88,6 +89,9 @@ static void parseArg(int argc, char* argv[]) { case 's': setSkipSqlNum(optarg); break; + case 'i': + setLimitSqlNum(optarg); + break; case 'l': setLogLevel(optarg); break; diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index c197a02dd1..d54859c296 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -51,6 +51,7 @@ enum DumpModule { DumpModule g_dumpModule = DUMP_MODULE_NOTHING; int32_t g_skipSql = 0; +int32_t g_limitSql = 0; int32_t g_logLevel = 131; void setDumpModule(const char* pModule) { @@ -76,28 +77,33 @@ void setDumpModule(const char* pModule) { } void setSkipSqlNum(const char* pNum) { g_skipSql = stoi(pNum); } - +void setLimitSqlNum(const char* pNum) { g_limitSql = stoi(pNum); } void setLogLevel(const char* pLogLevel) { g_logLevel = stoi(pLogLevel); } int32_t getLogLevel() { return g_logLevel; } class PlannerTestBaseImpl { public: - PlannerTestBaseImpl() : sqlNo_(0) {} + PlannerTestBaseImpl() : sqlNo_(0), sqlNum_(0) {} void useDb(const string& user, const string& db) { caseEnv_.acctId_ = 0; caseEnv_.user_ = user; caseEnv_.db_ = db; - caseEnv_.nsql_ = g_skipSql; + caseEnv_.numOfSkipSql_ = g_skipSql; + caseEnv_.numOfLimitSql_ = g_limitSql; } void run(const string& sql) { ++sqlNo_; - if (caseEnv_.nsql_ > 0) { - --(caseEnv_.nsql_); + if (caseEnv_.numOfSkipSql_ > 0) { + --(caseEnv_.numOfSkipSql_); return; } + if (caseEnv_.numOfLimitSql_ > 0 && caseEnv_.numOfLimitSql_ == sqlNum_) { + return; + } + ++sqlNum_; reset(); try { @@ -134,7 +140,7 @@ class PlannerTestBaseImpl { } void prepare(const string& sql) { - if (caseEnv_.nsql_ > 0) { + if (caseEnv_.numOfSkipSql_ > 0) { return; } @@ -148,7 +154,7 @@ class PlannerTestBaseImpl { } void bindParams(TAOS_MULTI_BIND* pParams, int32_t colIdx) { - if (caseEnv_.nsql_ > 0) { + if (caseEnv_.numOfSkipSql_ > 0) { return; } @@ -161,8 +167,8 @@ class PlannerTestBaseImpl { } void exec() { - if (caseEnv_.nsql_ > 0) { - --(caseEnv_.nsql_); + if (caseEnv_.numOfSkipSql_ > 0) { + --(caseEnv_.numOfSkipSql_); return; } @@ -197,9 +203,10 @@ class PlannerTestBaseImpl { int32_t acctId_; string user_; string db_; - int32_t nsql_; + int32_t numOfSkipSql_; + int32_t numOfLimitSql_; - caseEnv() : nsql_(0) {} + caseEnv() : numOfSkipSql_(0) {} }; struct stmtEnv { @@ -401,6 +408,7 @@ class PlannerTestBaseImpl { stmtEnv stmtEnv_; stmtRes res_; int32_t sqlNo_; + int32_t sqlNum_; }; PlannerTestBase::PlannerTestBase() : impl_(new PlannerTestBaseImpl()) {} diff --git a/source/libs/planner/test/planTestUtil.h b/source/libs/planner/test/planTestUtil.h index 7d2a9e533f..f9942c93a7 100644 --- a/source/libs/planner/test/planTestUtil.h +++ b/source/libs/planner/test/planTestUtil.h @@ -43,6 +43,7 @@ class PlannerTestBase : public testing::Test { extern void setDumpModule(const char* pModule); extern void setSkipSqlNum(const char* pNum); +extern void setLimitSqlNum(const char* pNum); extern void setLogLevel(const char* pLogLevel); extern int32_t getLogLevel(); diff --git a/source/libs/sync/inc/syncRaftEntry.h b/source/libs/sync/inc/syncRaftEntry.h index b130186516..37f18a6388 100644 --- a/source/libs/sync/inc/syncRaftEntry.h +++ b/source/libs/sync/inc/syncRaftEntry.h @@ -56,6 +56,31 @@ void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj); void syncEntryLog(const SSyncRaftEntry* pObj); void syncEntryLog2(char* s, const SSyncRaftEntry* pObj); +//----------------------------------- +typedef struct SRaftEntryCache { + SHashObj* pEntryHash; + int32_t maxCount; + int32_t currentCount; + TdThreadMutex mutex; + SSyncNode* pSyncNode; +} SRaftEntryCache; + +SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount); +void raftCacheDestroy(SRaftEntryCache* pCache); +int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry); +int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index); +int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheClear(struct SRaftEntryCache* pCache); + +cJSON* raftCache2Json(SRaftEntryCache* pObj); +char* raftCache2Str(SRaftEntryCache* pObj); +void raftCachePrint(SRaftEntryCache* pObj); +void raftCachePrint2(char* s, SRaftEntryCache* pObj); +void raftCacheLog(SRaftEntryCache* pObj); +void raftCacheLog2(char* s, SRaftEntryCache* pObj); + #ifdef __cplusplus } #endif diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index f00dfe6f50..14688f8912 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -35,12 +35,13 @@ extern "C" { #define SYNC_SNAPSHOT_RETRY_MS 5000 +//--------------------------------------------------- typedef struct SSyncSnapshotSender { bool start; int32_t seq; int32_t ack; - void * pReader; - void * pCurrentBlock; + void *pReader; + void *pCurrentBlock; int32_t blockLen; SSnapshot snapshot; SSyncCfg lastConfig; @@ -56,36 +57,39 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI void snapshotSenderDestroy(SSyncSnapshotSender *pSender); bool snapshotSenderIsStart(SSyncSnapshotSender *pSender); void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader); -void snapshotSenderStop(SSyncSnapshotSender *pSender); +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); -cJSON * snapshotSender2Json(SSyncSnapshotSender *pSender); -char * snapshotSender2Str(SSyncSnapshotSender *pSender); -char * snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event); +cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender); +char *snapshotSender2Str(SSyncSnapshotSender *pSender); +char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event); + +//--------------------------------------------------- typedef struct SSyncSnapshotReceiver { - bool start; - - int32_t ack; - void * pWriter; - SyncTerm term; - SyncTerm privateTerm; - SSnapshot snapshot; - - SSyncNode *pSyncNode; + bool start; + int32_t ack; + void *pWriter; + SyncTerm term; + SyncTerm privateTerm; + SSnapshot snapshot; SRaftId fromId; + SSyncNode *pSyncNode; } SSyncSnapshotReceiver; SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId fromId); void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); -bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply); -cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); -char * snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); -char * snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event); +void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); +bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); +cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); +char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); +char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event); + +//--------------------------------------------------- +// on message int32_t syncNodeOnSnapshotSendCb(SSyncNode *ths, SyncSnapshotSend *pMsg); int32_t syncNodeOnSnapshotRspCb(SSyncNode *ths, SyncSnapshotRsp *pMsg); diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index b7122b9c52..10f2745651 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -240,7 +240,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); ASSERT(pSender != NULL); - SSnapshot snapshot; + SSnapshot snapshot = {.data = NULL, + .lastApplyIndex = SYNC_INDEX_INVALID, + .lastApplyTerm = 0, + .lastConfigIndex = SYNC_INDEX_INVALID}; void* pReader = NULL; ths->pFsm->FpGetSnapshot(ths->pFsm, &snapshot, NULL, &pReader); if (snapshot.lastApplyIndex >= SYNC_INDEX_BEGIN && nextIndex <= snapshot.lastApplyIndex + 1 && @@ -249,10 +252,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries ASSERT(pReader != NULL); snapshotSenderStart(pSender, snapshot, pReader); - char* eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); - syncNodeEventLog(ths, eventLog); - taosMemoryFree(eventLog); - } else { // no snapshot if (pReader != NULL) { @@ -260,23 +259,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } } - /* - bool hasSnapshot = syncNodeHasSnapshot(ths); - SSnapshot snapshot; - ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); - - // start sending snapshot first time - // start here, stop by receiver - if (hasSnapshot && nextIndex <= snapshot.lastApplyIndex + 1 && !snapshotSenderIsStart(pSender) && - pMsg->privateTerm < pSender->privateTerm) { - snapshotSenderStart(pSender); - - char* eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); - syncNodeEventLog(ths, eventLog); - taosMemoryFree(eventLog); - } - */ - SyncIndex sentryIndex = pSender->snapshot.lastApplyIndex + 1; // update nextIndex to sentryIndex @@ -300,5 +282,5 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries syncIndexMgrLog2("recv sync-append-entries-reply, after pNextIndex:", ths->pNextIndex); syncIndexMgrLog2("recv sync-append-entries-reply, after pMatchIndex:", ths->pMatchIndex); - return ret; + return 0; } \ No newline at end of file diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 3996193037..f6768bf494 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -698,7 +698,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { } else { ret = -1; terrno = TSDB_CODE_SYN_NOT_LEADER; - sError("syncPropose not leader, %s", syncUtilState2String(pSyncNode->state)); + sError("sync propose not leader, %s", syncUtilState2String(pSyncNode->state)); goto _END; } @@ -1355,11 +1355,16 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { int32_t userStrLen = strlen(str); SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; - if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { + if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } - SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + + SyncIndex logLastIndex = SYNC_INDEX_INVALID; + SyncIndex logBeginIndex = SYNC_INDEX_INVALID; + if (pSyncNode->pLogStore != NULL) { + logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + } char* pCfgStr = syncCfg2SimpleStr(&(pSyncNode->pRaftCfg->cfg)); char* printStr = ""; @@ -1409,46 +1414,59 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) { int32_t userStrLen = strlen(str); SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; - if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { + if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } - SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + + SyncIndex logLastIndex = SYNC_INDEX_INVALID; + SyncIndex logBeginIndex = SYNC_INDEX_INVALID; + if (pSyncNode->pLogStore != NULL) { + logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + } + + char* pCfgStr = syncCfg2SimpleStr(&(pSyncNode->pRaftCfg->cfg)); + char* printStr = ""; + if (pCfgStr != NULL) { + printStr = pCfgStr; + } if (userStrLen < 256) { - char logBuf[128 + 256]; + char logBuf[256 + 256]; if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(logBuf, sizeof(logBuf), "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(logBuf, sizeof(logBuf), "%s", str); } sError("%s", logBuf); } else { - int len = 128 + userStrLen; + int len = 256 + userStrLen; char* s = (char*)taosMemoryMalloc(len); if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(s, len, "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(s, len, "%s", str); } sError("%s", s); taosMemoryFree(s); } + + taosMemoryFree(pCfgStr); } char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { @@ -1470,18 +1488,6 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); - /* - snprintf(s, len, - "syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, " - "lc:%lu, " - "lc-user:%lu, " - "ems:%d, replica-num:%d, restore:%d, changing:%d", - pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state, - syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock, - pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum, - pSyncNode->restoreFinish, pSyncNode->changing); - */ - return s; } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index ff334a76bb..225360630c 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -180,3 +180,247 @@ void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) { sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } + +//----------------------------------- +SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) { + SRaftEntryCache* pCache = taosMemoryMalloc(sizeof(SRaftEntryCache)); + if (pCache == NULL) { + sError("vgId:%d raft cache create error", pSyncNode->vgId); + return NULL; + } + + pCache->pEntryHash = + taosHashInit(sizeof(SyncIndex), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pCache->pEntryHash == NULL) { + sError("vgId:%d raft cache create hash error", pSyncNode->vgId); + return NULL; + } + + taosThreadMutexInit(&(pCache->mutex), NULL); + pCache->maxCount = maxCount; + pCache->currentCount = 0; + pCache->pSyncNode = pSyncNode; + + return pCache; +} + +void raftCacheDestroy(SRaftEntryCache* pCache) { + if (pCache != NULL) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashCleanup(pCache->pEntryHash); + taosThreadMutexUnlock(&(pCache->mutex)); + taosThreadMutexDestroy(&(pCache->mutex)); + taosMemoryFree(pCache); + } +} + +// success, return 1 +// max count, return 0 +// error, return -1 +int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry) { + taosThreadMutexLock(&(pCache->mutex)); + + if (pCache->currentCount >= pCache->maxCount) { + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosHashPut(pCache->pEntryHash, &(pEntry->index), sizeof(pEntry->index), pEntry, pEntry->bytes); + ++(pCache->currentCount); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache add, type:%s,%d, type2:%s,%d, index:%ld, bytes:%d", + TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType, + pEntry->index, pEntry->bytes); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 1; +} + +// success, return 0 +// error, return -1 +// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = taosMemoryMalloc(pEntry->bytes); + memcpy(*ppEntry, pTmp, pEntry->bytes); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +// success, return 0 +// error, return -1 +// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = pEntry; + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; +} + +int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = taosMemoryMalloc(pEntry->bytes); + memcpy(*ppEntry, pTmp, pEntry->bytes); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get-and-del, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +int32_t raftCacheClear(struct SRaftEntryCache* pCache) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashClear(pCache->pEntryHash); + pCache->currentCount = 0; + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; +} + +//----------------------------------- +cJSON* raftCache2Json(SRaftEntryCache* pCache) { + char u64buf[128] = {0}; + cJSON* pRoot = cJSON_CreateObject(); + + if (pCache != NULL) { + taosThreadMutexLock(&(pCache->mutex)); + + snprintf(u64buf, sizeof(u64buf), "%p", pCache->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + cJSON_AddNumberToObject(pRoot, "currentCount", pCache->currentCount); + cJSON_AddNumberToObject(pRoot, "maxCount", pCache->maxCount); + cJSON* pEntries = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "entries", pEntries); + + SSyncRaftEntry* pIter = (SSyncRaftEntry*)taosHashIterate(pCache->pEntryHash, NULL); + if (pIter != NULL) { + SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pIter; + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + } + while (pIter) { + pIter = taosHashIterate(pCache->pEntryHash, pIter); + if (pIter != NULL) { + SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pIter; + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + } + } + + taosThreadMutexUnlock(&(pCache->mutex)); + } + + cJSON* pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SRaftEntryCache", pRoot); + return pJson; +} + +char* raftCache2Str(SRaftEntryCache* pCache) { + cJSON* pJson = raftCache2Json(pCache); + char* serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + +void raftCachePrint(SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + printf("raftCachePrint | len:%lu | %s \n", strlen(serialized), serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void raftCachePrint2(char* s, SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + printf("raftCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void raftCacheLog(SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + sTrace("raftCacheLog | len:%lu | %s", strlen(serialized), serialized); + taosMemoryFree(serialized); +} + +void raftCacheLog2(char* s, SRaftEntryCache* pCache) { + if (gRaftDetailLog) { + char* serialized = raftCache2Str(pCache); + sTraceLong("raftCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + taosMemoryFree(serialized); + } +} \ No newline at end of file diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 48c1b70a04..d2cbabe226 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -32,11 +32,13 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) { } void syncRespMgrDestroy(SSyncRespMgr *pObj) { - taosThreadMutexLock(&(pObj->mutex)); - taosHashCleanup(pObj->pRespHash); - taosThreadMutexUnlock(&(pObj->mutex)); - taosThreadMutexDestroy(&(pObj->mutex)); - taosMemoryFree(pObj); + if (pObj != NULL) { + taosThreadMutexLock(&(pObj->mutex)); + taosHashCleanup(pObj->pRespHash); + taosThreadMutexUnlock(&(pObj->mutex)); + taosThreadMutexDestroy(&(pObj->mutex)); + taosMemoryFree(pObj); + } } int64_t syncRespMgrAdd(SSyncRespMgr *pObj, SRespStub *pStub) { diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 0feaf532bb..0e77876b97 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -21,8 +21,10 @@ #include "syncUtil.h" #include "wal.h" +//---------------------------------- static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); +static void snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg); //---------------------------------- SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex) { @@ -49,7 +51,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot)); pSender->finish = false; } else { - sError("snapshotSenderCreate cannot create sender"); + sError("vgId:%d, cannot create snapshot sender", pSyncNode->vgId); } return pSender; @@ -57,39 +59,59 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender != NULL) { + // free current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); + pSender->pCurrentBlock = NULL; } + + // close reader + if (pSender->pReader != NULL) { + int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); + ASSERT(ret == 0); + pSender->pReader = NULL; + } + + // free sender taosMemoryFree(pSender); } } bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; } -// begin send snapshot (current term, seq begin) +// begin send snapshot by snapshot, pReader void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader) { ASSERT(!snapshotSenderIsStart(pSender)); - pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; - // init snapshot and reader ASSERT(pSender->pReader == NULL); pSender->pReader = pReader; pSender->snapshot = snapshot; + // init current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); } pSender->blockLen = 0; + // update term + pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; + ++(pSender->privateTerm); + + // update state + pSender->finish = false; + pSender->start = true; + pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; + pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; + + // init last config if (pSender->snapshot.lastConfigIndex != SYNC_INDEX_INVALID) { int32_t code = 0; SSyncRaftEntry *pEntry = NULL; + bool getLastConfig = false; + code = pSender->pSyncNode->pLogStore->syncLogGetEntry(pSender->pSyncNode->pLogStore, pSender->snapshot.lastConfigIndex, &pEntry); - - bool getLastConfig = false; if (code == 0) { ASSERT(pEntry != NULL); @@ -106,35 +128,35 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void syncEntryDestory(pEntry); } else { if (pSender->snapshot.lastConfigIndex == pSender->pSyncNode->pRaftCfg->lastConfigIndex) { - sTrace("vgId:%d sync sender get cfg from local", pSender->pSyncNode->vgId); + sTrace("vgId:%d, sync sender get cfg from local", pSender->pSyncNode->vgId); pSender->lastConfig = pSender->pSyncNode->pRaftCfg->cfg; getLastConfig = true; } } + // last config not found in wal, update to -1 if (!getLastConfig) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %ld to -1", - pSender->snapshot.lastConfigIndex); - pSender->snapshot.lastConfigIndex = -1; - - char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - + SyncIndex oldLastConfigIndex = pSender->snapshot.lastConfigIndex; + SyncIndex newLastConfigIndex = SYNC_INDEX_INVALID; + pSender->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg)); + + // event log + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %ld to %ld", oldLastConfigIndex, + newLastConfigIndex); + char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } else { + // no last config memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg)); } - pSender->sendingMS = SYNC_SNAPSHOT_RETRY_MS; - pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; - ++(pSender->privateTerm); - pSender->finish = false; - pSender->start = true; - // build begin msg SyncSnapshotSend *pMsg = syncSnapshotSendBuild(0, pSender->pSyncNode->vgId); pMsg->srcId = pSender->pSyncNode->myRaftId; @@ -151,40 +173,47 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender send"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } -void snapshotSenderStop(SSyncSnapshotSender *pSender) { +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { + // close reader if (pSender->pReader != NULL) { int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); ASSERT(ret == 0); pSender->pReader = NULL; } + // free current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); pSender->pCurrentBlock = NULL; pSender->blockLen = 0; } + // update flag pSender->start = false; + pSender->finish = finish; - if (gRaftDetailLog) { - char *s = snapshotSender2Str(pSender); - sInfo("snapshotSenderStop %s", s); - taosMemoryFree(s); - } + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender stop"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } -// when sender receiver ack, call this function to send msg from seq +// when sender receive ack, call this function to send msg from seq // seq = ack + 1, already updated int32_t snapshotSend(SSyncSnapshotSender *pSender) { - // free memory last time (seq - 1) + // free memory last time (current seq - 1) if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); pSender->pCurrentBlock = NULL; @@ -198,7 +227,7 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { if (pSender->blockLen > 0) { // has read data } else { - // read finish + // read finish, update seq to end pSender->seq = SYNC_SNAPSHOT_SEQ_END; } @@ -219,25 +248,28 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender finish"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - - } else { - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender sending"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - } - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = NULL; + if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { + eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender finish"); + } else { + eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender sending"); + } + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + return 0; } // send snapshot data from cache int32_t snapshotReSend(SSyncSnapshotSender *pSender) { - if (pSender->pCurrentBlock != NULL) { + // send current block data + if (pSender->pCurrentBlock != NULL && pSender->blockLen > 0) { + // build msg SyncSnapshotSend *pMsg = syncSnapshotSendBuild(pSender->blockLen, pSender->pSyncNode->vgId); pMsg->srcId = pSender->pSyncNode->myRaftId; pMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; @@ -249,16 +281,20 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { pMsg->seq = pSender->seq; memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); + // send msg SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender resend"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender resend"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } + return 0; } @@ -294,7 +330,6 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { snprintf(u64buf, sizeof(u64buf), "%lu", pSender->snapshot.lastApplyTerm); cJSON_AddStringToObject(pSnapshot, "lastApplyTerm", u64buf); cJSON_AddItemToObject(pRoot, "snapshot", pSnapshot); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->sendingMS); cJSON_AddStringToObject(pRoot, "sendingMS", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSender->pSyncNode); @@ -314,22 +349,23 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { char *snapshotSender2Str(SSyncSnapshotSender *pSender) { cJSON *pJson = snapshotSender2Json(pSender); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) { int32_t len = 256; - char * s = taosMemoryMalloc(len); + char *s = taosMemoryMalloc(len); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - char host[128]; + char host[64]; uint16_t port; syncUtilU642Addr(destId.addr, host, sizeof(host), &port); - snprintf(s, len, "%s %p laindex:%ld laterm:%lu lcindex:%ld seq:%d ack:%d finish:%d pterm:%lu replica-index:%d %s:%d", - event, pSender, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, + snprintf(s, len, + "%s {%p laindex:%ld laterm:%lu lcindex:%ld seq:%d ack:%d finish:%d pterm:%lu replica-index:%d %s:%d}", event, + pSender, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->privateTerm, pSender->replicaIndex, host, port); @@ -355,12 +391,12 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->term = pSyncNode->pRaftStore->currentTerm; pReceiver->privateTerm = 0; pReceiver->snapshot.data = NULL; - pReceiver->snapshot.lastApplyIndex = -1; + pReceiver->snapshot.lastApplyIndex = SYNC_INDEX_INVALID; pReceiver->snapshot.lastApplyTerm = 0; - pReceiver->snapshot.lastConfigIndex = -1; + pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; } else { - sInfo("snapshotReceiverCreate cannot create receiver"); + sError("vgId:%d, cannot create snapshot receiver", pSyncNode->vgId); } return pReceiver; @@ -368,60 +404,54 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { if (pReceiver != NULL) { + // close writer + if (pReceiver->pWriter != NULL) { + int32_t ret = + pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); + ASSERT(ret == 0); + pReceiver->pWriter = NULL; + } + + // free receiver taosMemoryFree(pReceiver); } } bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver) { return pReceiver->start; } -// begin receive snapshot msg (current term, seq begin) +// static do start by privateTerm, pBeginMsg +// receive first snapshot data +// write first block data static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { + // update state pReceiver->term = pReceiver->pSyncNode->pRaftStore->currentTerm; pReceiver->privateTerm = privateTerm; pReceiver->ack = SYNC_SNAPSHOT_SEQ_BEGIN; pReceiver->fromId = pBeginMsg->srcId; + pReceiver->start = true; + // update snapshot pReceiver->snapshot.lastApplyIndex = pBeginMsg->lastIndex; pReceiver->snapshot.lastApplyTerm = pBeginMsg->lastTerm; pReceiver->snapshot.lastConfigIndex = pBeginMsg->lastConfigIndex; + // write data ASSERT(pReceiver->pWriter == NULL); int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStartWrite(pReceiver->pSyncNode->pFsm, &(pReceiver->pWriter)); ASSERT(ret == 0); + + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver start"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } -// if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver -// if already start, force close, start again -void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { - if (!snapshotReceiverIsStart(pReceiver)) { - // start - snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); - pReceiver->start = true; - - } else { - // already start - sInfo("snapshot recv, receiver already start"); - - // force close, abandon incomplete data - int32_t ret = - pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); - ASSERT(ret == 0); - pReceiver->pWriter = NULL; - - // start again - snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); - pReceiver->start = true; - } - - if (gRaftDetailLog) { - char *s = snapshotReceiver2Str(pReceiver); - sInfo("snapshotReceiverStart %s", s); - taosMemoryFree(s); - } -} - -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { +// force stop +static void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { + // force close, abandon incomplete data if (pReceiver->pWriter != NULL) { int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); @@ -431,14 +461,106 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { pReceiver->start = false; - if (apply) { - // ++(pReceiver->privateTerm); + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver force stop"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); +} + +// if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver +// if already start, force close, start again +void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { + if (!snapshotReceiverIsStart(pReceiver)) { + // first start + snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); + + } else { + // already start + sInfo("vgId:%d, snapshot recv, receiver already start", pReceiver->pSyncNode->vgId); + + // force close, abandon incomplete data + snapshotReceiverForceStop(pReceiver); + + // start again + snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); + } +} + +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { + if (pReceiver->pWriter != NULL) { + int32_t ret = + pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); + ASSERT(ret == 0); + pReceiver->pWriter = NULL; } - if (gRaftDetailLog) { - char *s = snapshotReceiver2Str(pReceiver); - sInfo("snapshotReceiverStop %s", s); - taosMemoryFree(s); + pReceiver->start = false; + + // event log + do { + SSnapshot snapshot; + pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver stop"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); +} + +static void snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { + ASSERT(pMsg->seq == SYNC_SNAPSHOT_SEQ_END); + + if (pReceiver->pWriter != NULL) { + int32_t code = 0; + if (pMsg->dataLen > 0) { + code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, + pMsg->dataLen); + ASSERT(code == 0); + } + + code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true); + ASSERT(code == 0); + pReceiver->pWriter = NULL; + } + + pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; + + // update commit index + if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { + pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; + } + + // reset wal + pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); + + // event log + do { + SSnapshot snapshot; + pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver got last data, finish, apply snapshot"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); +} + +static void snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { + ASSERT(pMsg->seq == pReceiver->ack + 1); + + if (pReceiver->pWriter != NULL) { + if (pMsg->dataLen > 0) { + int32_t code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, + pMsg->data, pMsg->dataLen); + ASSERT(code == 0); + } + pReceiver->ack = pMsg->seq; + + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver receiving"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } @@ -461,7 +583,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; - cJSON * pTmp = pFromId; + cJSON *pTmp = pFromId; char host[128] = {0}; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); @@ -494,21 +616,21 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) { cJSON *pJson = snapshotReceiver2Json(pReceiver); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event) { int32_t len = 256; - char * s = taosMemoryMalloc(len); + char *s = taosMemoryMalloc(len); SRaftId fromId = pReceiver->fromId; char host[128]; uint16_t port; syncUtilU642Addr(fromId.addr, host, sizeof(host), &port); - snprintf(s, len, "%s %p start:%d ack:%d term:%lu pterm:%lu from:%s:%d laindex:%ld laterm:%lu lcindex:%ld", event, + snprintf(s, len, "%s {%p start:%d ack:%d term:%lu pterm:%lu from:%s:%d laindex:%ld laterm:%lu lcindex:%ld}", event, pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, pReceiver->privateTerm, host, port, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex); @@ -520,33 +642,20 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // get receiver SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; bool needRsp = false; - int32_t writeCode = 0; // state, term, seq/ack if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { - // begin + // begin, no data snapshotReceiverStart(pReceiver, pMsg->privateTerm, pMsg); - pReceiver->ack = pMsg->seq; needRsp = true; - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver begin"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { // end, finish FSM - writeCode = pSyncNode->pFsm->FpSnapshotDoWrite(pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); - ASSERT(writeCode == 0); - - pSyncNode->pFsm->FpSnapshotStopWrite(pSyncNode->pFsm, pReceiver->pWriter, true); - if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { - pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; - } - - // pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1); - pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pSyncNode->pLogStore, pMsg->lastIndex); + snapshotReceiverFinish(pReceiver, pMsg); + snapshotReceiverStop(pReceiver); + needRsp = true; // maybe update lastconfig if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) { @@ -561,89 +670,83 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { syncNodeDoConfigChange(pSyncNode, &newSyncCfg, pMsg->lastConfigIndex); } - SSnapshot snapshot; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver finish, apply snapshot"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - - pReceiver->pWriter = NULL; - snapshotReceiverStop(pReceiver, true); - pReceiver->ack = pMsg->seq; - needRsp = true; - - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver stop"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { - pSyncNode->pFsm->FpSnapshotStopWrite(pSyncNode->pFsm, pReceiver->pWriter, false); - snapshotReceiverStop(pReceiver, false); + // force close + snapshotReceiverForceStop(pReceiver); needRsp = false; - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver force close"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { // transfering if (pMsg->seq == pReceiver->ack + 1) { - writeCode = - pSyncNode->pFsm->FpSnapshotDoWrite(pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); - ASSERT(writeCode == 0); - pReceiver->ack = pMsg->seq; + snapshotReceiverGotData(pReceiver, pMsg); } needRsp = true; + } else { + // error log do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver receiving"); - syncNodeEventLog(pSyncNode, eventLog); + char logBuf[96]; + snprintf(logBuf, sizeof(logBuf), "snapshot receiver recv error seq:%d, my ack:%d", pMsg->seq, pReceiver->ack); + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, logBuf); + syncNodeErrorLog(pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); - } else { - ASSERT(0); + return -1; } + // send ack if (needRsp) { + // build msg SyncSnapshotRsp *pRspMsg = syncSnapshotRspBuild(pSyncNode->vgId); pRspMsg->srcId = pSyncNode->myRaftId; pRspMsg->destId = pMsg->srcId; pRspMsg->term = pSyncNode->pRaftStore->currentTerm; pRspMsg->lastIndex = pMsg->lastIndex; pRspMsg->lastTerm = pMsg->lastTerm; - pRspMsg->ack = pReceiver->ack; - pRspMsg->code = writeCode; - pRspMsg->privateTerm = pReceiver->privateTerm; + pRspMsg->ack = pReceiver->ack; // receiver maybe already closed + pRspMsg->code = 0; + pRspMsg->privateTerm = pReceiver->privateTerm; // receiver maybe already closed + // send msg SRpcMsg rpcMsg; syncSnapshotRsp2RpcMsg(pRspMsg, &rpcMsg); syncNodeSendMsgById(&(pRspMsg->destId), pSyncNode, &rpcMsg); - syncSnapshotRspDestroy(pRspMsg); } + } else { + // error log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver term not equal"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } else { - syncNodeLog2("syncNodeOnSnapshotSendCb not follower", pSyncNode); + // error log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver not follower"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } return 0; } +static void snapshotSenderUpdateProgress(SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { + ASSERT(pMsg->ack == pSender->seq); + pSender->ack = pMsg->ack; + ++(pSender->seq); +} + // sender receives ack, set seq = ack + 1, send msg from seq // if ack == SYNC_SNAPSHOT_SEQ_END, stop sender int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { // if already drop replica, do not process if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId)) && pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - sInfo("recv SyncSnapshotRsp maybe replica already dropped"); - return 0; + sError("vgId:%d, recv sync-snapshot-rsp, maybe replica already dropped", pSyncNode->vgId); + return -1; } // get sender @@ -655,27 +758,49 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { // receiver ack is finish, close sender if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { - pSender->finish = true; - snapshotSenderStop(pSender); + snapshotSenderStop(pSender, true); return 0; } // send next msg if (pMsg->ack == pSender->seq) { // update sender ack - pSender->ack = pMsg->ack; - (pSender->seq)++; + snapshotSenderUpdateProgress(pSender, pMsg); snapshotSend(pSender); } else if (pMsg->ack == pSender->seq - 1) { snapshotReSend(pSender); } else { - ASSERT(0); + do { + char logBuf[96]; + snprintf(logBuf, sizeof(logBuf), "snapshot sender recv error ack:%d, my seq:%d", pMsg->ack, pSender->seq); + char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } + } else { + // error log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender term not equal"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } } else { - syncNodeLog2("syncNodeOnSnapshotRspCb not leader", pSyncNode); + // error log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender not leader"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } return 0; diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 27084286da..bc63462a9e 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -17,6 +17,7 @@ add_executable(syncVotesRespondTest "") add_executable(syncIndexMgrTest "") add_executable(syncLogStoreTest "") add_executable(syncEntryTest "") +add_executable(syncEntryCacheTest "") add_executable(syncRequestVoteTest "") add_executable(syncRequestVoteReplyTest "") add_executable(syncAppendEntriesTest "") @@ -129,6 +130,10 @@ target_sources(syncEntryTest PRIVATE "syncEntryTest.cpp" ) +target_sources(syncEntryCacheTest + PRIVATE + "syncEntryCacheTest.cpp" +) target_sources(syncRequestVoteTest PRIVATE "syncRequestVoteTest.cpp" @@ -362,6 +367,11 @@ target_include_directories(syncEntryTest "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncEntryCacheTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_include_directories(syncRequestVoteTest PUBLIC "${TD_SOURCE_DIR}/include/libs/sync" @@ -610,6 +620,10 @@ target_link_libraries(syncEntryTest sync gtest_main ) +target_link_libraries(syncEntryCacheTest + sync + gtest_main +) target_link_libraries(syncRequestVoteTest sync gtest_main diff --git a/source/libs/sync/test/syncEntryCacheTest.cpp b/source/libs/sync/test/syncEntryCacheTest.cpp new file mode 100644 index 0000000000..787c08e507 --- /dev/null +++ b/source/libs/sync/test/syncEntryCacheTest.cpp @@ -0,0 +1,162 @@ +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +SSyncRaftEntry* createEntry(int i) { + int32_t dataLen = 20; + SSyncRaftEntry* pEntry = syncEntryBuild(dataLen); + assert(pEntry != NULL); + pEntry->msgType = 88; + pEntry->originalRpcType = 99; + pEntry->seqNum = 3; + pEntry->isWeak = true; + pEntry->term = 100 + i; + pEntry->index = i; + snprintf(pEntry->data, dataLen, "value%d", i); + + return pEntry; +} + +SSyncNode* createFakeNode() { + SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode)); + ASSERT(pSyncNode != NULL); + memset(pSyncNode, 0, sizeof(SSyncNode)); + + return pSyncNode; +} + +SRaftEntryCache* createCache(int maxCount) { + SSyncNode* pSyncNode = createFakeNode(); + ASSERT(pSyncNode != NULL); + + SRaftEntryCache* pCache = raftCacheCreate(pSyncNode, maxCount); + ASSERT(pCache != NULL); + + return pCache; +} + +void test1() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test1 write 5 entries==", pCache); + + SyncIndex index; + index = 1; + code = raftCacheDelEntry(pCache, index); + ASSERT(code == 0); + index = 3; + code = raftCacheDelEntry(pCache, index); + ASSERT(code == 0); + raftCacheLog2((char*)"==test1 delete 1,3==", pCache); + + code = raftCacheClear(pCache); + ASSERT(code == 0); + raftCacheLog2((char*)"==clear all==", pCache); +} + +void test2() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test2 write 5 entries==", pCache); + + SyncIndex index; + index = 1; + SSyncRaftEntry* pEntry; + code = raftCacheGetEntry(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryDestory(pEntry); + syncEntryLog2((char*)"==test2 get entry 1==", pEntry); + + index = 2; + code = raftCacheGetEntryP(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryLog2((char*)"==test2 get entry pointer 2==", pEntry); + + // not found + index = 8; + code = raftCacheGetEntry(pCache, index, &pEntry); + ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); + sTrace("==test2 get entry 8 not found=="); + + // not found + index = 9; + code = raftCacheGetEntryP(pCache, index, &pEntry); + ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); + sTrace("==test2 get entry pointer 9 not found=="); +} + +void test3() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + for (int i = 6; i < 10; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 0); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test3 write 10 entries, max count is 5==", pCache); +} + +void test4() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test4 write 5 entries==", pCache); + + SyncIndex index; + index = 3; + SSyncRaftEntry* pEntry; + code = raftCacheGetAndDel(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryLog2((char*)"==test4 get-and-del entry 3==", pEntry); + raftCacheLog2((char*)"==test4 after get-and-del entry 3==", pCache); +} + +int main(int argc, char** argv) { + gRaftDetailLog = true; + tsAsyncLog = 0; + sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG; + + test1(); + test2(); + test3(); + test4(); + + return 0; +} diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 963a85922f..55db0b129a 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -229,7 +229,7 @@ typedef struct { SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, int sz, void* arg, AsyncCB cb); void transDestroyAsyncPool(SAsyncPool* pool); -int transSendAsync(SAsyncPool* pool, queue* mq); +int transAsyncSend(SAsyncPool* pool, queue* mq); #define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc) \ do { \ diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index c328629c4b..462debb247 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -52,7 +52,7 @@ typedef struct { char user[TSDB_UNI_LEN]; // meter ID void (*cfp)(void* parent, SRpcMsg*, SEpSet*); - bool (*retry)(int32_t code); + bool (*retry)(int32_t code, tmsg_t msgType); int index; void* parent; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 4f7b19b539..cc2e95cfb3 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -164,11 +164,6 @@ void rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) { transSetDefaultAddr(thandle, ip, fqdn); } -// void rpcSetMsgTraceId(SRpcMsg* pMsg, STraceId uid) { -// SRpcHandleInfo* pInfo = &pMsg->info; -// pInfo->traceId = uid; -//} - int32_t rpcInit() { // impl later return 0; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 7374d1fffc..aba2e6957b 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -967,7 +967,7 @@ void cliSendQuit(SCliThrd* thrd) { // cli can stop gracefully SCliMsg* msg = taosMemoryCalloc(1, sizeof(SCliMsg)); msg->type = Quit; - transSendAsync(thrd->asyncPool, &msg->q); + transAsyncSend(thrd->asyncPool, &msg->q); } void cliWalkCb(uv_handle_t* handle, void* arg) { if (!uv_is_closing(handle)) { @@ -1030,7 +1030,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { */ STransConnCtx* pCtx = pMsg->ctx; int32_t code = pResp->code; - if (pTransInst->retry != NULL && pTransInst->retry(code)) { + if (pTransInst->retry != NULL && pTransInst->retry(code, pResp->msgType - 1)) { pMsg->sent = 0; pCtx->retryCnt += 1; if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { @@ -1138,7 +1138,7 @@ void transReleaseCliHandle(void* handle) { cmsg->msg = tmsg; cmsg->type = Release; - transSendAsync(pThrd->asyncPool, &cmsg->q); + transAsyncSend(pThrd->asyncPool, &cmsg->q); return; } @@ -1171,7 +1171,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra STraceId* trace = &pReq->info.traceId; tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - ASSERT(transSendAsync(pThrd->asyncPool, &(cliMsg->q)) == 0); + ASSERT(transAsyncSend(pThrd->asyncPool, &(cliMsg->q)) == 0); return; } @@ -1205,7 +1205,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - transSendAsync(pThrd->asyncPool, &(cliMsg->q)); + transAsyncSend(pThrd->asyncPool, &(cliMsg->q)); tsem_wait(sem); tsem_destroy(sem); taosMemoryFree(sem); @@ -1234,7 +1234,7 @@ void transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { SCliThrd* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; tDebug("%s update epset at thread:%08" PRId64 "", pTransInst->label, thrd->pid); - transSendAsync(thrd->asyncPool, &(cliMsg->q)); + transAsyncSend(thrd->asyncPool, &(cliMsg->q)); } } #endif diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index bff7d79bd3..fbe0951a46 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -202,7 +202,7 @@ void transDestroyAsyncPool(SAsyncPool* pool) { taosMemoryFree(pool->asyncs); taosMemoryFree(pool); } -int transSendAsync(SAsyncPool* pool, queue* q) { +int transAsyncSend(SAsyncPool* pool, queue* q) { int idx = pool->index; idx = idx % pool->nAsync; // no need mutex here diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 892d32696e..08363b3c7c 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -999,7 +999,7 @@ void sendQuitToWorkThrd(SWorkThrd* pThrd) { SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); msg->type = Quit; tDebug("server send quit msg to work thread"); - transSendAsync(pThrd->asyncPool, &msg->q); + transAsyncSend(pThrd->asyncPool, &msg->q); } void transCloseServer(void* arg) { @@ -1070,7 +1070,7 @@ void transReleaseSrvHandle(void* handle) { m->type = Release; tTrace("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; _return1: @@ -1099,7 +1099,7 @@ void transSendResponse(const STransMsg* msg) { STraceId* trace = (STraceId*)&msg->info.traceId; tGTrace("conn %p start to send resp (1/2)", exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; _return1: @@ -1128,7 +1128,7 @@ void transRegisterMsg(const STransMsg* msg) { m->type = Register; tTrace("%s conn %p start to register brokenlink callback", transLabel(pThrd->pTransInst), exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index ba07b6c3dd..9c66ac1df8 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,6 +18,10 @@ #include "os.h" #if defined(WINDOWS) +BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { + printf("\n" TAOS_CONSOLE_PROMPT_HEADER); + return TRUE; +} #elif defined(_TD_DARWIN_64) #else #include @@ -124,7 +128,7 @@ int taosSetConsoleEcho(bool on) { void taosSetTerminalMode() { #if defined(WINDOWS) - // assert(0); + SetConsoleCtrlHandler(CtrlHandler, TRUE); #else struct termios newtio; @@ -158,7 +162,6 @@ void taosSetTerminalMode() { int32_t taosGetOldTerminalMode() { #if defined(WINDOWS) - // assert(0); #else /* Make sure stdin is a terminal. */ if (!isatty(STDIN_FILENO)) { @@ -176,7 +179,7 @@ int32_t taosGetOldTerminalMode() { void taosResetTerminalMode() { #if defined(WINDOWS) - // assert(0); + SetConsoleCtrlHandler(CtrlHandler, FALSE); #else if (tcsetattr(0, TCSANOW, &oldtio) != 0) { fprintf(stderr, "Fail to reset the terminal properties!\n"); diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index 3f23cd8b5f..f80c2b217f 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -52,7 +52,7 @@ fi docker run \ -v $REP_MOUNT_PARAM \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_TOOLS=true;make -j $THREAD_COUNT" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true;make -j $THREAD_COUNT" ret=$? exit $ret diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index ca0c66a9d4..6caf5624a4 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -642,5 +642,13 @@ class TDCom: column_value_str = ", ".join(str(v) for v in column_value_list) insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});' tsql.execute(insert_sql) - + def getOneRow(self, location, containElm): + res_list = list() + if 0 <= location < tdSql.queryRows: + for row in tdSql.queryResult: + if row[location] == containElm: + res_list.append(row) + return res_list + else: + tdLog.exit(f"getOneRow out of range: row_index={location} row_count={self.query_row}") tdCom = TDCom() diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index e5095c74dc..807398f70f 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -1,5 +1,76 @@ # -*- coding: utf-8 -*- +# basic type +TAOS_DATA_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", + "FLOAT", "DOUBLE", + "BOOL", + "BINARY", "NCHAR", "VARCHAR", + "TIMESTAMP", + # "MEDIUMBLOB", "BLOB", # add in 3.x + # "DECIMAL", "NUMERIC", # add in 3.x + "JSON", # only for tag +] + +TAOS_NUM_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", "FLOAT", "DOUBLE", + # "DECIMAL", "NUMERIC", # add in 3.x +] +TAOS_CHAR_TYPE = [ + "BINARY", "NCHAR", "VARCHAR", +] +TAOS_BOOL_TYPE = ["BOOL",] +TAOS_TS_TYPE = ["TIMESTAMP",] +TAOS_BIN_TYPE = [ + "MEDIUMBLOB", "BLOB", # add in 3.x +] + +TAOS_TIME_INIT = ["b", "u", "a", "s", "m", "h", "d", "w", "n", "y"] +TAOS_PRECISION = ["ms", "us", "ns"] +PRECISION_DEFAULT = "ms" +PRECISION = PRECISION_DEFAULT + +TAOS_KEYWORDS = [ + "ABORT", "CREATE", "IGNORE", "NULL", "STAR", + "ACCOUNT", "CTIME", "IMMEDIATE", "OF", "STATE", + "ACCOUNTS", "DATABASE", "IMPORT", "OFFSET", "STATEMENT", + "ADD", "DATABASES", "IN", "OR", "STATE_WINDOW", + "AFTER", "DAYS", "INITIALLY", "ORDER", "STORAGE", + "ALL", "DBS", "INSERT", "PARTITIONS", "STREAM", + "ALTER", "DEFERRED", "INSTEAD", "PASS", "STREAMS", + "AND", "DELIMITERS", "INT", "PLUS", "STRING", + "AS", "DESC", "INTEGER", "PPS", "SYNCDB", + "ASC", "DESCRIBE", "INTERVAL", "PRECISION", "TABLE", + "ATTACH", "DETACH", "INTO", "PREV", "TABLES", + "BEFORE", "DISTINCT", "IS", "PRIVILEGE", "TAG", + "BEGIN", "DIVIDE", "ISNULL", "QTIME", "TAGS", + "BETWEEN", "DNODE", "JOIN", "QUERIES", "TBNAME", + "BIGINT", "DNODES", "KEEP", "QUERY", "TIMES", + "BINARY", "DOT", "KEY", "QUORUM", "TIMESTAMP", + "BITAND", "DOUBLE", "KILL", "RAISE", "TINYINT", + "BITNOT", "DROP", "LE", "REM", "TOPIC", + "BITOR", "EACH", "LIKE", "REPLACE", "TOPICS", + "BLOCKS", "END", "LIMIT", "REPLICA", "TRIGGER", + "BOOL", "EQ", "LINEAR", "RESET", "TSERIES", + "BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS", + "CACHE", "EXPLAIN", "LP", "ROW", "UNION", + "CACHELAST", "FAIL", "LSHIFT", "RP", "UNSIGNED", + "CASCADE", "FILE", "LT", "RSHIFT", "UPDATE", + "CHANGE", "FILL", "MATCH", "SCORES", "UPLUS", + "CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE", + "COLON", "FOR", "MINROWS", "SEMI", "USER", + "COLUMN", "FROM", "MINUS", "SESSION", "USERS", + "COMMA", "FSYNC", "MNODES", "SET", "USING", + "COMP", "GE", "MODIFY", "SHOW", "VALUES", + "COMPACT", "GLOB", "MODULES", "SLASH", "VARIABLE", + "CONCAT", "GRANTS", "NCHAR", "SLIDING", "VARIABLES", + "CONFLICT", "GROUP", "NE", "SLIMIT", "VGROUPS", + "CONNECTION", "GT", "NONE", "SMALLINT", "VIEW", + "CONNECTIONS", "HAVING", "NOT", "SOFFSET", "VNODES", + "CONNS", "ID", "NOTNULL", "STABLE", "WAL", + "COPY", "IF", "NOW", "STABLES", "WHERE", +] + # basic data type boundary TINYINT_MAX = 127 TINYINT_MIN = -128 @@ -11,7 +82,7 @@ SMALLINT_MAX = 32767 SMALLINT_MIN = -32768 SMALLINT_UN_MAX = 65535 -MALLINT_UN_MIN = 0 +SMALLINT_UN_MIN = 0 INT_MAX = 2147483647 INT_MIN = -2147483648 @@ -33,8 +104,8 @@ DOUBLE_MIN = -1.7E+308 # schema boundary BINARY_LENGTH_MAX = 16374 -NCAHR_LENGTH_MAX_ = 4093 -DBNAME_LENGTH_MAX_ = 64 +NCAHR_LENGTH_MAX = 4093 +DBNAME_LENGTH_MAX = 64 STBNAME_LENGTH_MAX = 192 STBNAME_LENGTH_MIN = 1 @@ -66,4 +137,32 @@ MNODE_SHM_SIZE_DEFAULT = 6292480 VNODE_SHM_SIZE_MAX = 2147483647 VNODE_SHM_SIZE_MIN = 6292480 -VNODE_SHM_SIZE_DEFAULT = 31458304 \ No newline at end of file +VNODE_SHM_SIZE_DEFAULT = 31458304 + +# time_init +TIME_MS = 1 +TIME_US = TIME_MS/1000 +TIME_NS = TIME_US/1000 + +TIME_S = 1000 * TIME_MS +TIME_M = 60 * TIME_S +TIME_H = 60 * TIME_M +TIME_D = 24 * TIME_H +TIME_W = 7 * TIME_D +TIME_N = 30 * TIME_D +TIME_Y = 365 * TIME_D + + +# session parameters +INTERVAL_MIN = 1 * TIME_MS if PRECISION == PRECISION_DEFAULT else 1 * TIME_US + + +# streams and related agg-function +SMA_INDEX_FUNCTIONS = ["MIN", "MAX"] +ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"] +SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] +WATERMARK_MAX = 900000 +WATERMARK_MIN = 0 + +MAX_DELAY_MAX = 900000 +MAX_DELAY_MIN = 1 \ No newline at end of file diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 580fc8ee47..fe802dd9a3 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -21,6 +21,7 @@ import psutil import shutil import pandas as pd from util.log import * +from util.constant import * def _parse_datetime(timestr): try: @@ -117,8 +118,7 @@ class TDSql: col_name_list = [] col_type_list = [] self.cursor.execute(sql) - self.queryCols = self.cursor.description - for query_col in self.queryCols: + for query_col in self.cursor.description: col_name_list.append(query_col[0]) col_type_list.append(query_col[1]) except Exception as e: @@ -301,6 +301,41 @@ class TDSql: args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) + def get_times(self, time_str, precision="ms"): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + if time_str[-1] not in TAOS_TIME_INIT: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {time_str} not a standard taos time init") + if precision not in TAOS_PRECISION: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {precision} not a standard taos time precision") + + if time_str[-1] == TAOS_TIME_INIT[0]: + times = int(time_str[:-1]) * TIME_NS + if time_str[-1] == TAOS_TIME_INIT[1]: + times = int(time_str[:-1]) * TIME_US + if time_str[-1] == TAOS_TIME_INIT[2]: + times = int(time_str[:-1]) * TIME_MS + if time_str[-1] == TAOS_TIME_INIT[3]: + times = int(time_str[:-1]) * TIME_S + if time_str[-1] == TAOS_TIME_INIT[4]: + times = int(time_str[:-1]) * TIME_M + if time_str[-1] == TAOS_TIME_INIT[5]: + times = int(time_str[:-1]) * TIME_H + if time_str[-1] == TAOS_TIME_INIT[6]: + times = int(time_str[:-1]) * TIME_D + if time_str[-1] == TAOS_TIME_INIT[7]: + times = int(time_str[:-1]) * TIME_W + if time_str[-1] == TAOS_TIME_INIT[8]: + times = int(time_str[:-1]) * TIME_N + if time_str[-1] == TAOS_TIME_INIT[9]: + times = int(time_str[:-1]) * TIME_Y + + if precision == "ms": + return int(times) + elif precision == "us": + return int(times*1000) + elif precision == "ns": + return int(times*1000*1000) + def taosdStatus(self, state): tdLog.sleep(5) pstate = 0 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1b61bd1890..90bc4ab7c0 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -11,7 +11,7 @@ ./test.sh -f tsim/db/create_all_options.sim ./test.sh -f tsim/db/alter_option.sim ./test.sh -f tsim/db/alter_replica_13.sim -#./test.sh -f tsim/db/alter_replica_31.sim +./test.sh -f tsim/db/alter_replica_31.sim ./test.sh -f tsim/db/basic1.sim ./test.sh -f tsim/db/basic2.sim ./test.sh -f tsim/db/basic3.sim @@ -22,15 +22,25 @@ # ---- dnode ./test.sh -f tsim/dnode/balance_replica1.sim +./test.sh -f tsim/dnode/balance_replica3.sim +./test.sh -f tsim/dnode/balance1.sim +./test.sh -f tsim/dnode/balance2.sim +./test.sh -f tsim/dnode/balance3.sim +./test.sh -f tsim/dnode/balancex.sim ./test.sh -f tsim/dnode/create_dnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim ./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica1.sim -#./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim -#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim -#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim -#./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim +./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim +./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +./test.sh -f tsim/dnode/offline_reason.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim +./test.sh -f tsim/dnode/vnode_clean.sim # ---- insert ./test.sh -f tsim/insert/basic0.sim @@ -81,6 +91,7 @@ ./test.sh -f tsim/stream/basic1.sim ./test.sh -f tsim/stream/basic2.sim ./test.sh -f tsim/stream/distributeInterval0.sim +# ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim # ./test.sh -f tsim/stream/distributesession0.sim # ./test.sh -f tsim/stream/session0.sim ./test.sh -f tsim/stream/session1.sim @@ -151,6 +162,13 @@ # --- valgrind ./test.sh -f tsim/valgrind/checkError.sim -v +# --- vnode +#./test.sh -f tsim/vnode/replica3_basic.sim +#./test.sh -f tsim/vnode/replica3_repeat.sim +./test.sh -f tsim/vnode/replica3_vgroup.sim +#./test.sh -f tsim/vnode/replica3_many.sim +#./test.sh -f tsim/vnode/replica3_import.sim + # --- sync ./test.sh -f tsim/sync/3Replica1VgElect.sim ./test.sh -f tsim/sync/3Replica5VgElect.sim diff --git a/tests/script/sh/move_dnode.sh b/tests/script/sh/move_dnode.sh deleted file mode 100755 index d3650c18ad..0000000000 --- a/tests/script/sh/move_dnode.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -echo "Executing move_dnode.sh" - -UNAME_BIN=`which uname` -OS_TYPE=`$UNAME_BIN` - -SCRIPT_DIR=`dirname $0` -cd $SCRIPT_DIR/../ -SCRIPT_DIR=`pwd` -echo "SCRIPT_DIR: $SCRIPT_DIR" - -IN_TDINTERNAL="community" -if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then - cd ../../.. -else - cd ../../ -fi - -TAOS_DIR=`pwd` -TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` - -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi - -if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` -else - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` -fi - -BUILD_DIR=$TAOS_DIR/$BIN_DIR/build - -SIM_DIR=$TAOS_DIR/sim - -NODE_DIR=$SIM_DIR/$NODE_NAME - -if [ -d "$SIM_DIR/$2" ];then - rm -rf $SIM_DIR/$2 -fi -mv $SIM_DIR/$1 $SIM_DIR/$2 - -if [[ $2 =~ "dnode2" ]];then - sed -i 's/serverPort 7100/serverPort 7200/g' $SIM_DIR/$2/cfg/taos.cfg - sed -i 's/dnode1/dnode2/g' $SIM_DIR/$2/cfg/taos.cfg - sed -i 's/7100/7200/g' $SIM_DIR/$2/data/dnode/dnodeEps.json -elif [[ $2 =~ "dnode4" ]];then - sed -i 's/serverPort 7100/serverPort 7400/g' $SIM_DIR/$2/cfg/taos.cfg - sed -i 's/dnode1/dnode4/g' $SIM_DIR/$2/cfg/taos.cfg - sed -i 's/7100/7400/g' $SIM_DIR/dnode2/data/dnode/dnodeEps.json - sed -i 's/7100/7400/g' $SIM_DIR/dnode3/data/dnode/dnodeEps.json - sed -i 's/7100/7400/g' $SIM_DIR/$2/data/dnode/dnodeEps.json -fi diff --git a/tests/script/test-all.bat b/tests/script/test-all.bat index 7a1a4bc7fa..1c698449c6 100644 --- a/tests/script/test-all.bat +++ b/tests/script/test-all.bat @@ -11,14 +11,17 @@ if not "%2" == "" ( ) for /F "usebackq tokens=*" %%i in (!caseFile!) do ( set line=%%i - if "!line:~,9!" == "./test.sh" ( - set /a a+=1 - echo !a! Processing %%i - call :GetTimeSeconds !time! - set time1=!_timeTemp! - echo Start at !time! - call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt - if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + call :CheckSkipCase %%i + if !skipCase! == false ( + if "!line:~,9!" == "./test.sh" ( + set /a a+=1 + echo !a! Processing %%i + call :GetTimeSeconds !time! + set time1=!_timeTemp! + echo Start at !time! + call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt || set /a errorlevel=8 + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + ) ) ) exit !exitNum! @@ -56,3 +59,10 @@ for %%a in (%tt%) do ( ) set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% goto :eof + +:CheckSkipCase +set skipCase=false +if "%*" == "./test.sh -f tsim/query/scalarFunction.sim" ( set skipCase=true ) +if "%*" == "./test.sh -f tsim/stream/distributeInterval0.sim" ( set skipCase=true ) +if "%*" == "./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim" ( set skipCase=true ) +:goto eof \ No newline at end of file diff --git a/tests/script/tsim/db/alter_replica_31.sim b/tests/script/tsim/db/alter_replica_31.sim index cbd4183b5e..e9a295820c 100644 --- a/tests/script/tsim/db/alter_replica_31.sim +++ b/tests/script/tsim/db/alter_replica_31.sim @@ -89,13 +89,13 @@ step2: endi sql show db.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 -if $data(2)[3] != 4 then +if $data(2)[3] != 2 then return -1 endi if $data(2)[5] != 3 then return -1 endi -if $data(2)[7] != 2 then +if $data(2)[7] != 4 then return -1 endi if $data(2)[4] == leader then @@ -118,7 +118,7 @@ sql insert into db.ctb values(now, 1, "2") sql show db.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 -sleep 1000 +sleep 100 sql select * from db.ctb print ===> $data00 $data01 $data02 $data03 $data04 $data05 @@ -126,10 +126,9 @@ if $rows != 1 then return -1 endi -sleep 3000 - print ============= step3: alter database sql alter database db replica 1 +$hasleader = 0 $x = 0 step3: @@ -144,18 +143,20 @@ print ===> rows: $rows if $rows != 1 then goto step3 endi -if $data(2)[3] != 4 then - goto step3 +if $data(2)[4] == leader then + $hasleader = 1 endi -if $data(2)[5] != NULL then - goto step3 +if $data(2)[6] == leader then + $hasleader = 1 endi -if $data(2)[7] != NULL then +if $data(2)[8] == leader then + $hasleader = 1 +endi +if $hasleader != 1 then goto step3 endi print ============= step5: stop dnode 2 -return sql select * from db.stb if $rows != 1 then return -1 diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/tsim/dnode/balance1.sim similarity index 55% rename from tests/script/unique/dnode/balance1.sim rename to tests/script/tsim/dnode/balance1.sim index 8743204a03..6471529a1e 100644 --- a/tests/script/unique/dnode/balance1.sim +++ b/tests/script/tsim/dnode/balance1.sim @@ -1,40 +1,18 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -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 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 maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode4 -c supportVnodes -v 4 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sql create database d1 +sql create database d1 vgroups 1 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) @@ -43,35 +21,49 @@ sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+5s, 11) sql show dnodes -print dnode1 openVnodes $data2_1 -if $data2_1 != 1 then +print dnode1 openVnodes $data(1)[2] +if $data(1)[2] != 1 then return -1 endi print ========== step2 -sql create dnode $hostname2 +sql create dnode $hostname port 7200 system sh/exec.sh -n dnode2 -s start $x = 0 -show2: +step2: $x = $x + 1 sleep 1000 - if $x == 20 then + if $x == 10 then + print ====> dnode not ready! return -1 endi - sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then - goto show2 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 endi -if $data2_2 != 1 then - goto show2 +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(2)[2] != 1 then + return -1 endi print ========== step3 -sql create database d2 +sql create database d2 vgroups 1 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) @@ -80,69 +72,67 @@ sql insert into d2.t2 values(now+4s, 22) sql insert into d2.t2 values(now+5s, 21) sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 0 then return -1 endi -if $data2_2 != 2 then +if $data(2)[2] != 2 then return -1 endi print ========== step4 -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - +sql drop dnode 2 sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 2 then - goto show4 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 2 then + return -1 endi -if $data2_2 != null then - goto show4 -endi -if $rows != 1 then - goto show4 +if $data(2)[2] != null then + return -1 endi system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step5 -sql create dnode $hostname3 +sql create dnode $hostname port 7300 system sh/exec.sh -n dnode3 -s start $x = 0 -show5: +step5: $x = $x + 1 sleep 1000 - if $x == 30 then + if $x == 10 then + print ====> dnode not ready! return -1 endi - sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 0 then - goto show5 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 endi -if $data2_2 != null then - goto show5 +if $data(1)[4] != ready then + goto step5 endi -if $data2_3 != 2 then - goto show5 +if $data(3)[4] != ready then + goto step5 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(3)[2] != 1 then + return -1 endi print ========== step6 -sql create database d3 +sql create database d3 vgroups 1 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) @@ -151,52 +141,46 @@ sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+5s, 31) sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 - -if $data2_1 != 0 then +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 1 then return -1 endi -if $data2_2 != null then - return -1 -endi -if $data2_3 != 3 then +if $data(3)[2] != 2 then return -1 endi print ========== step7 -sql create dnode $hostname4 +sql create dnode $hostname port 7400 system sh/exec.sh -n dnode4 -s start $x = 0 -show7: +step7: $x = $x + 1 sleep 1000 - if $x == 20 then - return -1 + if $x == 10 then + print ====> dnode not ready! + return -1 endi - sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show7 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $rows != 3 then + return -1 endi -if $data2_2 != null then - goto show7 +if $data(1)[4] != ready then + goto step7 endi -if $data2_3 != 2 then - goto show7 +if $data(3)[4] != ready then + goto step7 endi -if $data2_4 != 1 then - goto show7 +if $data(4)[4] != ready then + goto step7 endi print ========== step8 -sql create database d4 +sql create database d4 vgroups 1 sql create table d4.t4 (t timestamp, i int) sql insert into d4.t4 values(now+1s, 45) sql insert into d4.t4 values(now+2s, 44) @@ -205,56 +189,32 @@ sql insert into d4.t4 values(now+4s, 42) sql insert into d4.t4 values(now+5s, 41) sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 0 then +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 1 then return -1 endi -if $data2_2 != null then +if $data(3)[2] != 2 then return -1 endi -if $data2_3 != 2 then - return -1 -endi -if $data2_4 != 2 then +if $data(4)[2] != 1 then return -1 endi print ========== step9 -sql drop dnode $hostname3 - -$x = 0 -show9: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - +sql drop dnode 3 sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 0 then - goto show9 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 2 then + return -1 endi -if $data2_2 != null then - goto show9 -endi -if $data2_3 != null then - goto show9 -endi -if $data2_4 != 4 then - goto show9 +if $data(4)[2] != 2 then + return -1 endi system sh/exec.sh -n dnode3 -s stop -x SIGINT - sql reset query cache sleep 100 diff --git a/tests/script/tsim/dnode/balance2.sim b/tests/script/tsim/dnode/balance2.sim new file mode 100644 index 0000000000..5da9a659f3 --- /dev/null +++ b/tests/script/tsim/dnode/balance2.sim @@ -0,0 +1,280 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode4 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode5 -c supportVnodes -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi + +print ========== step2 +sql create database d1 replica 3 vgroups 1 +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 create database d2 replica 3 vgroups 1 +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 create database d3 replica 3 vgroups 1 +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 create database d4 replica 3 vgroups 1 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +print ========== step2.1 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode3 openVnodes $data(3)[2] +if $data(1)[2] != 4 then + return -1 +endi +if $data(2)[2] != 4 then + return -1 +endi +if $data(3)[2] != 4 then + return -1 +endi + +print ========== step3 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step3 +endi +if $data(2)[4] != ready then + goto step3 +endi +if $data(3)[4] != ready then + goto step3 +endi +if $data(4)[4] != ready then + goto step3 +endi +if $data(5)[4] != ready then + goto step3 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(2)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +if $data(1)[2] != 2 then + return -1 +endi +if $data(2)[2] != 3 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi +if $data(5)[2] != 2 then + return -1 +endi + +print ========== step4 +sql drop dnode 2 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +if $data(1)[2] != 2 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +if $data(4)[2] != 4 then + return -1 +endi +if $data(5)[2] != 3 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql drop dnode 3 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +if $data(1)[2] != 4 then + return -1 +endi +if $data(3)[2] != null then + return -1 +endi +if $data(4)[2] != 4 then + return -1 +endi +if $data(5)[2] != 4 then + return -1 +endi + +sql reset query cache +sleep 100 +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/balance3.sim b/tests/script/tsim/dnode/balance3.sim new file mode 100644 index 0000000000..f26c0eaa21 --- /dev/null +++ b/tests/script/tsim/dnode/balance3.sim @@ -0,0 +1,394 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode4 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode5 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode6 -c supportVnodes -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step10 +endi +if $data(2)[4] != ready then + goto step10 +endi +if $data(3)[4] != ready then + goto step10 +endi +if $data(4)[4] != ready then + goto step10 +endi + +sql create database d1 replica 3 vgroups 1 +$x = 0 +step11: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step11 +endi + +sql create database d2 replica 3 vgroups 1 +$x = 0 +step12: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> d2 not ready! + return -1 + endi +sql show d2.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $rows != 1 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step12 +endi + +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 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 show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(2)[2] != 2 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi + +print ========== step2 +sql drop dnode 2 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +if $data(1)[2] != 2 then + return -1 +endi +if $data(2)[2] != null then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step3 +sql create dnode $hostname port 7500 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step3 +endi +if $data(3)[4] != ready then + goto step3 +endi +if $data(4)[4] != ready then + goto step3 +endi +if $data(5)[4] != ready then + goto step3 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi +if $data(5)[2] != 1 then + return -1 +endi + +print ========== step4 +sql create database d3 replica 3 vgroups 1 +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 show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +if $data(4)[2] != 3 then + return -1 +endi +if $data(5)[2] != 2 then + return -1 +endi + +print ========== step5 +sql create dnode $hostname port 7600 +system sh/exec.sh -n dnode6 -s start + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step5 +endi +if $data(3)[4] != ready then + goto step5 +endi +if $data(4)[4] != ready then + goto step5 +endi +if $data(5)[4] != ready then + goto step5 +endi +if $data(6)[4] != ready then + goto step5 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +print dnode5 openVnodes $data(6)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi +if $data(5)[2] != 2 then + return -1 +endi +if $data(6)[2] != 2 then + return -1 +endi + +print ========== step6 +sql drop dnode 3 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode3 openVnodes $data(3)[2] +print dnode4 openVnodes $data(4)[2] +print dnode5 openVnodes $data(5)[2] +print dnode5 openVnodes $data(6)[2] +if $data(1)[2] != 2 then + return -1 +endi +if $data(3)[2] != null then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi +if $data(5)[2] != 3 then + return -1 +endi +if $data(6)[2] != 2 then + return -1 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 100 + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/balance_replica1.sim b/tests/script/tsim/dnode/balance_replica1.sim index 14f3f130fb..998d0654ab 100644 --- a/tests/script/tsim/dnode/balance_replica1.sim +++ b/tests/script/tsim/dnode/balance_replica1.sim @@ -117,7 +117,6 @@ if $rows != 6 then return -1 endi -return system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/balance_replica3.sim b/tests/script/tsim/dnode/balance_replica3.sim new file mode 100644 index 0000000000..276621cfcc --- /dev/null +++ b/tests/script/tsim/dnode/balance_replica3.sim @@ -0,0 +1,359 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 4 replica 3 + +print =============== step32 wait vgroup2 +$x = 0 +step32: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step32 +endi + +print =============== step33 wait vgroup3 +$x = 0 +step33: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step33 +endi + +print =============== step34 wait vgroup4 +$x = 0 +step34: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step34 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step35: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step35 +endi + +print =============== step36: create table +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql create table d1.c2 using st tags(1) +sql create table d1.c3 using st tags(1) +sql create table d1.c4 using st tags(1) +sql create table d1.c5 using st tags(1) +sql create table d1.c6 using st tags(1) +sql show d1.tables +if $rows != 6 then + return -1 +endi + +print =============== step4: start dnode5 +system sh/exec.sh -n dnode5 -s start +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != ready then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi +if $data(4)[4] != ready then + goto step4 +endi +if $data(5)[4] != ready then + goto step4 +endi + +print =============== step5: balance +sql balance vgroup + +print =============== step62 wait vgroup2 +$x = 0 +step62: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step62 +endi + +print =============== step63 wait vgroup3 +$x = 0 +step63: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step63 +endi + +print =============== step64 wait vgroup4 +$x = 0 +step64: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step64 +endi + +print =============== step65 wait vgroup5 +$x = 0 +step65: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step65 +endi + +print =============== step7: select data +sql show d1.tables +print rows $rows +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/tsim/dnode/balancex.sim similarity index 51% rename from tests/script/unique/dnode/remove1.sim rename to tests/script/tsim/dnode/balancex.sim index 25e0846129..124ccbebba 100644 --- a/tests/script/unique/dnode/remove1.sim +++ b/tests/script/tsim/dnode/balancex.sim @@ -1,30 +1,18 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode4 -c supportVnodes -v 4 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sql create database d1 +sql create database d1 vgroups 1 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) @@ -32,7 +20,7 @@ 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 create database d2 +sql create database d2 vgroups 1 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) @@ -41,36 +29,59 @@ sql insert into d2.t2 values(now+4s, 22) sql insert into d2.t2 values(now+5s, 21) sql show dnodes -print dnode1 openVnodes $data2_1 -if $data2_1 != 2 then +print dnode1 openVnodes $data(1)[2] +if $data(1)[2] != 2 then return -1 endi print ========== step2 -sql create dnode $hostname2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + $x = 0 -step2: +step2: $x = $x + 1 sleep 1000 if $x == 10 then + print ====> dnode not ready! return -1 endi - sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then goto step2 endi -if $data4_2 != ready then +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then goto step2 endi -sql create database d3 replica 2 +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(2)[2] != 1 then + return -1 +endi +if $data(3)[2] != 1 then + return -1 +endi + +print ========== step3 +sql create database d3 replica 3 vgroups 1 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) @@ -78,89 +89,95 @@ 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) -$x = 0 -show2: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 1 then - goto show2 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 1 then + return -1 endi -if $data2_2 != 3 then - goto show2 +if $data(2)[2] != 2 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 endi print ========== step3 - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 - -print ========== step4 -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_2 != null then - goto show4 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -print ========== step5 -sql create dnode $hostname4 +sql create dnode $hostname port 7400 system sh/exec.sh -n dnode4 -s start $x = 0 -show5: +step3: $x = $x + 1 sleep 1000 - if $x == 20 then - return -1 + if $x == 10 then + print ====> dnode not ready! + return -1 endi sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show5 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 endi -if $data2_2 != null then - goto show5 +if $data(1)[4] != ready then + goto step3 endi -if $data2_3 != 2 then - goto show5 +if $data(2)[4] != ready then + goto step3 endi -if $data2_4 != 2 then - goto show5 +if $data(3)[4] != ready then + goto step3 endi +if $data(4)[4] != ready then + goto step3 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(2)[2] != 2 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 1 then + return -1 +endi + +print ========== step5 +sql drop dnode 2 +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(2)[2] != null then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql reset query cache +sleep 100 print ========== step6 sql select * from d1.t1 order by t desc @@ -224,4 +241,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT system sh/exec.sh -n dnode6 -s stop -x SIGINT system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim index 35a2466297..e1b7c4a3a4 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim @@ -28,7 +28,7 @@ step1: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -49,6 +49,128 @@ endi print =============== step3 create database sql create database d1 vgroups 4 replica 3 + +print =============== step32 wait vgroup2 +$x = 0 +step32: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step32 +endi + +print =============== step33 wait vgroup3 +$x = 0 +step33: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step33 +endi + +print =============== step34 wait vgroup4 +$x = 0 +step34: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step34 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step35: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step35 +endi + +print =============== step36: create table sql use d1 sql create table d1.st (ts timestamp, i int) tags (j int) sql create table d1.c1 using st tags(1) @@ -57,21 +179,6 @@ if $rows != 1 then return -1 endi -sql show d1.vgroups -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -if $rows != 1 then - return -1 -endi -if $data(2)[3] != 2 then - return -1 -endi -if $data(2)[5] != 3 then - return -1 -endi -if $data(2)[7] != 4 then - return -1 -endi - print =============== step4: drop dnode 2 system sh/exec.sh -n dnode5 -s start $x = 0 @@ -85,7 +192,7 @@ step4: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -115,21 +222,133 @@ if $rows != 4 then return -1 endi -print show d1.vgroups +print =============== step62 wait vgroup2 +$x = 0 +step62: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi sql show d1.vgroups -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -if $rows != 1 then +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then return -1 endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step62 +endi +print =============== step63 wait vgroup3 +$x = 0 +step63: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step63 +endi -print =============== step6: select data +print =============== step64 wait vgroup4 +$x = 0 +step64: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step64 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step65: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step65 +endi + +print =============== step7: select data +print ===> $data00 $data01 sql show d1.tables if $rows != 1 then return -1 endi -return system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim index 3ea351f7a7..4855f4dccf 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim @@ -49,6 +49,50 @@ endi print =============== step3 create database sql create database d1 vgroups 1 replica 3 +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + sql use d1 sql create table d1.st (ts timestamp, i int) tags (j int) sql create table d1.c1 using st tags(1) @@ -72,13 +116,6 @@ if $data(2)[7] != 4 then return -1 endi -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT - - -return - - print =============== step4: drop dnode 2 system sh/exec.sh -n dnode5 -s start $x = 0 @@ -92,7 +129,7 @@ step4: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -116,8 +153,11 @@ sql drop dnode 2 print show dnodes; sql show dnodes; -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 if $rows != 4 then return -1 endi @@ -128,9 +168,9 @@ print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] if $rows != 1 then return -1 endi -#if $data(2)[3] != 3 then -# return -1 -#endi +if $data(2)[3] != 5 then + return -1 +endi print =============== step6: select data sql show d1.tables @@ -138,7 +178,37 @@ if $rows != 1 then return -1 endi -return +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step6 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/offline_reason.sim b/tests/script/tsim/dnode/offline_reason.sim new file mode 100644 index 0000000000..3c6fff8b59 --- /dev/null +++ b/tests/script/tsim/dnode/offline_reason.sim @@ -0,0 +1,161 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname port 7200 + +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode2 off: $data(2)[6] + +if $data(2)[6] != @status not received@ then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode2 off: $data(2)[6] +if $data(2)[6] != @status msg timeout@ then + goto step3 +endi + +print ========== step4 +sql drop dnode 2 +sql show dnodes +if $rows != 1 then + return -1 +endi + +print ========== step5 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname port 7200 + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode2 off: $data(3)[6] +if $data(3)[6] != @dnodeId not match@ then + goto step5 +endi + +print ========== step6 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c statusInterval -v 4 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname port 7400 + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode2 off: $data(3)[6] +print dnode3 off: $data(4)[6] +if $data(4)[6] != @interval not match@ then + goto step6 +endi + +print ========== step7 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode5 -c locale -v zn_CH.UTF-8 +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname port 7500 + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode3 off: $data(3)[6] +print dnode4 off: $data(4)[6] +print dnode5 off: $data(5)[6] +if $data(5)[6] != @locale not match@ then + goto step7 +endi + +print ========== step8 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode6 -c charset -v UTF-16 +system sh/exec.sh -n dnode6 -s start +sql create dnode $hostname port 7600 + +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data(1)[6] +print dnode3 off: $data(3)[6] +print dnode4 off: $data(4)[6] +print dnode5 off: $data(5)[6] +print dnode6 off: $data(6)[6] +if $data(6)[6] != @charset not match@ then + goto step8 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim new file mode 100644 index 0000000000..d3b5a02a23 --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim @@ -0,0 +1,178 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 1 + +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi + +print =============== step3: create database +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode 4 +sql redistribute vgroup 2 dnode 4 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: +print redistribute vgroup 2 dnode 4 +sql redistribute vgroup 2 dnode 4 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim index 9b11e16616..00c6e8a98d 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim @@ -65,7 +65,7 @@ sql_error redistribute vgroup 3 dnode 6 dnode 3 dnode 4 # vgroup not exist sql_error redistribute vgroup 3 dnode 5 dnode 3 dnode 4 # un changed -sql_error redistribute vgroup 2 dnode 2 dnode 3 dnode 4 +# sql_error redistribute vgroup 2 dnode 2 dnode 3 dnode 4 # no enought vnodes sql_error redistribute vgroup 2 dnode 1 dnode 3 dnode 4 # offline vnodes @@ -176,8 +176,6 @@ if $rows != 1 then return -1 endi -return - print =============== step32: print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim new file mode 100644 index 0000000000..6614009497 --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim @@ -0,0 +1,245 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode6 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 +sql create dnode $hostname port 7600 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 6 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 3 + +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 6 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi +if $data(5)[4] != ready then + goto step2 +endi +if $data(6)[4] != ready then + goto step2 +endi + +print =============== step3: create database +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode 6 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode 5 dnode $follower2 dnode $follower1 +sql redistribute vgroup 2 dnode 5 dnode $follower2 dnode $follower1 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode $follower2 dnode 6 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower2 dnode 6 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode $follower1 dnode 5 dnode 6 +sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: +print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 6 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode $follower1 dnode 6 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower1 dnode 6 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim new file mode 100644 index 0000000000..c78d90e352 --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim @@ -0,0 +1,263 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 +system sh/deploy.sh -n dnode8 -i 8 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode6 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode7 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode8 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 +sql create dnode $hostname port 7600 +sql create dnode $hostname port 7700 +sql create dnode $hostname port 7800 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 8 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 3 + +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +system sh/exec.sh -n dnode7 -s start +system sh/exec.sh -n dnode8 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 8 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi +if $data(5)[4] != ready then + goto step2 +endi +if $data(6)[4] != ready then + goto step2 +endi +if $data(7)[4] != ready then + goto step2 +endi +if $data(8)[4] != ready then + goto step2 +endi + +print =============== step3: create database +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode 7 dnode 5 dnode 6 +sql redistribute vgroup 2 dnode 7 dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode 7 dnode 6 dnode 8 +sql redistribute vgroup 2 dnode 7 dnode 6 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + + +return + + +print =============== step44: +print redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode +sql redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 8 +sql redistribute vgroup 2dnode $follower1 dnode $follower2 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode $leaderVnode dnode 6 dnode 5 +sql redistribute vgroup 2 dnode $leaderVnode dnode 6 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode $follower1 dnode 7 dnode 8 +sql redistribute vgroup 2 dnode $follower1 dnode 7 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/tsim/dnode/vnode_clean.sim similarity index 55% rename from tests/script/unique/dnode/vnode_clean.sim rename to tests/script/tsim/dnode/vnode_clean.sim index 76311a6cac..9fcf9451c1 100644 --- a/tests/script/unique/dnode/vnode_clean.sim +++ b/tests/script/tsim/dnode/vnode_clean.sim @@ -1,30 +1,14 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 - print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sql create database d1 +sql create database d1 vgroups 1 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) @@ -33,34 +17,49 @@ sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+5s, 11) sql show dnodes -print dnode1 openVnodes $data2_1 -if $data2_1 != 1 then +print dnode1 openVnodes $data(1)[2] +if $data(1)[2] != 1 then return -1 endi print ========== step2 -sql create dnode $hostname2 +sql create dnode $hostname port 7200 system sh/exec.sh -n dnode2 -s start $x = 0 -show2: +step2: $x = $x + 1 sleep 1000 - if $x == 20 then - return -1 + if $x == 10 then + print ====> dnode not ready! + return -1 endi sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then - goto show2 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 endi -if $data2_2 != 1 then - goto show2 +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(2)[2] != 1 then + return -1 endi print ========== step3 -sql create database d2 +sql create database d2 vgroups 1 sql create table d2.t2 (t timestamp, i int) sql insert into d2.t2 values(now+1s, 25) @@ -69,65 +68,68 @@ 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) -$x = 0 sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 0 then return -1 endi -if $data2_2 != 2 then +if $data(2)[2] != 2 then return -1 endi print ========== step4 -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi +sql drop dnode 2 sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 2 then - goto show4 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(2)[2] +if $data(1)[2] != 2 then + return -1 endi -if $data2_2 != null then - goto show4 -endi -if $rows != 1 then - goto show4 +if $data(2)[2] != null then + return -1 endi system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step5 -sql create dnode $hostname3 +sql create dnode $hostname port 7300 system sh/exec.sh -n dnode3 -s start $x = 0 -show5: +step5: $x = $x + 1 sleep 1000 - if $x == 40 then - return -1 + if $x == 10 then + print ====> dnode not ready! + return -1 endi sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode3 openVnodes $data2_3 -if $data2_1 != 0 then - goto show5 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 endi -if $data2_3 != 2 then - goto show5 +if $data(1)[4] != ready then + goto step5 +endi +if $data(3)[4] != ready then + goto step5 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 1 then + return -1 +endi +if $data(3)[2] != 1 then + return -1 endi print ========== step6 -sql create database d3 +sql create database d3 vgroups 1 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) @@ -136,43 +138,61 @@ sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+5s, 31) sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_3 -if $data2_1 != 0 then +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +if $data(1)[2] != 1 then return -1 endi -if $data2_3 != 3 then +if $data(3)[2] != 2 then return -1 endi print ========== step7 -sql create dnode $hostname4 +sql create dnode $hostname port 7400 system sh/exec.sh -n dnode4 -s start $x = 0 -show7: +step7: $x = $x + 1 sleep 1000 - if $x == 40 then + if $x == 10 then + print ====> dnode not ready! return -1 endi - sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show7 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $rows != 3 then + return -1 endi -if $data2_3 != 2 then - goto show7 +if $data(1)[4] != ready then + goto step7 endi -if $data2_4 != 1 then - goto show7 +if $data(3)[4] != ready then + goto step7 +endi +if $data(4)[4] != ready then + goto step7 +endi + +sql balance vgroup +sql show dnodes +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 0 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +if $data(4)[2] != 1 then + return -1 endi print ========== step8 -sql create database d4 +sql create database d4 vgroups 1 sql create table d4.t4 (t timestamp, i int) sql insert into d4.t4 values(now+1s, 45) sql insert into d4.t4 values(now+2s, 44) @@ -180,53 +200,39 @@ sql insert into d4.t4 values(now+3s, 43) sql insert into d4.t4 values(now+4s, 42) sql insert into d4.t4 values(now+5s, 41) -$x = 0 -show8: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show8 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 0 then + return -1 endi -if $data2_3 != 2 then - goto show8 +if $data(3)[2] != 2 then + return -1 endi -if $data2_4 != 2 then - goto show8 +if $data(4)[2] != 2 then + return -1 endi print ========== step9 -sql drop dnode $hostname3 - -$x = 0 -show9: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - +sql drop dnode 3 sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show9 +print dnode1 openVnodes $data(1)[2] +print dnode2 openVnodes $data(3)[2] +print dnode2 openVnodes $data(4)[2] +if $data(1)[2] != 1 then + return -1 endi -if $data2_3 != null then - goto show9 +if $data(3)[2] != null then + return -1 endi -if $data2_4 != 4 then - goto show9 +if $data(4)[2] != 3 then + return -1 endi -system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 100 print ========== step10 sql select * from d1.t1 order by t desc diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index 8936655974..a59e989d80 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); -sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); +sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sleep 1000 diff --git a/tests/script/tsim/stream/distributeIntervalRetrive0.sim b/tests/script/tsim/stream/distributeIntervalRetrive0.sim new file mode 100644 index 0000000000..cde5c7058f --- /dev/null +++ b/tests/script/tsim/stream/distributeIntervalRetrive0.sim @@ -0,0 +1,291 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +sql create dnode $hostname2 port 7200 + +system sh/exec.sh -n dnode2 -s start + +print ===== step1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print ===== step2 + +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); +sql create table ts3 using st tags(3,2,2); +sql create table ts4 using st tags(4,2,2); +sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); + +sleep 1000 + +sql insert into ts1 values(1648791213001,1,12,3,1.0); +sql insert into ts2 values(1648791213001,1,12,3,1.0); +sql insert into ts1 values(1648791213002,NULL,NULL,NULL,NULL); +sql insert into ts2 values(1648791213002,NULL,NULL,NULL,NULL); + +sql insert into ts1 values(1648791223002,2,2,3,1.1); +sql insert into ts1 values(1648791233003,3,2,3,2.1); +sql insert into ts2 values(1648791243004,4,2,43,73.1); + +sql insert into ts1 values(1648791213002,24,22,23,4.1) (1648791243005,4,20,3,3.1); + +sleep 1000 + +sql insert into ts3 values(1648791213001,12,12,13,14.1) (1648791243005,14,30,30,30.1); + +$loop_count = 0 +loop1: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 5 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 14 then + print =====data02=$data02 + goto loop1 +endi + +# row 1 +if $data11 != 1 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop1 +endi + +#row2 +if $data21 != 1 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 3 then + print =====data22=$data22 + goto loop1 +endi + +#row 3 +if $data31 != 3 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 22 then + print =====data32=$data32 + goto loop1 +endi + +print loop1 over + +sql insert into ts1 values(1648791223008,4,2,30,3.1) (1648791213009,4,2,3,3.1) (1648791233010,4,2,3,3.1) (1648791243011,4,2,3,3.1)(1648791243012,34,32,33,3.1); + +$loop_count = 0 +loop2: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 6 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 18 then + print =====data02=$data02 + goto loop2 +endi + +# row 1 +if $data11 != 2 then + print =====data11=$data11 + goto loop2 +endi + +if $data12 != 6 then + print =====data12=$data12 + goto loop2 +endi + +#row2 +if $data21 != 2 then + print =====data21=$data21 + goto loop2 +endi + +if $data22 != 7 then + print =====data22=$data22 + goto loop2 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop2 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop2 +endi + +print loop2 over + +sql insert into ts4 values(1648791223008,4,2,30,3.1) (1648791213009,4,2,3,3.1) (1648791233010,4,2,3,3.1); + +$loop_count = 0 +loop3: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 7 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 22 then + print =====data02=$data02 + goto loop3 +endi + +# row 1 +if $data11 != 3 then + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 10 then + print =====data12=$data12 + goto loop3 +endi + +#row2 +if $data21 != 3 then + print =====data21=$data21 + goto loop3 +endi + +if $data22 != 11 then + print =====data22=$data22 + goto loop3 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop3 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop3 +endi + +print loop3 over + +$loop_count = 0 +loop4: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 7 then + print =====data01=$data01 + goto loop4 +endi + +if $data02 != 22 then + print =====data02=$data02 + goto loop4 +endi + +# row 1 +if $data11 != 3 then + print =====data11=$data11 + goto loop4 +endi + +if $data12 != 10 then + print =====data12=$data12 + goto loop4 +endi + +#row2 +if $data21 != 3 then + print =====data21=$data21 + goto loop4 +endi + +if $data22 != 11 then + print =====data22=$data22 + goto loop4 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop4 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop4 +endi + +print loop4 over + +system sh/stop_dnodes.sh diff --git a/tests/script/tsim/stream/distributesession0.sim b/tests/script/tsim/stream/distributeSession0.sim similarity index 100% rename from tests/script/tsim/stream/distributesession0.sim rename to tests/script/tsim/stream/distributeSession0.sim diff --git a/tests/script/unique/vnode/back_insert.sim b/tests/script/tsim/vnode/back_insert.sim similarity index 100% rename from tests/script/unique/vnode/back_insert.sim rename to tests/script/tsim/vnode/back_insert.sim diff --git a/tests/script/unique/vnode/back_insert_many.sim b/tests/script/tsim/vnode/back_insert_many.sim similarity index 100% rename from tests/script/unique/vnode/back_insert_many.sim rename to tests/script/tsim/vnode/back_insert_many.sim diff --git a/tests/script/tsim/vnode/replica3_basic.sim b/tests/script/tsim/vnode/replica3_basic.sim new file mode 100644 index 0000000000..f7dd5dd136 --- /dev/null +++ b/tests/script/tsim/vnode/replica3_basic.sim @@ -0,0 +1,368 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +print ========== step0 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step01: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step01 +endi +if $data(2)[4] != ready then + goto step01 +endi +if $data(3)[4] != ready then + goto step01 +endi + +sql create mnode on dnode 2 +sql create mnode on dnode 3 + +$x = 0 +step02: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show mnodes +print $data(1)[0] $data(1)[1] $data(1)[2] +print $data(2)[0] $data(2)[1] $data(2)[2] +print $data(3)[0] $data(3)[1] $data(3)[2] + +if $rows != 3 then + return -1 +endi +if $data(1)[0] != 1 then + return -1 +endi +if $data(1)[2] != leader then + return -1 +endi +if $data(2)[0] != 2 then + return -1 +endi +if $data(2)[2] != follower then + goto step02 +endi +if $data(3)[0] != 3 then + return -1 +endi +if $data(3)[2] != follower then + goto step02 +endi + +$N = 10 +$table = table_r3 +$db = db1 + +print =================== step 1 +sql create database $db replica 3 vgroups 1 +sql use $db + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step1 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step1 +endi + +sql use $db +sql create table $table (ts timestamp, speed int) + +print =================== step2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step3 +system sh/exec.sh -n dnode2 -s stop +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step3 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step3 +endi + +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +print =================== step4 +system sh/exec.sh -n dnode2 -s start +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step4 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step4 +endi + +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +print =================== step5 +system sh/exec.sh -n dnode3 -s stop +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step5 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step5 +endi + +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +print =================== step6 +system sh/exec.sh -n dnode3 -s start +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step6 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step6 +endi + +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +print =================== step7 +system sh/exec.sh -n dnode1 -s stop +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step7 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step7 +endi + +$y = $x + $N +$expect = $N * 6 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +print =================== step 8 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step8 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step8 +endi + +$y = $x + $N +$expect = $N * 7 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/vnode/replica3_import.sim b/tests/script/tsim/vnode/replica3_import.sim new file mode 100644 index 0000000000..d1e73b9f27 --- /dev/null +++ b/tests/script/tsim/vnode/replica3_import.sim @@ -0,0 +1,338 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode4 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode5 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode6 -c supportVnodes -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +stepa: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto stepa +endi +if $data(2)[4] != ready then + goto stepa +endi +if $data(3)[4] != ready then + goto stepa +endi +if $data(4)[4] != ready then + goto stepa +endi + +sql create database ir3db replica 3 duration 7 vgroups 1 +sql use ir3db +$x = 0 +stepb: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto stepb +endi + +sql create table tb(ts timestamp, i bigint) + +print ================= step1 +sql insert into tb values(1520000010000, 1520000010000) +sql select * from tb; +print $rows +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1520000008000, 1520000008000) +print $rows +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1520000020000, 1520000020000) +sql select * from tb; +print $rows +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql insert into tb values(1520000009000, 1520000009000) +sql insert into tb values(1520000015000, 1520000015000) +sql insert into tb values(1520000030000, 1520000030000) +sql select * from tb; +print $rows +if $rows != 6 then + return -1 +endi + +print ================= step5 +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 + return -1 +endi + +print ================= step6 +sql insert into tb values(1520000007000, 1520000007000) +sql insert into tb values(1520000012000, 1520000012000) +sql insert into tb values(1520000023000, 1520000023000) +sql insert into tb values(1520000034000, 1520000034000) +sql insert into tb values(1520000050000, 1520000050000) +sql select * from tb; +print $rows +if $rows != 14 then + return -1 +endi + +print ================== step7 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s start +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step7 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step7 +endi + +print ================= step7 +sql insert into tb values(1520000007001, 1520000007001) +sql insert into tb values(1520000012001, 1520000012001) +sql insert into tb values(1520000023001, 1520000023001) +sql insert into tb values(1520000034001, 1520000034001) +sql insert into tb values(1520000050001, 1520000050001) +sql select * from tb; +print $rows +if $rows != 19 then + print expect 19, actual: $rows + return -1 +endi + +print ================= step8 +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 != 23 then + return -1 +endi + +print ================= step9 +sql insert into tb values(1517408000000, 1517408000000) +sql insert into tb values(1518272000000, 1518272000000) +sql insert into tb values(1519136000000, 1519136000000) +sql insert into tb values(1519568000000, 1519568000000) +sql insert into tb values(1519654400000, 1519654400000) +sql insert into tb values(1519827200000, 1519827200000) +sql insert into tb values(1520345600000, 1520345600000) +sql insert into tb values(1520691200000, 1520691200000) +sql insert into tb values(1520864000000, 1520864000000) +sql insert into tb values(1521900800000, 1521900800000) +sql insert into tb values(1523110400000, 1523110400000) +sql insert into tb values(1521382400000, 1521382400000) +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step10 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s start +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step10 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step10 +endi + +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step11 +sql insert into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) +sql select * from tb; +if $rows != 40 then + return -1 +endi + +print ================= step12 +sql insert 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 != 49 then + return -1 +endi + +print ================= step13 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s start +$x = 0 +step13: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step13 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step13 +endi + +print ================= step14 +sql insert into tb values(1515852800001, -48) +sql insert into tb values(1516716800000, -38) +sql insert into tb values(1517580800000, -28) + +sql select * from tb; +print $rows +if $rows != 52 then + return -1 +endi + +print ================= step15 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s start +$x = 0 +step15: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups -x step15 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step15 +endi + +sql select * from tb; +if $rows != 52 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/vnode/replica3_many.sim b/tests/script/tsim/vnode/replica3_many.sim new file mode 100644 index 0000000000..6b1a582f23 --- /dev/null +++ b/tests/script/tsim/vnode/replica3_many.sim @@ -0,0 +1,262 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +print ========== step0 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step0: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step0 +endi +if $data(2)[4] != ready then + goto step0 +endi +if $data(3)[4] != ready then + goto step0 +endi +if $data(4)[4] != ready then + goto step0 +endi + +print ========= step1 +sql create database db1 replica 3 vgroups 1 +sql create database db2 replica 3 vgroups 1 +sql create database db3 replica 3 vgroups 1 +sql create database db4 replica 3 vgroups 1 + +print =============== step12 wait vgroup2 +$x = 0 +step12: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step12 +endi + +print =============== step13 wait vgroup3 +$x = 0 +step13: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step13 +endi + +print =============== step14 wait vgroup4 +$x = 0 +step14: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step14 +endi + +print =============== step15 wait vgroup5 +$x = 0 +step15: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step15 +endi + +print =============== step16: create table +sql create table db1.tb1 (ts timestamp, i int) +sql create table db2.tb2 (ts timestamp, i int) +sql create table db3.tb3 (ts timestamp, i int) +sql create table db4.tb4 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 1) +sql insert into db2.tb2 values(now, 1) +sql insert into db3.tb3 values(now, 1) +sql insert into db4.tb4 values(now, 1) + +sql select count(*) from db1.tb1 +$lastRows1 = $rows +sql select count(*) from db2.tb2 +$lastRows2 = $rows +sql select count(*) from db3.tb3 +$lastRows3 = $rows +sql select count(*) from db4.tb4 +$lastRows4 = $rows + +print ======== step2 +run_back tsim/vnode/back_insert_many.sim +sleep 3000 + +$x = 0 +loop: + +print ======== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step4 +system sh/exec.sh -n dnode3 -s stop +sleep 3000 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step5 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step6 +sql select count(*) from db1.tb1 +print select count(*) from db1.tb1 ==> $data00 $lastRows1 +if $data00 <= $lastRows1 then + return -1 +endi +$lastRows1 = $data00 + +sql select count(*) from db2.tb2 +print select count(*) from db2.tb2 ==> $data00 $lastRows2 +if $data00 <= $lastRows2 then + return -1 +endi +$lastRows2 = $data00 + +sql select count(*) from db3.tb3 +print select count(*) from db3.tb3 ==> $data00 $lastRows3 +if $data00 <= $lastRows3 then + return -1 +endi +$lastRows3 = $data00 + +sql select count(*) from db4.tb4 +print select count(*) from db4.tb4 ==> $data00 $lastRows4 +if $data00 <= $lastRows4 then + return -1 +endi +$lastRows4 = $data00 + +print ======== step7 + +print ======== loop Times $x + +if $x < 2 then + $x = $x + 1 + goto loop +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/tsim/vnode/replica3_repeat.sim similarity index 60% rename from tests/script/unique/vnode/replica3_repeat.sim rename to tests/script/tsim/vnode/replica3_repeat.sim index 636bc64f89..7419139277 100644 --- a/tests/script/unique/vnode/replica3_repeat.sim +++ b/tests/script/tsim/vnode/replica3_repeat.sim @@ -1,77 +1,84 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c 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 numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +print ========== step0 system sh/exec.sh -n dnode1 -s start - sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode4 -s start - $x = 0 -step1: +step0: $x = $x + 1 sleep 1000 if $x == 10 then + print ====> dnode not ready! return -1 endi - sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 endi -if $data4_2 != ready then - goto step1 +if $data(1)[4] != ready then + goto step0 endi -if $data4_3 != ready then - goto step1 +if $data(2)[4] != ready then + goto step0 endi -if $data4_4 != ready then - goto step1 +if $data(3)[4] != ready then + goto step0 endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 +if $data(4)[4] != ready then + goto step0 endi print ========= step1 -sql create database db replica 3 +sql create database db replica 3 vgroups 1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show db.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step1 +endi + sql create table db.tb (ts timestamp, i int) sql insert into db.tb values(now, 1) sql select count(*) from db.tb $lastRows = $rows print ======== step2 -run_back unique/vnode/back_insert.sim +run_back tsim/vnode/back_insert.sim sleep 2000 print ======== step3 diff --git a/tests/script/tsim/vnode/replica3_vgroup.sim b/tests/script/tsim/vnode/replica3_vgroup.sim new file mode 100644 index 0000000000..746a9d67ae --- /dev/null +++ b/tests/script/tsim/vnode/replica3_vgroup.sim @@ -0,0 +1,129 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +print ========== step0 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step0: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step0 +endi +if $data(2)[4] != ready then + goto step0 +endi +if $data(3)[4] != ready then + goto step0 +endi +if $data(4)[4] != ready then + goto step0 +endi + +$N = 10 +$table = table_r3 +$db = db1 + +print =================== step 1 +sql create database $db replica 3 vgroups 2 +sql use $db + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +if $rows != 2 then + return -1 +endi +$leaderExist = 0 +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step1 +endi +$leaderExist = 0 +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step1 +endi + +sql create table st (ts timestamp, speed int) tags (t1 int) + +$tbPre = m +$N = 300 +$x = 0 +$y = $x + $N +while $x < $y + $table = $tbPre . $x + sql create table $table using st tags ( $x ) + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +#print =================== step2 +$x = -500 +$y = $x + $N +while $x < $y + $ms = $x . m + sql insert into $table values (now $ms , $x ) + $x = $x + 1 +endw + +$expect = $N + 1 +sql select * from $table +print sql select * from $table -> $rows points expect $expect +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim deleted file mode 100644 index 14a6e92f06..0000000000 --- a/tests/script/unique/dnode/alternativeRole.sim +++ /dev/null @@ -1,97 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 - -system sh/cfg.sh -n dnode1 -c role -v 1 -system sh/cfg.sh -n dnode2 -c role -v 2 -system sh/cfg.sh -n dnode3 -c role -v 0 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 - - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sleep 5000 - -sql show dnodes -print dnode1 $data5_1 -print dnode1 $data5_2 -print dnode1 $data5_3 - -if $data5_1 != mnode then - return -1 -endi -if $data5_2 != vnode then - return -1 -endi -if $data5_3 != any then - return -1 -endi - -sql show mnodes -print dnode1 ==> $data2_1 -print dnode2 ==> $data2_2 -print dnode3 ==> $data2_3 -if $data2_1 != master then - return -1 -endi -if $data2_2 != null then - return -1 -endi -if $data2_3 != slave then - return -1 -endi - -print ========== step2 -sql create database d1 -sql create table d1.t1 (ts timestamp, i int) -sql create table d1.t2 (ts timestamp, i int) -sql create table d1.t3 (ts timestamp, i int) -sql create table d1.t4 (ts timestamp, i int) -sql create table d1.t5 (ts timestamp, i int) -sql create table d1.t6 (ts timestamp, i int) -sql create table d1.t7 (ts timestamp, i int) -sql create table d1.t8 (ts timestamp, i int) - -sql show dnodes -print dnode1 $data2_1 -print dnode2 $data2_2 -print dnode3 $data2_3 - -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 1 then - return -1 -endi -if $data2_3 != 1 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim deleted file mode 100644 index 4c67e20c3e..0000000000 --- a/tests/script/unique/dnode/balance2.sim +++ /dev/null @@ -1,306 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 -system sh/cfg.sh -n dnode5 -c wallevel -v 1 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql create database d1 replica 2 -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 create database d2 replica 2 -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 show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 2 then - return -1 -endi -if $data2_3 != 2 then - return -1 -endi - -print ========== step2 -sql drop dnode $hostname2 - -$x = 0 -show2: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 2 then - goto show2 -endi -if $data2_2 != null then - goto show2 -endi -if $data2_3 != 2 then - goto show2 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -print ========== step3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show3: - $x = $x + 1 - sleep 2000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show3 -endi -if $data2_2 != null then - goto show3 -endi -if $data2_3 != 2 then - goto show3 -endi -if $data2_4 != 2 then - goto show3 -endi - -print ========== step4 -sql create database d3 replica 2 -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 show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != null then - return -1 -endi -if $data2_3 != 3 then - return -1 -endi -if $data2_4 != 3 then - return -1 -endi - -print ========== step5 -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 -if $data2_1 != 0 then - goto show5 -endi -if $data2_2 != null then - goto show5 -endi -if $data2_3 != 2 then - goto show5 -endi -if $data2_4 != 2 then - goto show5 -endi -if $data2_5 != 2 then - goto show5 -endi - -print ========== step6 -sql drop dnode $hostname3 - -$x = 0 -show6: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 -if $data2_1 != 0 then - goto show6 -endi -if $data2_2 != null then - goto show6 -endi -if $data2_3 != null then - goto show6 -endi -if $data2_4 != 3 then - goto show6 -endi -if $data2_5 != 3 then - goto show6 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sql reset query cache -sleep 100 - -print ========== step7 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance3.sim b/tests/script/unique/dnode/balance3.sim deleted file mode 100644 index f5558d504e..0000000000 --- a/tests/script/unique/dnode/balance3.sim +++ /dev/null @@ -1,337 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 -system sh/deploy.sh -n dnode6 -i 6 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 -system sh/cfg.sh -n dnode5 -c wallevel -v 1 -system sh/cfg.sh -n dnode6 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi -if $data4_4 != ready then - goto step1 -endi - -sql create database d1 replica 3 -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 create database d2 replica 3 -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 show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 2 then - return -1 -endi -if $data2_3 != 2 then - return -1 -endi -if $data2_4 != 2 then - return -1 -endi - -print ========== step2 -sql drop dnode $hostname2 - -$x = 0 -show2: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 2 then - goto show2 -endi -if $data2_2 != null then - goto show2 -endi -if $data2_3 != 2 then - goto show2 -endi -if $data2_4 != 2 then - goto show2 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT -print ========== step -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 60 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_1 != 0 then - goto show3 -endi -if $data2_2 != null then - goto show3 -endi -if $data2_3 != 2 then - goto show3 -endi -if $data2_4 != 2 then - goto show3 -endi -if $data2_5 != 2 then - goto show3 -endi - -print ========== step4 -sql create database d3 replica 3 -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) - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_1 != 0 then - goto show4 -endi -if $data2_2 != null then - goto show4 -endi -if $data2_3 != 3 then - goto show4 -endi -if $data2_4 != 3 then - goto show4 -endi -if $data2_5 != 3 then - goto show4 -endi - -print ========== step5 -sql create dnode $hostname6 -system sh/exec.sh -n dnode6 -s start - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode6 openVnodes $data2_6 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_1 != 0 then - goto show5 -endi -if $data2_6 != 2 then - goto show5 -endi - -sleep 8000 - -print ========== step6 -sql drop dnode $hostname3 - -$x = 0 -show6: - $x = $x + 1 - sleep 1000 - if $x == 30 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode6 openVnodes $data2_6 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_1 != 0 then - goto show6 -endi -if $data2_6 != 3 then - goto show6 -endi -if $data2_3 != null then - goto show6 -endi -if $data2_4 != 3 then - goto show6 -endi -if $data2_5 != 3 then - goto show6 -endi - -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sql reset query cache -sleep 100 - -print ========== step7 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim deleted file mode 100644 index d2c738ee97..0000000000 --- a/tests/script/unique/dnode/balancex.sim +++ /dev/null @@ -1,215 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 -system sh/cfg.sh -n dnode4 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sleep 2000 - -sql create database d1 -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 create database d2 -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 show dnodes -print dnode1 openVnodes $data2_1 -if $data2_1 != 2 then - return -1 -endi - -print ========== step2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -show2: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then - goto show2 -endi -if $data2_2 != 2 then - goto show2 -endi - -print ========== step3 -sql create database d3 replica 2 -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) - -$x = 0 -show3: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 1 then - goto show3 -endi -if $data2_2 != 3 then - goto show3 -endi - -print ========== step3 -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start - -$x = 0 -show4: - $x = $x + 1 - sleep 2000 - if $x == 20 then - return -1 - endi -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 0 then - goto show4 -endi -if $data2_2 != 2 then - goto show4 -endi -if $data2_3 != 2 then - goto show4 -endi - -print ========== step5 -sql drop dnode $hostname2 - -$x = 0 -show5: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 1 then - goto show5 -endi -if $data2_2 != null then - goto show5 -endi -if $data2_3 != 3 then - goto show5 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -sql reset query cache -sleep 1000 - -print ========== step6 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/data1.sim b/tests/script/unique/dnode/data1.sim deleted file mode 100644 index 75a484abb6..0000000000 --- a/tests/script/unique/dnode/data1.sim +++ /dev/null @@ -1,137 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -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 ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sleep 2000 - -print ========== step2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show2: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show2 -endi -if $data2_2 != 0 then - goto show2 -endi -if $data2_3 != 0 then - goto show2 -endi -if $data2_4 != 0 then - goto show2 -endi - -print ========== step3 -sql create database d1 replica 3 -sql create table d1.t1 (t timestamp, i int) -sql insert into d1.t1 values(now+1s, 35) -sql insert into d1.t1 values(now+2s, 34) -sql insert into d1.t1 values(now+3s, 33) -sql insert into d1.t1 values(now+4s, 32) -sql insert into d1.t1 values(now+5s, 31) - -$x = 0 -show3: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show3 -endi -if $data2_2 != 1 then - goto show3 -endi -if $data2_3 != 1 then - goto show3 -endi -if $data2_4 != 1 then - goto show3 -endi - -print ========== step4 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT - -print ========== step5 -system_content rm -rf ../../../sim/dnode4/data/vnode/vnode2/tsdb/data - -print ========== step6 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -sleep 10000 - -print ========== step7 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_1node.sim b/tests/script/unique/dnode/datatrans_1node.sim deleted file mode 100644 index a156c32672..0000000000 --- a/tests/script/unique/dnode/datatrans_1node.sim +++ /dev/null @@ -1,53 +0,0 @@ - -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/exec.sh -n dnode1 -s start - -sleep 2000 -sql connect - -print =============== step1 -sql drop database -x step1 -step1: -sql create database db -sql use db -sql create table m1 (ts timestamp, speed int) - -print =============== step 2 -$x = 0 -while $x < 10 - $cc = $x * 60000 - $ms = 1601481600000 + $cc - - sql insert into m1 values ($ms , $x ) - $x = $x + 1 -endw - -sql select * from m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT - -print =============== step 3 -system sh/move_dnode.sh dnode1 dnode2 -system sh/exec.sh -n dnode2 -s start - - -print =============== step 4 -sleep 2000 -sql connect - -sql select * from db.m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_3node.sim b/tests/script/unique/dnode/datatrans_3node.sim deleted file mode 100644 index 7948eb6d3a..0000000000 --- a/tests/script/unique/dnode/datatrans_3node.sim +++ /dev/null @@ -1,91 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 - - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 - - -system sh/cfg.sh -n 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 dnode1 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c role -v 2 -system sh/cfg.sh -n dnode2 -c role -v 2 -system sh/cfg.sh -n dnode3 -c role -v 2 - - -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 - - - - -print ============== step1: start dnode1 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname2 -sql create dnode $hostname3 -sleep 2000 - -# create table -sql drop database -x step1 -step1: -sql create database db -sql use db -sql create table m1 (ts timestamp, speed int) - -# insert data -$x = 0 -while $x < 10 - $cc = $x * 60000 - $ms = 1601481600000 + $cc - - sql insert into m1 values ($ms , $x ) - $x = $x + 1 -endw - -sql select * from m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -print ============== step3: stop cluster , then move_dnode1 ,start cluster -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -system sh/move_dnode.sh dnode1 dnode4 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start - -print =============== step 4 -sleep 2000 -sql connect - -sql select * from db.m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_3node_2.sim b/tests/script/unique/dnode/datatrans_3node_2.sim deleted file mode 100644 index 844afc5b02..0000000000 --- a/tests/script/unique/dnode/datatrans_3node_2.sim +++ /dev/null @@ -1,91 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 - - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 - - -system sh/cfg.sh -n 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 dnode1 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c role -v 2 -system sh/cfg.sh -n dnode2 -c role -v 2 -system sh/cfg.sh -n dnode3 -c role -v 2 - - -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 - - - - -print ============== step1: start dnode1 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname2 -sql create dnode $hostname3 -sleep 2000 - -# create table -sql drop database -x step1 -step1: -sql create database db replica 2 -sql use db -sql create table m1 (ts timestamp, speed int) - -# insert data -$x = 0 -while $x < 10 - $cc = $x * 60000 - $ms = 1601481600000 + $cc - - sql insert into m1 values ($ms , $x ) - $x = $x + 1 -endw - -sql select * from m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -print ============== step3: stop cluster , then move_dnode1 ,start cluster -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -system sh/move_dnode.sh dnode1 dnode4 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start - -print =============== step 4 -sleep 2000 -sql connect - -sql select * from db.m1 - -print $rows points data are retrieved -if $rows != 10 then - return -1 -endi - -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/lossdata.sim b/tests/script/unique/dnode/lossdata.sim deleted file mode 100644 index 89ba716970..0000000000 --- a/tests/script/unique/dnode/lossdata.sim +++ /dev/null @@ -1,165 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 - -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 dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -print ========== step2 - -sql create database d1 replica 2 -sql create table d1.t1 (t timestamp, i int) - -print ========== step2.1 - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 1 then - return -1 -endi -if $data2_3 != 1 then - return -1 -endi - -print ========== step3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_2 != 1 then - goto show3 -endi -if $data2_3 != 1 then - goto show3 -endi -if $data2_4 != 0 then - goto show3 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -print ========== step4 -sql drop dnode $hostname3 - -$i = 0 -$rowNum = 10000 - -while $i < $rowNum - $ts = 1500000000000 + $i - sql insert into d1.t1 values( $ts , $i ) - - $i = $i + 1 -endw - -print insert $rowNum finished - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != 1 then - goto show4 -endi -if $data2_3 != null then - goto show4 -endi -if $data2_4 != 1 then - goto show4 -endi - -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -print ========== step5 -sql select count(*) from d1.t1 -print select count(*) from d1.t1 ==> $data00 -if $data00 != $rowNum then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/m2.sim b/tests/script/unique/dnode/m2.sim deleted file mode 100644 index 5fdf3b7400..0000000000 --- a/tests/script/unique/dnode/m2.sim +++ /dev/null @@ -1,367 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 - -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 dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -print ========== step2 - -sql create database d1 replica 2 -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 create database d2 replica 2 -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 create database d3 replica 2 -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 create database d4 replica 2 -sql create table d4.t4 (t timestamp, i int) -sql insert into d4.t4 values(now+1s, 45) -sql insert into d4.t4 values(now+2s, 44) -sql insert into d4.t4 values(now+3s, 43) -sql insert into d4.t4 values(now+4s, 42) -sql insert into d4.t4 values(now+5s, 41) - -print ========== step2.1 - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 - -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 4 then - return -1 -endi -if $data2_3 != 4 then - return -1 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -print ========== step3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != 2 then - goto show3 -endi -if $data2_3 != 2 then - goto show3 -endi -if $data2_4 != 2 then - goto show3 -endi -if $data2_5 != 2 then - goto show3 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show3 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show3 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show3 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show3 -endi - -print ========== step4 -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != null then - goto show4 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show4 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show4 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show4 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show4 -endi - -sql reset query cache -sleep 100 -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -print ========== step5 -sql drop dnode $hostname3 - -$x = 0 -show5: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != null then - goto show5 -endi -if $data2_3 != null then - goto show5 -endi -if $data2_4 != 4 then - goto show5 -endi -if $data2_5 != 4 then - goto show4 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show5 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show5 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show5 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data03 != 2 then - goto show5 -endi - -sql reset query cache -sleep 100 -system sh/exec.sh -n dnode3 -s stop -x SIGINT - -print ========== step6 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -sql select * from d4.t4 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 41 then - return -1 -endi -if $data11 != 42 then - return -1 -endi -if $data21 != 43 then - return -1 -endi -if $data31 != 44 then - return -1 -endi -if $data41 != 45 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/m3.sim b/tests/script/unique/dnode/m3.sim deleted file mode 100644 index 5850147d04..0000000000 --- a/tests/script/unique/dnode/m3.sim +++ /dev/null @@ -1,359 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 - -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 dnode3 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi -if $data4_4 != ready then - goto step1 -endi - -print ========== step2 - -sql create database d1 replica 3 -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 create database d2 replica 3 -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 create database d3 replica 3 -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 create database d4 replica 3 -sql create table d4.t4 (t timestamp, i int) -sql insert into d4.t4 values(now+1s, 45) -sql insert into d4.t4 values(now+2s, 44) -sql insert into d4.t4 values(now+3s, 43) -sql insert into d4.t4 values(now+4s, 42) -sql insert into d4.t4 values(now+5s, 41) - -print ========== step2.1 - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 - -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 4 then - return -1 -endi -if $data2_3 != 4 then - return -1 -endi -if $data2_4 != 4 then - return -1 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 4 then - return -1 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 3 then - return -1 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 2 then - return -1 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 4 then - return -1 -endi - -print ========== step3 -sql create dnode $hostname5 -system sh/exec.sh -n dnode5 -s start - -$x = 0 -show3: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != 3 then - goto show3 -endi -if $data2_3 != 3 then - goto show3 -endi -if $data2_4 != 3 then - goto show3 -endi -if $data2_5 != 3 then - goto show3 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 5 then - return -1 -endi -if $data03 != 3 then - goto show3 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 5 then - return -1 -endi -if $data03 != 3 then - goto show3 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 2 then - return -1 -endi -if $data03 != 3 then - goto show3 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 4 then - return -1 -endi -if $data03 != 3 then - goto show3 -endi - -print ========== step4 -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -print dnode5 openVnodes $data2_5 - -if $data2_2 != null then - goto show4 -endi -if $data2_3 != 4 then - goto show4 -endi -if $data2_4 != 4 then - goto show4 -endi -if $data2_5 != 4 then - goto show4 -endi - -sql show d1.vgroups; -print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 5 then - return -1 -endi -if $data03 != 3 then - goto show4 -endi - -sql show d2.vgroups; -print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 3 then - return -1 -endi -if $data03 != 3 then - goto show4 -endi - -sql show d3.vgroups; -print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 4 then - return -1 -endi -if $data03 != 3 then - goto show4 -endi - -sql show d4.vgroups; -print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data04 != 4 then - return -1 -endi -if $data03 != 3 then - goto show4 -endi - -sql reset query cache -sleep 100 - -print ========== step5 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 21 then - return -1 -endi -if $data11 != 22 then - return -1 -endi -if $data21 != 23 then - return -1 -endi -if $data31 != 24 then - return -1 -endi -if $data41 != 25 then - return -1 -endi - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -sql select * from d4.t4 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 41 then - return -1 -endi -if $data11 != 42 then - return -1 -endi -if $data21 != 43 then - return -1 -endi -if $data31 != 44 then - return -1 -endi -if $data41 != 45 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/monitor_bug.sim b/tests/script/unique/dnode/monitor_bug.sim deleted file mode 100644 index 60c6524d9c..0000000000 --- a/tests/script/unique/dnode/monitor_bug.sim +++ /dev/null @@ -1,77 +0,0 @@ -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 mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 - -system sh/cfg.sh -n dnode1 -c monitor -v 1 -system sh/cfg.sh -n dnode2 -c monitor -v 0 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sleep 3000 - -sql show dnodes -print dnode1 openVnodes $data2_1 -if $data2_1 > 2 then - return -1 -endi - -print ========== step2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -show2: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 0 then - goto show2 -endi -if $data2_2 > 2 then - goto show2 -endi - -print ========== step3 -sql show log.tables - -print $data00 -print $data10 -print $data20 -print $data30 -print $data40 -print $data50 - -if $rows > 5 then - return -1 -endi - -print ========== step4 -sql select * from log.dn1 -print $rows -$rows1 = $rows - -sleep 2000 -sql select * from log.dn1 -print $rows -$rows2 = $rows - -if $rows2 <= $rows1 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/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim deleted file mode 100644 index 9bbd14cf07..0000000000 --- a/tests/script/unique/dnode/offline1.sim +++ /dev/null @@ -1,77 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 - -system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 5 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 5 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 5 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sleep 2000 - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 != ready then - return -1 -endi - -print ========== step2 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 8000 - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 == ready then - return -1 -endi - -print ========== step3 -sleep 10000 - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 != null then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim deleted file mode 100644 index 711488cf3f..0000000000 --- a/tests/script/unique/dnode/offline2.sim +++ /dev/null @@ -1,126 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 - -system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 5 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 5 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 5 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 - - -system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 - - -system sh/cfg.sh -n dnode1 -c wallevel -v 1 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/cfg.sh -n dnode3 -c wallevel -v 1 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sleep 2000 - -sql create database d1 replica 2 -sql create table d1.t1(ts timestamp, i int) -sql insert into d1.t1 values(1588262400001, 1) - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 != ready then - return -1 -endi - -print ========== step2 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 8000 - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 == ready then - return -1 -endi - -print ========== step3 -sleep 10000 - -sql show dnodes -print dnode1 $data4_1 -print dnode1 $data4_2 - -if $data4_1 != ready then - return -1 -endi -if $data4_2 != dropping then - return -1 -endi - -print ========== step4 -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode2 -s start -sql drop dnode $hostname2 - -sleep 3000 -$x = 0 -show4: - $x = $x + 1 - sleep 3000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -if $data4_1 != ready then - goto show4 -endi -if $data4_2 != null then - goto show4 -endi -if $data4_3 != ready then - goto show4 -endi - -print ======================== step5 -sql reset query cache -sleep 1000 - -sql select * from d1.t1 -if $rows != 1 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline3.sim b/tests/script/unique/dnode/offline3.sim deleted file mode 100644 index 93c75e3b13..0000000000 --- a/tests/script/unique/dnode/offline3.sim +++ /dev/null @@ -1,111 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c offlineThreshold -v 3 -system sh/cfg.sh -n dnode2 -c offlineThreshold -v 3 -system sh/cfg.sh -n dnode3 -c offlineThreshold -v 3 -system sh/cfg.sh -n dnode4 -c offlineThreshold -v 3 - -system sh/cfg.sh -n dnode1 -c balanceInterval -v 300 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 300 -system sh/cfg.sh -n dnode3 -c balanceInterval -v 300 -system sh/cfg.sh -n dnode4 -c balanceInterval -v 300 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi -if $data4_4 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -if $data2_1 != master then - goto step1 -endi - -print ========== step2 -sql create database db replica 3 -sql use db -sql create table tb (ts timestamp, value int) -sql insert into tb values (now, 1) -sql insert into tb values (now, 2) - -sql show vgroups; -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -print ========== step2 -system sh/exec.sh -n dnode4 -s stop -x SIGINT - -$x = 0 -step2: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show vgroups; -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step2 -endi -if $data4_2 != ready then - goto step2 -endi -if $data4_3 != ready then - goto step2 -endi -if $data4_4 != null then - goto step2 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/reason.sim b/tests/script/unique/dnode/reason.sim deleted file mode 100644 index c685b1129d..0000000000 --- a/tests/script/unique/dnode/reason.sim +++ /dev/null @@ -1,203 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 - -sql show dnodes -print dnode1 off: $data7_1 -print dnode2 off: $data7_2 -if $data7_2 != @status not received@ then - return -1 -endi - -print ========== step2 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi - -print ========== step3 -system sh/exec.sh -n dnode2 -s stop - -$x = 0 -step3: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi -sql show dnodes -print dnode1 off: $data7_1 -print dnode2 off: $data7_2 -if $data7_2 != @status msg timeout@ then - goto step3 -endi - -print ========== step4 -sql drop dnode $hostname2 -$x = 0 -step4: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -if $rows != 1 then - goto step4 -endi - -print ========== step5 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname2 - -$x = 0 -step5: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode2 off: $data7_3 -if $data7_3 != @dnodeId not match@ then - goto step5 -endi - -print ========== step6 -system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 3 -system sh/exec.sh -n dnode4 -s start -sql create dnode $hostname4 - -$x = 0 -step6: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode4 off: $data7_4 -if $data7_4 != @mnEqualVn not match@ then - goto step6 -endi - -print ========== step7 -system sh/deploy.sh -n dnode5 -i 5 -system sh/cfg.sh -n dnode5 -c statusInterval -v 3 -system sh/exec.sh -n dnode5 -s start -sql create dnode $hostname5 - -$x = 0 -step7: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode5 off: $data7_5 -if $data7_5 != @interval not match@ then - goto step7 -endi - -print ========== step8 -system sh/deploy.sh -n dnode6 -i 6 -system sh/cfg.sh -n dnode6 -c balance -v 0 -system sh/exec.sh -n dnode6 -s start -sql create dnode $hostname6 - -$x = 0 -step8: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode6 off: $data7_6 -if $data7_6 != @balance not match@ then - goto step8 -endi - -print ========== step9 -system sh/deploy.sh -n dnode7 -i 7 -system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000 -system sh/exec.sh -n dnode7 -s start -sql create dnode $hostname7 - -$x = 0 -step9: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode7 off: $data7_7 -if $data7_7 != @maxTabPerVn not match@ then - goto step9 -endi - -print ========== step10 -system sh/deploy.sh -n dnode8 -i 8 -system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3 -system sh/exec.sh -n dnode8 -s start -sql create dnode $hostname8 - -$x = 0 -step10: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 off: $data7_1 -print dnode8 off: $data7_8 -if $data7_8 != @maxVgPerDb not match@ then - goto step10 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim deleted file mode 100644 index 1d707bc4a3..0000000000 --- a/tests/script/unique/dnode/remove2.sim +++ /dev/null @@ -1,204 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -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 maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create database d1 -sql create table d1.t1 (t timestamp, i int) -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 -sql create table d2.t2 (t timestamp, i int) -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 -if $data2_1 != 2 then - return -1 -endi - -print ========== step2 -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -$x = 0 -step2: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step2 -endi -if $data4_2 != ready then - goto step2 -endi - -sql create database d3 replica 2 -sql create table d3.t3 (t timestamp, i int) -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: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 1 then - goto show2 -endi -if $data2_2 != 3 then - goto show2 -endi - -print ========== step3 -system sh/exec.sh -n dnode2 -s stop -x SIGINT - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 - -print ========== step4 -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step4: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -# wait dnode3 create first vgroup in dnode-status msg -if $data2_3 != 1 then - goto step4 -endi - -print ============ step 4.1 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -step4.1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_2 != ready then - goto step4.1 -endi - -sql drop dnode $hostname2 - -$x = 0 -show4: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -if $data2_1 != 1 then - goto show4 -endi -if $data2_2 != null then - goto show4 -endi -if $data2_3 != 3 then - goto show4 -endi - -print ========== step5 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 - -sql select * from d2.t2 order by t desc -print $data01 $data11 $data21 $data31 $data41 - -sql select * from d3.t3 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 31 then - return -1 -endi -if $data11 != 32 then - return -1 -endi -if $data21 != 33 then - return -1 -endi -if $data31 != 34 then - return -1 -endi -if $data41 != 35 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/simple.sim b/tests/script/unique/dnode/simple.sim deleted file mode 100644 index 38d8c08d75..0000000000 --- a/tests/script/unique/dnode/simple.sim +++ /dev/null @@ -1,147 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -print ========== step1 -system sh/exec.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -sql create dnode $hostname3 -system sh/exec.sh -n dnode3 -s start -sleep 2000 - -sql create database d1 replica 2 -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 show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 1 then - return -1 -endi -if $data2_3 != 1 then - return -1 -endi -if $data2_4 != null then - return -1 -endi - -print ========== step2 -sql create dnode $hostname4 -system sh/exec.sh -n dnode4 -s start -sleep 2000 - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - return -1 -endi -if $data2_2 != 1 then - return -1 -endi -if $data2_3 != 1 then - return -1 -endi -if $data2_4 != 0 then - return -1 -endi - -print ========== step3 -sql drop dnode $hostname2 - -$x = 0 -show3: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 0 then - goto show3 -endi -if $data2_2 != null then - goto show3 -endi -if $data2_3 != 1 then - goto show3 -endi -if $data2_4 != 1 then - goto show3 -endi - -print ========== step4 -sql drop dnode $hostname3 - -$x = 0 -show4: - $x = $x + 1 - sleep 2000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -print dnode3 openVnodes $data2_3 -print dnode4 openVnodes $data2_4 -if $data2_1 != 1 then - goto show4 -endi -if $data2_2 != null then - goto show4 -endi -if $data2_3 != null then - goto show4 -endi -if $data2_4 != 1 then - goto show4 -endi - -print ========== step5 -sql select * from d1.t1 order by t desc -print $data01 $data11 $data21 $data31 $data41 -if $data01 != 11 then - return -1 -endi -if $data11 != 12 then - return -1 -endi -if $data21 != 13 then - return -1 -endi -if $data31 != 14 then - return -1 -endi -if $data41 != 15 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/testSuite.sim b/tests/script/unique/dnode/testSuite.sim deleted file mode 100644 index ecd43cc224..0000000000 --- a/tests/script/unique/dnode/testSuite.sim +++ /dev/null @@ -1,9 +0,0 @@ -run unique/dnode/balance1.sim -run unique/dnode/balance2.sim -run unique/dnode/balance3.sim -run unique/dnode/balancex.sim -run unique/dnode/offline1.sim -run unique/dnode/offline2.sim -run unique/dnode/remove1.sim -run unique/dnode/remove2.sim -run unique/dnode/vnode_clean.sim diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim deleted file mode 100644 index 387567fc82..0000000000 --- a/tests/script/unique/import/replica2.sim +++ /dev/null @@ -1,300 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 - -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 -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 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.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -system sh/exec.sh -n dnode2 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi - -sql create database ir2db replica 2 duration 7 -sql use ir2db -sql create table tb(ts timestamp, i bigint) - -print ================= step1 -sql import into tb values(1520000010000, 1520000010000) -sql select * from tb; -print $rows -if $rows != 1 then - return -1 -endi - -print ================= step2 -sql insert into tb values(1520000008000, 1520000008000) -print $rows -sql select * from tb; -if $rows != 2 then - return -1 -endi - -print ================= step3 -sql insert into tb values(1520000020000, 1520000020000) -sql select * from tb; -print $rows -if $rows != 3 then - return -1 -endi - -print ================= step4 -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 - return -1 -endi - -print ================= step5 -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 - return -1 -endi - -print ================= step6 -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.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start - -$x = 0 -a1: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show vgroups -print online vnodes $data03 -if $data03 != 2 then - goto a1 -endi - -sql select * from tb; -if $rows != 14 then - return -1 -endi - -print ================= step7 -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 - print expect 19, actual: $rows - return -1 -endi - -print ================= step8 -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 != 23 then - return -1 -endi - -print ================= step9 -#1520000000000 -#sql import into tb values(now-30d, 7003) -#sql import into tb values(now-20d, 34003) -#sql import into tb values(now-10d, 34003) -#sql import into tb values(now-5d, 34003) -#sql import into tb values(now+1d, 50001) -#sql import into tb values(now+2d, 50001) -#sql import into tb values(now+6d, 50001) -#sql import into tb values(now+8d, 50002) -#sql import into tb values(now+10d, 50003) -#sql import into tb values(now+12d, 50004) -#sql import into tb values(now+14d, 50001) -#sql import into tb values(now+16d, 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 != 35 then - return -1 -endi - -print ================= step10 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start - -$x = 0 -a2: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show vgroups -print online vnodes $data03 -if $data03 != 2 then - goto a2 -endi - -sql select * from tb; -print $rows -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, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) -sql select * from tb; -if $rows != 40 then - return -1 -endi - -print ================= step12 -#1520000000000 -#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 != 49 then - return -1 -endi - -print ================= step13 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s start -$x = 0 -a3: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show vgroups -print online vnodes $data03 -if $data03 != 2 then - goto a3 -endi - -print ================= step14 -#1520000000000 -#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, -48) -sql import into tb values(1516716800000, -38) -sql import into tb values(1517580800000, -28) - -sql select * from tb; -if $rows != 52 then - return -1 -endi - -print ================= step15 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -$x = 0 -a4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show vgroups -print online vnodes $data03 -if $data03 != 2 then - goto a4 -endi - -sql select * from tb; -if $rows != 52 then - goto a4 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim deleted file mode 100644 index 5c1b8b8932..0000000000 --- a/tests/script/unique/import/replica3.sim +++ /dev/null @@ -1,291 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 - -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 -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 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.sh -n dnode1 -s start -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql create database ir3db replica 3 duration 7 -sql use ir3db -sql create table tb(ts timestamp, i bigint) - -print ================= step1 -sql import into tb values(1520000010000, 1520000010000) -sql select * from tb; -print $rows -if $rows != 1 then - return -1 -endi - -print ================= step2 -sql insert into tb values(1520000008000, 1520000008000) -print $rows -sql select * from tb; -if $rows != 2 then - return -1 -endi - -print ================= step3 -sql insert into tb values(1520000020000, 1520000020000) -sql select * from tb; -print $rows -if $rows != 3 then - return -1 -endi - -print ================= step4 -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 - return -1 -endi - -print ================= step5 -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 - return -1 -endi - -print ================= step6 -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.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -$x = 0 -a4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show vgroups -print online vnodes $data03 -if $data03 != 3 then - goto a4 -endi - -sql select * from tb; -if $rows != 14 then - return -1 -endi - -print ================= step7 -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 - print expect 19, actual: $rows - return -1 -endi - -print ================= step8 -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 != 23 then - return -1 -endi - -print ================= step9 -#1520000000000 -#sql import into tb values(now-30d, 7003) -#sql import into tb values(now-20d, 34003) -#sql import into tb values(now-10d, 34003) -#sql import into tb values(now-5d, 34003) -#sql import into tb values(now+1d, 50001) -#sql import into tb values(now+2d, 50001) -#sql import into tb values(now+6d, 50001) -#sql import into tb values(now+8d, 50002) -#sql import into tb values(now+10d, 50003) -#sql import into tb values(now+12d, 50004) -#sql import into tb values(now+14d, 50001) -#sql import into tb values(now+16d, 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 != 35 then - return -1 -endi - -print ================= step10 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start - -$x = 0 -step10: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show vgroups -print online vnodes $data03 -if $data03 != 3 then - goto step10 -endi - -sql select * from tb; -print $rows -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, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) -sql select * from tb; -if $rows != 40 then - return -1 -endi - -print ================= step12 -#1520000000000 -#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 != 49 then - return -1 -endi - -print ================= step13 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 -system sh/exec.sh -n dnode2 -s start -sleep 3000 - -print ================= step14 -#1520000000000 -#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, -48) -sql import into tb values(1516716800000, -38) -sql import into tb values(1517580800000, -28) - -sql select * from tb; -if $rows != 52 then - return -1 -endi - -print ================= step15 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s start -$x = 0 -step15: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi -sql show vgroups -print online vnodes $data03 -if $data03 != 3 then - goto step15 -endi - -sql select * from tb; -if $rows != 52 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/testSuite.sim b/tests/script/unique/import/testSuite.sim deleted file mode 100644 index 8be358ce17..0000000000 --- a/tests/script/unique/import/testSuite.sim +++ /dev/null @@ -1,2 +0,0 @@ -run unique/import/replica2.sim -run unique/import/replica3.sim \ No newline at end of file diff --git a/tests/script/unique/vnode/backup/replica4.sim b/tests/script/unique/vnode/backup/replica4.sim deleted file mode 100644 index c0ff267c73..0000000000 --- a/tests/script/unique/vnode/backup/replica4.sim +++ /dev/null @@ -1,220 +0,0 @@ -system sh/stop_dnodes.sh - - - - - - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode2 -c walLevel -v 1 -system sh/cfg.sh -n dnode3 -c walLevel -v 1 -system sh/cfg.sh -n dnode4 -c walLevel -v 1 - -system sh/exec.sh -n dnode1 -s start -$x = 0 -connectTbase: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql connect -x connectTbase - -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 - -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -sleep 3001 - -$N = 10 -$table = table_r4 -$db = db1 - -print =================== step 1 - -$x = 0 -created: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create database $db replica 4 -x created -sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $table (ts timestamp, speed int) -x create1 -sleep 3001 - -print =================== step 2 -$x = 1 -$y = $x + $N -$expect = $N -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 3 -system sh/exec.sh -n dnode2 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 4 -system sh/exec.sh -n dnode2 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 3 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 5 -system sh/exec.sh -n dnode3 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 4 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 6 -system sh/exec.sh -n dnode3 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 5 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - - -print =================== step 7 -system sh/exec.sh -n dnode4 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 6 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 8 -system sh/exec.sh -n dnode4 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 7 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 9 -system sh/exec.sh -n dnode1 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 8 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , 10) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 10 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 9 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -system sh/exec.sh -n dnode2 -s stop -system sh/exec.sh -n dnode3 -s stop -system sh/exec.sh -n dnode4 -s stop - diff --git a/tests/script/unique/vnode/backup/replica5.sim b/tests/script/unique/vnode/backup/replica5.sim deleted file mode 100644 index 1223cf6b58..0000000000 --- a/tests/script/unique/vnode/backup/replica5.sim +++ /dev/null @@ -1,263 +0,0 @@ -system sh/stop_dnodes.sh - - - - - - - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/deploy.sh -n dnode5 -i 5 - -system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode2 -c walLevel -v 1 -system sh/cfg.sh -n dnode3 -c walLevel -v 1 -system sh/cfg.sh -n dnode4 -c walLevel -v 1 -system sh/cfg.sh -n dnode5 -c walLevel -v 1 - -system sh/exec.sh -n dnode1 -s start - -$x = 0 -connectTbase: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql connect -x connectTbase - -sql create dnode $hostname2 -sql create dnode $hostname3 -sql create dnode $hostname4 -sql create dnode $hostname5 - -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -system sh/exec.sh -n dnode4 -s start -system sh/exec.sh -n dnode5 -s start -sleep 3001 - -$N = 10 -$table = table_r5 -$db = db1 - -print =================== step 1 - -$x = 0 -created: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create database $db replica 5 -x created -sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $table (ts timestamp, speed int) -x create1 - -sleep 3001 - -print =================== step 2 -$x = 1 -$y = $x + $N -$expect = $N -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 3 -system sh/exec.sh -n dnode2 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 4 -system sh/exec.sh -n dnode2 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 3 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 5 -system sh/exec.sh -n dnode3 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 4 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 6 -system sh/exec.sh -n dnode3 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 5 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - - -print =================== step 7 -system sh/exec.sh -n dnode4 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 6 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 8 -system sh/exec.sh -n dnode4 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 7 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - - -print =================== step 9 -system sh/exec.sh -n dnode5 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 8 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 10 -system sh/exec.sh -n dnode5 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 9 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 11 -system sh/exec.sh -n dnode1 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 10 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , 10) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 12 -system sh/exec.sh -n dnode1 -s start -sleep 2000 -$y = $x + $N -$expect = $N * 11 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -system sh/exec.sh -n dnode2 -s stop -system sh/exec.sh -n dnode3 -s stop -system sh/exec.sh -n dnode4 -s stop -system sh/exec.sh -n dnode5 -s stop - diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim deleted file mode 100644 index a9298b1cf2..0000000000 --- a/tests/script/unique/vnode/many.sim +++ /dev/null @@ -1,147 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c 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 numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/exec.sh -n dnode1 -s start - -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 -endi - -print ========= step1 -sql create database db1 replica 2 -sql create database db2 replica 2 -sql create database db3 replica 2 -sql create database db4 replica 2 -sql create table db1.tb1 (ts timestamp, i int) -sql create table db2.tb2 (ts timestamp, i int) -sql create table db3.tb3 (ts timestamp, i int) -sql create table db4.tb4 (ts timestamp, i int) -sql insert into db1.tb1 values(now, 1) -sql insert into db2.tb2 values(now, 1) -sql insert into db3.tb3 values(now, 1) -sql insert into db4.tb4 values(now, 1) - -sql select count(*) from db1.tb1 -$lastRows1 = $rows -sql select count(*) from db2.tb2 -$lastRows2 = $rows -sql select count(*) from db3.tb3 -$lastRows3 = $rows -sql select count(*) from db4.tb4 -$lastRows4 = $rows - -print ======== step2 -run_back unique/vnode/back_insert_many.sim -sleep 3000 - -print ======== step3 - -$x = 0 -loop: - -print ======== step4 -system sh/exec.sh -n dnode3 -s stop -sleep 3000 -system sh/exec.sh -n dnode3 -s start -sleep 3000 - -print ======== step5 -system sh/exec.sh -n dnode2 -s stop -sleep 3000 -system sh/exec.sh -n dnode2 -s start -sleep 3000 - -print ======== step6 -sql select count(*) from db1.tb1 -print select count(*) from db1.tb1 ==> $data00 $lastRows1 -if $data00 <= $lastRows1 then - return -1 -endi -$lastRows1 = $data00 - -sql select count(*) from db2.tb2 -print select count(*) from db2.tb2 ==> $data00 $lastRows2 -if $data00 <= $lastRows2 then - return -1 -endi -$lastRows2 = $data00 - -sql select count(*) from db3.tb3 -print select count(*) from db3.tb3 ==> $data00 $lastRows3 -if $data00 <= $lastRows3 then - return -1 -endi -$lastRows3 = $data00 - -sql select count(*) from db4.tb4 -print select count(*) from db4.tb4 ==> $data00 $lastRows4 -if $data00 <= $lastRows4 then - return -1 -endi -$lastRows4 = $data00 - -print ======== step7 - -print ======== loop Times $x - -if $x < 2 then - $x = $x + 1 - goto loop -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_a_large.sim b/tests/script/unique/vnode/replica2_a_large.sim deleted file mode 100644 index 6f31803845..0000000000 --- a/tests/script/unique/vnode/replica2_a_large.sim +++ /dev/null @@ -1,103 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c 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 numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode1 -c debugFlag -v 131 -system sh/cfg.sh -n dnode2 -c debugFlag -v 131 -system sh/cfg.sh -n dnode3 -c debugFlag -v 131 -system sh/cfg.sh -n dnode4 -c debugFlag -v 131 -system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator -system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator -system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator -system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator - -print ============== step0: start tarbitrator -system sh/exec_tarbitrator.sh -s start - -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect - -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -t -system sh/exec.sh -n dnode3 -s start -t -sleep 2000 - -print ========= step1 -sql create database db replica 2 -#sql create table db.tb1 (ts timestamp, i int) -#sql create table db.tb2 (ts timestamp, i int) -#sql create table db.tb3 (ts timestamp, i int) -#sql create table db.tb4 (ts timestamp, i int) -#sql insert into db.tb1 values(now, 1) -#sql select count(*) from db.tb1 - -sql create database db replica 2 -sql create table db.tb (ts timestamp, i int) -sql insert into db.tb values(now, 1) -sql select count(*) from db.tb -$lastRows = $rows - -print ======== step2 -#run_back unique/vnode/back_insert_many.sim -run_back unique/vnode/back_insert.sim -sleep 2000 - -print ======== step3 - -$x = 0 -loop: - -print ======== step4 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 10000 -system sh/exec.sh -n dnode2 -s start -t -sleep 10000 - -print ======== step5 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 10000 -system sh/exec.sh -n dnode3 -s start -t -sleep 10000 - -print ======== step6 -#sql select count(*) from db.tb1 -#print select count(*) from db.tb1 ==> $data00 $lastRows -sql select count(*) from db.tb -print select count(*) from db.tb ==> $data00 $lastRows -if $data00 <= $lastRows then - return -1 -endi - -print ======== step7 -$lastRows = $data00 -print ======== loop Times $x - -if $x < 10 then - $x = $x + 1 - goto loop -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim deleted file mode 100644 index c081f878dd..0000000000 --- a/tests/script/unique/vnode/replica2_basic2.sim +++ /dev/null @@ -1,223 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 - -system sh/cfg.sh -n dnode1 -c 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 numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 - -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 - -print ========= start dnodes -system sh/exec.sh -n dnode1 -s start -sleep 2000 -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -sleep 2000 - -sql reset query cache - -print ========= step1 -sql create database d1 replica 2 -sql create database d2 replica 2 -sql create database d3 replica 2 -sql create database d4 replica 2 - -sql create table d1.t1 (ts timestamp, i int) -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 select * from d1.t1 -if $rows != 1 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 1 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 1 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 1 then - return -1 -endi - -sql show dnodes -print dnode1 ==> openVnodes: $data2_1 -print dnode2 ==> openVnodes: $data2_2 -print dnode3 ==> openVnodes: $data2_3 - -if $data2_1 != 0 then - return -1 -endi - -if $data2_2 != 4 then - return -1 -endi - -if $data2_3 != 4 then - return -1 -endi - -if $data4_1 != ready then - print dnode1 status should ready but is $data4_1 - return -1 -endi - -if $data4_2 != ready then - return -1 -endi - -if $data4_3 != ready then - return -1 -endi - -print ========= step2 -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 select * from d1.t1 -if $rows != 2 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 2 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 2 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 2 then - return -1 -endi - -print ========= step3 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -#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 select * from d1.t1 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d2.t2 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d3.t3 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d4.t4 -#if $rows != 2 then -# return -1 -#endi - -print ========= step4 -system sh/exec.sh -n dnode2 -s start -sleep 3000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -#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 select * from d1.t1 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d2.t2 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d3.t3 -#if $rows != 2 then -# return -1 -#endi - -#sql select * from d4.t4 -#if $rows != 2 then -# return -1 -#endi - -print ========= step5 -system sh/exec.sh -n dnode3 -s start -sleep 3000 - -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 select * from d1.t1 -if $rows != 3 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 3 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 3 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 3 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim deleted file mode 100644 index ac68d59164..0000000000 --- a/tests/script/unique/vnode/replica2_repeat.sim +++ /dev/null @@ -1,110 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c 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 numOfMnodes -v 1 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 -system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/exec.sh -n dnode1 -s start - -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 -print dnode4 $data4_4 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 -endi - -print ========= step1 -sql create database db replica 2 -sql create table db.tb (ts timestamp, i int) -sql insert into db.tb values(now, 1) -sql select count(*) from db.tb -$lastRows = $rows - -print ======== step2 -run_back unique/vnode/back_insert.sim -sleep 2000 - -print ======== step3 - -$x = 0 -loop: - -print ======== step4 -system sh/exec.sh -n dnode2 -s stop -sleep 3000 -system sh/exec.sh -n dnode2 -s start -sleep 3000 - -print ======== step5 -system sh/exec.sh -n dnode3 -s stop -sleep 3000 -system sh/exec.sh -n dnode3 -s start -sleep 3000 - -print ======== step6 -sql select count(*) from db.tb -print select count(*) from db.tb ==> $data00 $lastRows -if $data00 <= $lastRows then - return -1 -endi - -print ======== step7 -$lastRows = $data00 -print ======== loop Times $x - -if $x < 2 then - $x = $x + 1 - goto loop -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_basic.sim b/tests/script/unique/vnode/replica3_basic.sim deleted file mode 100644 index 0ff42b523b..0000000000 --- a/tests/script/unique/vnode/replica3_basic.sim +++ /dev/null @@ -1,233 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/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 dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 - -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step1: - $x = $x + 1 - sleep 1000 - if $x == 10 then - return -1 - endi - -sql show dnodes -print dnode1 $data4_1 -print dnode2 $data4_2 -print dnode3 $data4_3 - -if $data4_1 != ready then - goto step1 -endi -if $data4_2 != ready then - goto step1 -endi -if $data4_3 != ready then - goto step1 -endi - -sql show mnodes -print mnode1 $data2_1 -print mnode1 $data2_2 -print mnode1 $data2_3 -if $data2_1 != master then - goto step1 -endi -if $data2_2 != slave then - goto step1 -endi -if $data2_3 != slave then - goto step1 -endi - -$N = 10 -$table = table_r3 -$db = db1 - -print =================== step 1 - -sql create database $db replica 3 -sql use $db -sql create table $table (ts timestamp, speed int) -sleep 3001 - -print =================== step 2 -$x = 1 -$y = $x + $N -$expect = $N -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 3 -system sh/exec.sh -n dnode2 -s stop -sleep 2000 -$y = $x + $N -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 4 -system sh/exec.sh -n dnode2 -s start - -$x = 0 -step4: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show db1.vgroups -print online vnodes $data03 -if $data03 != 3 then - goto step4 -endi - -$y = $x + $N -$expect = $N * 3 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 5 -system sh/exec.sh -n dnode3 -s stop -$y = $x + $N -$expect = $N * 4 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -print =================== step 6 -system sh/exec.sh -n dnode3 -s start - -$x = 0 -step6: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show db1.vgroups -print online vnodes $data03 -if $data03 != 3 then - goto step6 -endi - -$y = $x + $N -$expect = $N * 5 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , $x ) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 7 -system sh/exec.sh -n dnode1 -s stop -$y = $x + $N -$expect = $N * 6 -while $x < $y -$ms = $x . m -sql insert into $table values (now + $ms , 10) -$x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then -return -1 -endi - -print =================== step 8 -system sh/exec.sh -n dnode1 -s start - -$x = 0 -step8: - $x = $x + 1 - sleep 1000 - if $x == 40 then - return -1 - endi - -sql show db1.vgroups -print online vnodes $data03 -if $data03 != 3 then - goto step8 -endi - -$y = $x + $N -$expect = $N * 7 -while $x < $y - $ms = $x . m - sql insert into $table values (now + $ms , 10) - $x = $x + 1 -endw - -sql select * from $table -print sql select * from $table -> $rows points -if $rows != $expect then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim deleted file mode 100644 index de4c48eca5..0000000000 --- a/tests/script/unique/vnode/replica3_vgroup.sim +++ /dev/null @@ -1,71 +0,0 @@ -system sh/stop_dnodes.sh - -system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 -system sh/deploy.sh -n dnode3 -i 3 -system sh/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 dnode1 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 -system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 - -system sh/exec.sh -n dnode1 -s start -sql connect -sql create dnode $hostname2 -sql create dnode $hostname3 -system sh/exec.sh -n dnode2 -s start -system sh/exec.sh -n dnode3 -s start -sleep 2000 - -$N = 10 -$table = table_r3 -$db = db1 - -sleep 2000 - -print =================== step 1 - -sql create database $db replica 3 -sql use $db -sql create table st (ts timestamp, speed int) tags (t1 int) -sleep 3001 - - -$tbPre = m -$N = 300 -$x = 0 -$y = $x + $N -while $x < $y - $table = $tbPre . $x - sql create table $table using st tags ( $x ) - $ms = $x . m - sql insert into $table values (now + $ms , $x ) - $x = $x + 1 -endw - - -#print =================== step 2 -$x = -500 -$y = $x + $N -while $x < $y - $ms = $x . m - sql insert into $table values (now $ms , $x ) - $x = $x + 1 -endw - -$expect = $N + 1 -sql select * from $table -print sql select * from $table -> $rows points expect $expect -if $rows != $expect then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/testSuite.sim b/tests/script/unique/vnode/testSuite.sim deleted file mode 100644 index 3a9db66beb..0000000000 --- a/tests/script/unique/vnode/testSuite.sim +++ /dev/null @@ -1,6 +0,0 @@ -run unique/vnode/many.sim -run unique/vnode/replica2_basic2.sim -run unique/vnode/replica2_repeat.sim -run unique/vnode/replica3_basic.sim -run unique/vnode/replica3_repeat.sim -run unique/vnode/replica3_vgroup.sim diff --git a/tests/script/windows/alter/metrics.sim b/tests/script/windows/alter/metrics.sim deleted file mode 100644 index 7dfda05bd0..0000000000 --- a/tests/script/windows/alter/metrics.sim +++ /dev/null @@ -1,769 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -print ======== step1 -sql create database d2 -sql use d2 -sql create table mt (ts timestamp, a int) TAGS (t int) -sql create table tb using mt tags (1) -sql insert into tb values(now-28d, -28) -sql insert into tb values(now-27d, -27) -sql insert into tb values(now-26d, -26) -sql select * from tb -if $rows != 3 then - return -1 -endi -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != t then - return -1 -endi -if $data21 != INT then - return -1 -endi - -print ======== step2 -sql alter table mt add column b smallint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != t then - return -1 -endi -if $data31 != INT then - return -1 -endi - -print ======== step3 -sql alter table mt add column c tinyint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != t then - return -1 -endi -if $data41 != INT then - return -1 -endi - -print ======== step4 -sql alter table mt add column d int -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != t then - return -1 -endi -if $data51 != INT then - return -1 -endi - -print ======== step5 -sql alter table mt add column e bigint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != t then - return -1 -endi -if $data61 != INT then - return -1 -endi - -print ======== step6 -sql alter table mt add column f float -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != t then - return -1 -endi -if $data71 != INT then - return -1 -endi - -print ======== step7 -sql alter table mt add column g double -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi -if $data80 != t then - return -1 -endi -if $data81 != INT then - return -1 -endi - -print ======== step8 -sql alter table mt add column h binary(10) -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi -if $data80 != h then - return -1 -endi -if $data81 != BINARY then - return -1 -endi -if $data82 != 10 then - return -1 -endi -if $data90 != t then - return -1 -endi -if $data91 != INT then - return -1 -endi - -print ======== step9 -print ======== step10 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 -system sh/exec.sh -n dnode1 -s start -sleep 3000 - -sql use d2 -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi -if $data80 != h then - return -1 -endi -if $data81 != BINARY then - return -1 -endi -if $data82 != 10 then - return -1 -endi -if $data90 != t then - return -1 -endi -if $data91 != INT then - return -1 -endi - -print ======== step11 -#sql alter table mt drop column a -x step111 -# return -1 -#step111: - -#sql alter table mt drop column ts -x step112 -# return -1 -#step112: - -#sql alter table mt drop column cdfg -x step113 -# return -1 -#step113: - -#sql alter table mt add column a -x step114 -# return -1 -#step114: - -#sql alter table mt add column b -x step115 -# return -1 -#step115: - -print ======== step12 -sql alter table mt drop column b -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != c then - return -1 -endi -if $data21 != TINYINT then - return -1 -endi -if $data30 != d then - return -1 -endi -if $data31 != INT then - return -1 -endi -if $data40 != e then - return -1 -endi -if $data41 != BIGINT then - return -1 -endi -if $data50 != f then - return -1 -endi -if $data51 != FLOAT then - return -1 -endi -if $data60 != g then - return -1 -endi -if $data61 != DOUBLE then - return -1 -endi -if $data70 != h then - return -1 -endi -if $data71 != BINARY then - return -1 -endi -if $data72 != 10 then - return -1 -endi -if $data80 != t then - return -1 -endi -if $data81 != INT then - return -1 -endi - -print ======== step13 -sql alter table mt drop column c -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != d then - return -1 -endi -if $data21 != INT then - return -1 -endi -if $data30 != e then - return -1 -endi -if $data31 != BIGINT then - return -1 -endi -if $data40 != f then - return -1 -endi -if $data41 != FLOAT then - return -1 -endi -if $data50 != g then - return -1 -endi -if $data51 != DOUBLE then - return -1 -endi -if $data60 != h then - return -1 -endi -if $data61 != BINARY then - return -1 -endi -if $data62 != 10 then - return -1 -endi -if $data70 != t then - return -1 -endi -if $data71 != INT then - return -1 -endi - -print ======== step14 -sql alter table mt drop column d -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != e then - return -1 -endi -if $data21 != BIGINT then - return -1 -endi -if $data30 != f then - return -1 -endi -if $data31 != FLOAT then - return -1 -endi -if $data40 != g then - return -1 -endi -if $data41 != DOUBLE then - return -1 -endi -if $data50 != h then - return -1 -endi -if $data51 != BINARY then - return -1 -endi -if $data52 != 10 then - return -1 -endi -if $data60 != t then - return -1 -endi -if $data61 != INT then - return -1 -endi - -print ======== step15 -sql alter table mt drop column e -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != f then - return -1 -endi -if $data21 != FLOAT then - return -1 -endi -if $data30 != g then - return -1 -endi -if $data31 != DOUBLE then - return -1 -endi -if $data40 != h then - return -1 -endi -if $data41 != BINARY then - return -1 -endi -if $data42 != 10 then - return -1 -endi -if $data50 != t then - return -1 -endi -if $data51 != INT then - return -1 -endi - -print ======== step16 -sql alter table mt drop column f -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != g then - return -1 -endi -if $data21 != DOUBLE then - return -1 -endi -if $data30 != h then - return -1 -endi -if $data31 != BINARY then - return -1 -endi -if $data32 != 10 then - return -1 -endi -if $data40 != t then - return -1 -endi -if $data41 != INT then - return -1 -endi - -print ======== step17 -sql alter table mt drop column g -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != h then - return -1 -endi -if $data21 != BINARY then - return -1 -endi -if $data22 != 10 then - return -1 -endi -if $data30 != t then - return -1 -endi -if $data31 != INT then - return -1 -endi - -print ============= step18 -sql alter table mt drop column h -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != t then - return -1 -endi -if $data21 != INT then - return -1 -endi -if $data30 != null then - return -1 -endi - -print ======= over -sql drop database d2 -sql show databases -if $rows != 0 then - return -1 -endi - diff --git a/tests/script/windows/alter/table.sim b/tests/script/windows/alter/table.sim deleted file mode 100644 index 52757da20e..0000000000 --- a/tests/script/windows/alter/table.sim +++ /dev/null @@ -1,672 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -print ======== step1 -sql create database d1 -sql use d1 -sql create table tb (ts timestamp, a int) -sql insert into tb values(now-28d, -28) -sql insert into tb values(now-27d, -27) -sql insert into tb values(now-26d, -26) -sql select * from tb -if $rows != 3 then - return -1 -endi -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi - -print ======== step2 -sql alter table tb add column b smallint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi - -print ======== step3 -sql alter table tb add column c tinyint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi - -print ======== step4 -sql alter table tb add column d int -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi - -print ======== step5 -sql alter table tb add column e bigint -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi - -print ======== step6 -sql alter table tb add column f float -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi - -print ======== step7 -sql alter table tb add column g double -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi - -print ======== step8 -sql alter table tb add column h binary(10) -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi -if $data80 != h then - return -1 -endi -if $data81 != BINARY then - return -1 -endi -if $data82 != 10 then - return -1 -endi - -print ======== step9 -print ======== step10 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 -system sh/exec.sh -n dnode1 -s start -sleep 3000 - -sql use d1 -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != b then - return -1 -endi -if $data21 != SMALLINT then - return -1 -endi -if $data30 != c then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data40 != d then - return -1 -endi -if $data41 != INT then - return -1 -endi -if $data50 != e then - return -1 -endi -if $data51 != BIGINT then - return -1 -endi -if $data60 != f then - return -1 -endi -if $data61 != FLOAT then - return -1 -endi -if $data70 != g then - return -1 -endi -if $data71 != DOUBLE then - return -1 -endi -if $data80 != h then - return -1 -endi -if $data81 != BINARY then - return -1 -endi -if $data82 != 10 then - return -1 -endi - -print ======== step11 -sql alter table drop column a -x step111 - return -1 -step111: - -sql alter table drop column ts -x step112 - return -1 -step112: - -sql alter table drop column cdfg -x step113 - return -1 -step113: - -sql alter table add column a -x step114 - return -1 -step114: - -sql alter table add column b -x step115 - return -1 -step115: - -print ======== step12 -sql alter table tb drop column b -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != c then - return -1 -endi -if $data21 != TINYINT then - return -1 -endi -if $data30 != d then - return -1 -endi -if $data31 != INT then - return -1 -endi -if $data40 != e then - return -1 -endi -if $data41 != BIGINT then - return -1 -endi -if $data50 != f then - return -1 -endi -if $data51 != FLOAT then - return -1 -endi -if $data60 != g then - return -1 -endi -if $data61 != DOUBLE then - return -1 -endi -if $data70 != h then - return -1 -endi -if $data71 != BINARY then - return -1 -endi -if $data72 != 10 then - return -1 -endi - -print ======== step13 -sql alter table tb drop column c -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != d then - return -1 -endi -if $data21 != INT then - return -1 -endi -if $data30 != e then - return -1 -endi -if $data31 != BIGINT then - return -1 -endi -if $data40 != f then - return -1 -endi -if $data41 != FLOAT then - return -1 -endi -if $data50 != g then - return -1 -endi -if $data51 != DOUBLE then - return -1 -endi -if $data60 != h then - return -1 -endi -if $data61 != BINARY then - return -1 -endi -if $data62 != 10 then - return -1 -endi - -print ======== step14 -sql alter table tb drop column d -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != e then - return -1 -endi -if $data21 != BIGINT then - return -1 -endi -if $data30 != f then - return -1 -endi -if $data31 != FLOAT then - return -1 -endi -if $data40 != g then - return -1 -endi -if $data41 != DOUBLE then - return -1 -endi -if $data50 != h then - return -1 -endi -if $data51 != BINARY then - return -1 -endi -if $data52 != 10 then - return -1 -endi - -print ======== step15 -sql alter table tb drop column e -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != f then - return -1 -endi -if $data21 != FLOAT then - return -1 -endi -if $data30 != g then - return -1 -endi -if $data31 != DOUBLE then - return -1 -endi -if $data40 != h then - return -1 -endi -if $data41 != BINARY then - return -1 -endi -if $data42 != 10 then - return -1 -endi - -print ======== step16 -sql alter table tb drop column f -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != g then - return -1 -endi -if $data21 != DOUBLE then - return -1 -endi -if $data30 != h then - return -1 -endi -if $data31 != BINARY then - return -1 -endi -if $data32 != 10 then - return -1 -endi - -print ======== step17 -sql alter table tb drop column g -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != h then - return -1 -endi -if $data21 != BINARY then - return -1 -endi -if $data22 != 10 then - return -1 -endi - -print ============= step18 -sql alter table tb drop column h -sql describe tb -if $data00 != ts then - return -1 -endi -if $data01 != TIMESTAMP then - return -1 -endi -if $data10 != a then - return -1 -endi -if $data11 != INT then - return -1 -endi -if $data20 != null then - return -1 -endi - -print ======= over -sql drop database d1 -sql show databases -if $rows != 0 then - return -1 -endi - diff --git a/tests/script/windows/compute/avg.sim b/tests/script/windows/compute/avg.sim deleted file mode 100644 index 7445808db5..0000000000 --- a/tests/script/windows/compute/avg.sim +++ /dev/null @@ -1,158 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_av_db -$tbPrefix = m_av_tb -$mtPrefix = m_av_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select avg(tbcol) from $tb -print ===> $data00 -if $data00 != 9.500000000 then - return -1 -endi - -print =============== step3 -sql select avg(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -print =============== step4 -sql select avg(tbcol) as b from $tb -print ===> $data00 -if $data00 != 9.500000000 then - return -1 -endi - -print =============== step5 -sql select avg(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data11 != 1.000000000 then - return -1 -endi - -sql select avg(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 9.500000000 then - return -1 -endi - -print =============== step6 -sql select avg(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data41 != 4.000000000 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select avg(tbcol) from $mt -print ===> $data00 -if $data00 != 9.500000000 then - return -1 -endi - -print =============== step8 -sql select avg(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select avg(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 9.500000000 then - return -1 -endi - -sql select avg(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -print =============== step9 -sql select avg(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1.000000000 then - return -1 -endi - -sql select avg(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 9.500000000 then - return -1 -endi - -print =============== step10 -sql select avg(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 9.500000000 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select avg(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1.000000000 then - return -1 -endi -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/bottom.sim b/tests/script/windows/compute/bottom.sim deleted file mode 100644 index 18f6c0bd09..0000000000 --- a/tests/script/windows/compute/bottom.sim +++ /dev/null @@ -1,99 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_bo_db -$tbPrefix = m_bo_tb -$mtPrefix = m_bo_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select bottom(tbcol, 1) from $tb -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step3 -sql select bottom(tbcol, 1) from $tb where ts > now + 4m -print ===> $data01 -if $data01 != 5 then - return -1 -endi - -print =============== step4 -sql select bottom(tbcol, 1) as b from $tb -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step5 -sql select bottom(tbcol, 2) as b from $tb -print ===> $data01 $data11 -if $data01 != 0 then - return -1 -endi -if $data11 != 1 then - return -1 -endi - -print =============== step6 -sql select bottom(tbcol, 2) as b from $tb where ts > now + 4m -print ===> $data01 $data11 -if $data01 != 5 then - return -1 -endi -if $data11 != 6 then - return -1 -endi - -sql select bottom(tbcol, 122) as b from $tb -x step6 - return -1 -step6: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/count.sim b/tests/script/windows/compute/count.sim deleted file mode 100644 index 227b49a8bd..0000000000 --- a/tests/script/windows/compute/count.sim +++ /dev/null @@ -1,174 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_co_db -$tbPrefix = m_co_tb -$mtPrefix = m_co_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - - -sql select count(*) from $tb -print ===> select count(*) from $tb => $data00 -if $data00 != $rowNum then - return -1 -endi - -sql select count(tbcol) from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step3 -sql select count(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol) as b from $tb -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -print =============== step5 -sql select count(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi - -sql select count(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != $rowNum then - return -1 -endi - -print =============== step6 -sql select count(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select count(*) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -sql select count(tbcol) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi - -print =============== step8 -sql select count(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 25 then - return -1 -endi - -print =============== step9 -sql select count(tbcol) as b from $mt interval(1m) -print ===> $data01 -if $data01 != 10 then - return -1 -endi -if $data11 != 10 then - return -1 -endi - -sql select count(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 200 then - return -1 -endi - -print =============== step10 -sql select count(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != $rowNum then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select count(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data01 -if $data01 != 1 then - return -1 -endi -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/diff.sim b/tests/script/windows/compute/diff.sim deleted file mode 100644 index bdc5a0e3d8..0000000000 --- a/tests/script/windows/compute/diff.sim +++ /dev/null @@ -1,91 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_di_db -$tbPrefix = m_di_tb -$mtPrefix = m_di_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select diff(tbcol) from $tb -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -print =============== step3 -sql select diff(tbcol) from $tb where ts > now + 4m -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select diff(tbcol) from $tb where ts < now + 4m -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -print =============== step4 -sql select diff(tbcol) as b from $tb -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -print =============== step5 -sql select diff(tbcol) as b from $tb interval(1m) -x step5 - return -1 -step5: - -print =============== step6 -sql select diff(tbcol) as b from $tb where ts < now + 4m interval(1m) -x step6 - return -1 -step6: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/first.sim b/tests/script/windows/compute/first.sim deleted file mode 100644 index a83939c2a6..0000000000 --- a/tests/script/windows/compute/first.sim +++ /dev/null @@ -1,160 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_fi_db -$tbPrefix = m_fi_tb -$mtPrefix = m_fi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select first(tbcol) from $tb -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step3 -sql select first(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step4 -sql select first(tbcol) as b from $tb -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step5 -sql select first(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -sql select first(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step6 -sql select first(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data41 != 4 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select first(tbcol) from $mt -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step8 -sql select first(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -sql select first(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -sql select first(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step9 -sql select first(tbcol) as b from $mt interval(1m) -print select first(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select first(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step10 -sql select first(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select first(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then - return -1 -endi -print ===> $rows -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/interval.sim b/tests/script/windows/compute/interval.sim deleted file mode 100644 index feacce1606..0000000000 --- a/tests/script/windows/compute/interval.sim +++ /dev/null @@ -1,176 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_in_db -$tbPrefix = m_in_tb -$mtPrefix = m_in_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) -print ===> $rows -if $rows < $rowNum then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data05 != 1 then - return -1 -endi - -print =============== step3 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now + 4m interval(1m) -print ===> $rows -if $rows > 10 then - return -1 -endi -if $rows < 3 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data05 != 1 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now-1m interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data05 != 1 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now+1m interval(1m) fill(value,0) -print ===> $rows -if $rows < 30 then - return -1 -endi -if $rows > 50 then - return -1 -endi -if $data21 != 1 then - return -1 -endi -if $data25 != 1 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1m) -print ===> $rows -if $rows < 3 then - return -1 -endi -if $rows > 7 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now-1m interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now+1m interval(1m) fill(value, 0) -if $rows < 30 then - return -1 -endi -if $rows > 50 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/last.sim b/tests/script/windows/compute/last.sim deleted file mode 100644 index 379a5ae64a..0000000000 --- a/tests/script/windows/compute/last.sim +++ /dev/null @@ -1,159 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_la_db -$tbPrefix = m_la_tb -$mtPrefix = m_la_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select last(tbcol) from $tb -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step3 -sql select last(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -print =============== step4 -sql select last(tbcol) as b from $tb -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step5 -sql select last(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select last(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step6 -sql select last(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select last(tbcol) from $mt -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step8 -sql select last(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -sql select last(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -sql select last(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -print =============== step9 -sql select last(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select last(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step10 -sql select last(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select last(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then - return -1 -endi -print ===> $rows -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/leastsquare.sim b/tests/script/windows/compute/leastsquare.sim deleted file mode 100644 index 20353a409e..0000000000 --- a/tests/script/windows/compute/leastsquare.sim +++ /dev/null @@ -1,102 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_le_db -$tbPrefix = m_le_tb -$mtPrefix = m_le_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db keep 36500 -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 2 - $ms = 1000 - while $x < $rowNum - $ms = $ms + 1000 - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select leastsquares(tbcol, 1, 1) from $tb -print ===> $data00 -if $data00 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi - -print =============== step3 -sql select leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi - -print =============== step4 -sql select leastsquares(tbcol, 1, 1) as b from $tb -print ===> $data00 -if $data00 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi - -print =============== step5 -print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) -sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi - -print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) -sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi - -print =============== step6 -sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data01 != @{slop:1.000000, intercept:1.000000}@ then - return -1 -endi -print ===> $rows -if $rows != 1 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/compute/max.sim b/tests/script/windows/compute/max.sim deleted file mode 100644 index 641b31fe36..0000000000 --- a/tests/script/windows/compute/max.sim +++ /dev/null @@ -1,159 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_ma_db -$tbPrefix = m_ma_tb -$mtPrefix = m_ma_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select max(tbcol) from $tb -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step3 -sql select max(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -print =============== step4 -sql select max(tbcol) as b from $tb -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step5 -sql select max(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select max(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step6 -sql select max(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select max(tbcol) from $mt -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -print =============== step8 -sql select max(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -sql select max(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -sql select max(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 4 then - return -1 -endi - -print =============== step9 -sql select max(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select max(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step10 -sql select max(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 19 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select max(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then - return -1 -endi -print ===> $rows -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/min.sim b/tests/script/windows/compute/min.sim deleted file mode 100644 index 3528f573ce..0000000000 --- a/tests/script/windows/compute/min.sim +++ /dev/null @@ -1,159 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mi_db -$tbPrefix = m_mi_tb -$mtPrefix = m_mi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select min(tbcol) from $tb -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step3 -sql select min(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step4 -sql select min(tbcol) as b from $tb -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step5 -sql select min(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select min(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step6 -sql select min(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select min(tbcol) from $mt -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step8 -sql select min(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -sql select min(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -sql select min(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -print =============== step9 -sql select min(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select min(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 0 then - return -1 -endi - -print =============== step10 -sql select min(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 0 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select min(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol -print ===> $data11 -if $data11 != 1 then - return -1 -endi -print ===> $rows -if $rows != 50 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/percentile.sim b/tests/script/windows/compute/percentile.sim deleted file mode 100644 index fa6212f013..0000000000 --- a/tests/script/windows/compute/percentile.sim +++ /dev/null @@ -1,116 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_pe_db -$tbPrefix = m_pe_tb -$mtPrefix = m_pe_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select percentile(tbcol, 10) from $tb -print ===> $data00 -if $data00 != 1.900000000 then - return -1 -endi - -sql select percentile(tbcol, 20) from $tb -print ===> $data00 -if $data00 != 3.800000000 then - return -1 -endi - -sql select percentile(tbcol, 100) from $tb -print ===> $data00 -if $data00 != 19.000000000 then - return -1 -endi - -sql select percentile(tbcol, 110) from $tb -x step2 - return -1 -step2: - -print =============== step3 -sql select percentile(tbcol, 1) from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.140000000 then - return -1 -endi - -sql select percentile(tbcol, 5) from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.700000000 then - return -1 -endi - -sql select percentile(tbcol, 0) from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -print =============== step4 -sql select percentile(tbcol, 1) as c from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.140000000 then - return -1 -endi - -sql select percentile(tbcol, 5) as c from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.700000000 then - return -1 -endi - -sql select percentile(tbcol, 0) as c from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/stddev.sim b/tests/script/windows/compute/stddev.sim deleted file mode 100644 index eea6c8aa05..0000000000 --- a/tests/script/windows/compute/stddev.sim +++ /dev/null @@ -1,98 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_st_db -$tbPrefix = m_st_tb -$mtPrefix = m_st_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select stddev(tbcol) from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step3 -sql select stddev(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 1.414213562 then - return -1 -endi - -print =============== step4 -sql select stddev(tbcol) as b from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step5 -sql select stddev(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - return -1 -endi - -sql select stddev(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 5.766281297 then - return -1 -endi - -print =============== step6 -sql select stddev(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/sum.sim b/tests/script/windows/compute/sum.sim deleted file mode 100644 index a429ce99e0..0000000000 --- a/tests/script/windows/compute/sum.sim +++ /dev/null @@ -1,159 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_su_db -$tbPrefix = m_su_tb -$mtPrefix = m_su_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select sum(tbcol) from $tb -print ===> $data00 -if $data00 != 190 then - return -1 -endi - -print =============== step3 -sql select sum(tbcol) from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 10 then - return -1 -endi - -print =============== step4 -sql select sum(tbcol) as b from $tb -print ===> $data00 -if $data00 != 190 then - return -1 -endi - -print =============== step5 -sql select sum(tbcol) as b from $tb interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi - -sql select sum(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 190 then - return -1 -endi - -print =============== step6 -sql select sum(tbcol) as b from $tb where ts < now + 4m interval(1m) -print ===> $data11 -if $data11 != 1 then - return -1 -endi -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select sum(tbcol) from $mt -print ===> $data00 -if $data00 != 1900 then - return -1 -endi - -print =============== step8 -sql select sum(tbcol) as c from $mt where ts < now + 4m -print ===> $data00 -if $data00 != 100 then - return -1 -endi - -sql select sum(tbcol) as c from $mt where tgcol < 5 -print ===> $data00 -if $data00 != 950 then - return -1 -endi - -sql select sum(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m -print ===> $data00 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select sum(tbcol) as b from $mt interval(1m) -print ===> $data11 -if $data11 < 5 then - return -1 -endi - -sql select sum(tbcol) as b from $mt interval(1d) -print ===> $data01 -if $data01 != 1900 then - return -1 -endi - -print =============== step10 -sql select sum(tbcol) as b from $mt group by tgcol -print ===> $data00 -if $data00 != 190 then - return -1 -endi - -if $rows != $tbNum then - return -1 -endi - -print =============== step11 -sql select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol -print select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol -print ===> $data01 -if $data01 != 10 then - return -1 -endi -if $rows != 10 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/compute/top.sim b/tests/script/windows/compute/top.sim deleted file mode 100644 index 65e448b0fa..0000000000 --- a/tests/script/windows/compute/top.sim +++ /dev/null @@ -1,99 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_to_db -$tbPrefix = m_to_tb -$mtPrefix = m_to_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select top(tbcol, 1) from $tb -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step3 -sql select top(tbcol, 1) from $tb where ts < now + 4m -print ===> $data01 -if $data01 != 4 then - return -1 -endi - -print =============== step4 -sql select top(tbcol, 1) as b from $tb -print ===> $data01 -if $data01 != 19 then - return -1 -endi - -print =============== step5 -sql select top(tbcol, 2) as b from $tb -print ===> $data01 $data11 -if $data01 != 18 then - return -1 -endi -if $data11 != 19 then - return -1 -endi - -print =============== step6 -sql select top(tbcol, 2) as b from $tb where ts < now + 4m -print ===> $data01 $data11 -if $data01 != 3 then - return -1 -endi -if $data11 != 4 then - return -1 -endi - -sql select top(tbcol, 122) as b from $tb -x step6 - return -1 -step6: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/db/basic.sim b/tests/script/windows/db/basic.sim deleted file mode 100644 index 1f0fc31a6b..0000000000 --- a/tests/script/windows/db/basic.sim +++ /dev/null @@ -1,193 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -print ============================ dnode1 start - -$i = 0 -$dbPrefix = ob_db_db -$tbPrefix = ob_db_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db replica 1 duration 20 keep 2000 cache 16 -sql show databases -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 -if $data00 != $db then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 0 then - return -1 -endi -if $data04 != 1 then - return -1 -endi -if $data06 != 20 then - return -1 -endi -if $data08 != 16 then - return -1 -endi - -print =============== step2 -sql create database $db -sql show databases -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step4 -sql_error drop database $db - -print =============== step5 -sql create database $db replica 1 duration 15 keep 1500 -sql show databases -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 -if $data00 != $db then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 0 then - return -1 -endi -if $data04 != 1 then - return -1 -endi -if $data06 != 15 then - return -1 -endi - -print =============== step6 -sql use $db -sql create table $tb (ts timestamp, speed int) -$i = 1 -while $i < 4 - $db = $dbPrefix . $i - $tb = $tbPrefix . $i - sql create database $db - sql use $db - sql create table $tb (ts timestamp, speed int) - $i = $i + 1 -endw - -sql show databases -if $rows != 4 then - return -1 -endi - -$i = 4 -$db = $dbPrefix . $i -$tb = $tbPrefix . $i -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed int) - -print =============== step7 -$i = 0 -while $i < 5 - $db = $dbPrefix . $i - sql drop database $db - $i = $i + 1 -endw - -print =============== step8 -$i = 0 -$db = $dbPrefix . $i -$tb = $tbPrefix . $i -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi - -print =============== step9 -sql drop database $db - -print =============== step10 -sql create database $db -sql use $db -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step11 -sql create table $tb (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi - -print =============== step12 -sql drop database $db - -print =============== step13 -sql create database $db -sql use $db -sql show tables -if $rows != 0 then - return -1 -endi -sql create table $tb (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi -sql insert into $tb values (now+1a, 0) -sql insert into $tb values (now+2a, 1) -sql insert into $tb values (now+3a, 2) -sql insert into $tb values (now+4a, 3) -sql insert into $tb values (now+5a, 4) -sql select * from $tb -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql drop database $db - -print =============== step15 -sql create database $db -sql use $db -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step16 -sql create table $tb (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi -sql select * from $tb -if $rows != 0 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/db/len.sim b/tests/script/windows/db/len.sim deleted file mode 100644 index 3356165117..0000000000 --- a/tests/script/windows/db/len.sim +++ /dev/null @@ -1,92 +0,0 @@ -sleep 2000 -sql connect - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -print =============== step1 -sql_error drop database dd - -sql create database -x step1 - return -1 -step1: - -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step2 -sql create database a -sql show databases -if $rows != 1 then - return -1 -endi - -sql drop database a -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql create database a12345678 -sql show databases -if $rows != 1 then - return -1 -endi - -sql drop database a12345678 -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step4 -sql create database a012345678901201234567890120123456789012a012345678901201234567890120123456789012 -x step4 - return -1 -step4: -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step5 -sql create database a;1 -sql drop database a -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step6 -sql create database a'1 -x step6 - return -1 -step6: - -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step7 -sql create database (a) -x step7 - return -1 -step7: -sql show databases -if $rows != 0 then - return -1 -endi - -print =============== step8 -sql create database a.1 -x step8 - return -1 -step8: -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/2.sim b/tests/script/windows/field/2.sim deleted file mode 100644 index e258fbe80e..0000000000 --- a/tests/script/windows/field/2.sim +++ /dev/null @@ -1,295 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_bt_db -$tbPrefix = fi_bt_tb -$mtPrefix = fi_bt_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol2 bool, tbcol int) TAGS(tgcol bool, tgcol2 int) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0, 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1, 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol order by tgcol desc -print $db -print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/3.sim b/tests/script/windows/field/3.sim deleted file mode 100644 index e3fe0b0b11..0000000000 --- a/tests/script/windows/field/3.sim +++ /dev/null @@ -1,521 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_3_db -$tbPrefix = fi_3_tb -$mtPrefix = fi_3_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 int, tbcol3 float) TAGS(tgcol1 smallint, tgcol2 int, tgcol3 float) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0, 0, 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1, 1, 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tbcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step14 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step15 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step16 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step17 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step18 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step19 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/4.sim b/tests/script/windows/field/4.sim deleted file mode 100644 index aabfe2be2c..0000000000 --- a/tests/script/windows/field/4.sim +++ /dev/null @@ -1,711 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_4_db -$tbPrefix = fi_4_tb -$mtPrefix = fi_4_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 float, tbcol4 double) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0, 0, 0, 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1, 1, 1, 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tbcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tbcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step19 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step20 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step21 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step22 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step23 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step24 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/5.sim b/tests/script/windows/field/5.sim deleted file mode 100644 index 874730ff1c..0000000000 --- a/tests/script/windows/field/5.sim +++ /dev/null @@ -1,834 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_5_db -$tbPrefix = fi_5_tb -$mtPrefix = fi_5_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol1 tinyint, tbcol2 int, tbcol3 bigint, tbcol4 double, tbcol5 smallint) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 smallint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tbcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tbcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where tbcol5 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tbcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step19 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step20 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step21 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step22 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step23 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step24 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step25 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step26 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step27 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/6.sim b/tests/script/windows/field/6.sim deleted file mode 100644 index 77277df35b..0000000000 --- a/tests/script/windows/field/6.sim +++ /dev/null @@ -1,989 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_6_db -$tbPrefix = fi_6_tb -$mtPrefix = fi_6_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 smallint, tbcol4 bigint, tbcol5 float, tbcol6 bool) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 float, tgcol6 bool) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0, 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0, 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1, 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1, 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tbcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tbcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tbcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where tbcol5 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol5 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step8 -sql select * from $mt where tbcol6 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol6 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol6 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol6 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tbcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tbcol6 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol6 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol6 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol6 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step19 -sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol6 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol6 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol6 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step20 -sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step21 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step22 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step23 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step24 -sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 and tbcol6 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 and tbcol6 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step25 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step26 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step27 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step28 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol6 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step29 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step30 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step31 -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 interval(1d) group by tgcol6 order by tgcol6 desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/bigint.sim b/tests/script/windows/field/bigint.sim deleted file mode 100644 index f912ee968b..0000000000 --- a/tests/script/windows/field/bigint.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_bi_db -$tbPrefix = fi_bi_tb -$mtPrefix = fi_bi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol bigint) TAGS(tgcol bigint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/binary.sim b/tests/script/windows/field/binary.sim deleted file mode 100644 index aa641878e4..0000000000 --- a/tests/script/windows/field/binary.sim +++ /dev/null @@ -1,77 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_by_db -$tbPrefix = fi_by_tb -$mtPrefix = fi_by_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol binary(10)) TAGS(tgcol binary(10)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , '0' ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , '1' ) - $x = $x + 1 - endw - $i = $i + 1 -endw - - -print =============== step2 - -sql select * from $mt where tbcol = '0' -if $rows != 100 then - return -1 -endi - -sql select * from $mt where ts > now + 4m and tbcol = '1' -if $rows != 75 then - return -1 -endi - -print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' -sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol -sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol -sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol - -#can't filter binary fields - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/bool.sim b/tests/script/windows/field/bool.sim deleted file mode 100644 index 3ef56a1d95..0000000000 --- a/tests/script/windows/field/bool.sim +++ /dev/null @@ -1,161 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_bo_db -$tbPrefix = fi_bo_tb -$mtPrefix = fi_bo_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol bool) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> false -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> false and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = true group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc -print select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/double.sim b/tests/script/windows/field/double.sim deleted file mode 100644 index ef404d28dc..0000000000 --- a/tests/script/windows/field/double.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_do_db -$tbPrefix = fi_do_tb -$mtPrefix = fi_do_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol double) TAGS(tgcol double) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/float.sim b/tests/script/windows/field/float.sim deleted file mode 100644 index 8435f31c1f..0000000000 --- a/tests/script/windows/field/float.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_fl_db -$tbPrefix = fi_fl_tb -$mtPrefix = fi_fl_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol float) TAGS(tgcol float) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/int.sim b/tests/script/windows/field/int.sim deleted file mode 100644 index 781b939484..0000000000 --- a/tests/script/windows/field/int.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_in_db -$tbPrefix = fi_in_tb -$mtPrefix = fi_in_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/single.sim b/tests/script/windows/field/single.sim deleted file mode 100644 index b6b4402091..0000000000 --- a/tests/script/windows/field/single.sim +++ /dev/null @@ -1,218 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_si_db -$tbPrefix = fi_si_tb -$mtPrefix = fi_si_mt -$rowNum = 20 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql create database $db -sql use $db -sql create table $tb (ts timestamp, tbcol int) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - -print =============== step2 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi - -sql select * from $tb where tbcol = 10 -if $rows != 1 then - return -1 -endi -if $data01 != 10 then - return -1 -endi - -sql select * from $tb where tbcol = 8 -if $rows != 1 then - return -1 -endi -if $data01 != 8 then - return -1 -endi - -sql select * from $tb where tbcol < 10 -if $rows != 10 then - return -1 -endi -if $data91 != 9 then - return -1 -endi - -sql select * from $tb where tbcol <= 10 -if $rows != 11 then - return -1 -endi -if $data81 != 8 then - return -1 -endi - -sql select * from $tb where tbcol > 10 -if $rows != 9 then - return -1 -endi -if $data81 != 19 then - return -1 -endi - -sql select * from $tb where tbcol > 10 order by ts asc -if $rows != 9 then - return -1 -endi -if $data01 != 11 then - return -1 -endi - -sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts desc -if $rows != 4 then - return -1 -endi -if $data01 != 9 then - return -1 -endi -if $data31 != 6 then - return -1 -endi - -sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts asc -if $rows != 4 then - return -1 -endi -if $data01 != 6 then - return -1 -endi -if $data31 != 9 then - return -1 -endi - -sql select * from $tb where tbcol > 10 and tbcol < 5 order by ts asc -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi - -sql select * from $tb where tbcol = 10 and ts < now + 4m -print select * from $tb where tbcol = 10 and ts < now + 4m -if $rows != 0 then - return -1 -endi - -sql select * from $tb where tbcol = 4 and ts < now + 4m order by ts desc -if $rows != 1 then - return -1 -endi -if $data01 != 4 then - return -1 -endi - -sql select * from $tb where tbcol < 10 and ts < now + 4m order by ts desc -if $rows != 5 then - return -1 -endi -if $data01 != 4 then - return -1 -endi - -sql select * from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m order by ts desc -print $rows $data00 $data01 -if $rows != 1 then - return -1 -endi -if $data01 != 5 then - return -1 -endi - -print =============== step4 -sql select count(*) from $tb -if $data00 != $rowNum then - return -1 -endi - -sql select count(*) from $tb where tbcol = 10 -if $data00 != 1 then - return -1 -endi - -#sql select count(*) from $tb where tbcol = 8 or tbcol = 9 -#if $data00 != 2 then -# return -1 -#endi - -sql select count(*) from $tb where tbcol < 10 -if $data00 != 10 then - return -1 -endi - -sql select count(*) from $tb where tbcol <= 10 -if $data00 != 11 then - return -1 -endi - -sql select count(*) from $tb where tbcol < 10 and tbcol > 5 -if $data00 != 4 then - return -1 -endi - -sql select count(*) from $tb where tbcol < 10 and tbcol > 5 order by ts asc -x step4 -# return -1 -step4: - -print =============== step5 -sql select count(*) from $tb where ts < now + 4m -if $data00 != 5 then - return -1 -endi - -#sql select count(*) from $tb where tbcol = 10 and ts < now + 4m -#if $data00 != 0 then -# return -1 -#endi - -sql select count(*) from $tb where tbcol = 4 and ts < now + 4m -if $data00 != 1 then - return -1 -endi - -sql select count(*) from $tb where tbcol < 10 and ts < now + 4m -if $data00 != 5 then - return -1 -endi - -sql select count(*) from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m -if $data00 != 1 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/smallint.sim b/tests/script/windows/field/smallint.sim deleted file mode 100644 index 5f1839226b..0000000000 --- a/tests/script/windows/field/smallint.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_sm_db -$tbPrefix = fi_sm_tb -$mtPrefix = fi_sm_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol smallint) TAGS(tgcol smallint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/field/tinyint.sim b/tests/script/windows/field/tinyint.sim deleted file mode 100644 index c90ff3f932..0000000000 --- a/tests/script/windows/field/tinyint.sim +++ /dev/null @@ -1,160 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = fi_ti_db -$tbPrefix = fi_ti_tb -$mtPrefix = fi_ti_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol tinyint) TAGS(tgcol tinyint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 0 ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , 1 ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tbcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step3 -sql select * from $mt where ts > now + 4m and tbcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tbcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/import/basic.sim b/tests/script/windows/import/basic.sim deleted file mode 100644 index ee19893ae2..0000000000 --- a/tests/script/windows/import/basic.sim +++ /dev/null @@ -1,125 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -sql create database ibadb -sql use ibadb -sql create table tb(ts timestamp, i int) - -print ================= step1 - -sql import into tb values(1564641710000, 10000) -sql select * from tb; -if $rows != 1 then - return -1 -endi - -print ================= step2 -sql insert into tb values(1564641708000, 8000) -sql select * from tb; -if $rows != 2 then - return -1 -endi - -print ================= step3 -sql insert into tb values(1564641720000, 20000) -sql select * from tb; -if $rows != 3 then - return -1 -endi - -print ================= step4 -sql import into tb values(1564641708000, 8000) -sql import into tb values(1564641715000, 15000) -sql import into tb values(1564641730000, 30000) -sql select * from tb; -if $rows != 5 then - return -1 -endi - -print ================= step5 -sql insert into tb values(1564641708000, 8000) -sql insert into tb values(1564641714000, 14000) -sql insert into tb values(1564641725000, 25000) -sql insert into tb values(1564641740000, 40000) -sql select * from tb; -if $rows != 8 then - return -1 -endi - -print ================= step6 -sql import into tb values(1564641707000, 7000) -sql import into tb values(1564641712000, 12000) -sql import into tb values(1564641723000, 23000) -sql import into tb values(1564641734000, 34000) -sql import into tb values(1564641750000, 50000) -sql select * from tb; -if $rows != 13 then - return -1 -endi - -print ================= step7 -sql import into tb values(1564641707001, 7001) -sql import into tb values(1564641712001, 12001) -sql import into tb values(1564641723001, 23001) -sql import into tb values(1564641734001, 34001) -sql import into tb values(1564641750001, 50001) -sql select * from tb; -if $rows != 18 then - return -1 -endi - -print ================= step8 -sql insert into tb values(1564641708002, 8002) -sql insert into tb values(1564641714002, 14002) -sql insert into tb values(1564641725002, 25002) -sql insert into tb values(1564641900000, 200000) -sql select * from tb; -if $rows != 22 then - return -1 -endi - -print ================= step9 only insert last one -sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 700000) -sql select * from tb; -if $rows != 25 then - return -1 -endi - -print ================= step10 -sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 70000) -sql select * from tb; -if $rows != 25 then - return -1 -endi - -print ================= step11 -sql import into tb values(1564642400000, 700000) -sql select * from tb; -if $rows != 25 then - return -1 -endi - -print ================= step12 -sql import into tb values(1564641709527, 9527)(1564641709527, 9528) -sql select * from tb; -print rows=> $rows -if $rows != 26 then - return -1 -endi - -print ================= step13 -sql import into tb values(1564641709898, 9898)(1564641709897, 9897) -sql select * from tb; -print rows=> $rows -if $rows != 28 then - return -1 -endi - -sql drop database ibadb \ No newline at end of file diff --git a/tests/script/windows/insert/basic.sim b/tests/script/windows/insert/basic.sim deleted file mode 100644 index a516f80e10..0000000000 --- a/tests/script/windows/insert/basic.sim +++ /dev/null @@ -1,49 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_in_db -$tbPrefix = tb_in_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed int) - -$x = 0 -while $x < 10 - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw - -print =============== step 2 -sql insert into $tb values (now - 5m , 10) -sql insert into $tb values (now - 6m , 10) -sql insert into $tb values (now - 7m , 10) -sql insert into $tb values (now - 8m , 10) - -sql select * from $tb - -print $rows points data are retrieved -if $rows != 14 then - return -1 -endi - -sql drop database $db -sleep 1000 -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/insert/query_block1_file.sim b/tests/script/windows/insert/query_block1_file.sim deleted file mode 100644 index 62b74ac19c..0000000000 --- a/tests/script/windows/insert/query_block1_file.sim +++ /dev/null @@ -1,195 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_1f_db -$tbPrefix = tb_1f_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed int) - -#commit to file will trigger if insert 82 rows - -$N = 82 - -print =============== step 1 -$x = $N -$y = $N / 2 -while $x > $y - $ms = $x . m - $xt = - . $x - sql insert into $tb values (now - $ms , $x ) - $x = $x - 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $y then - return -1 -endi - -$x = $N / 2 -$y = $N -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $N then - return -1 -endi - -print =============== step 2 - -$R = 4 -$x = $N * 2 -$y = $N * $R -$expect = $y + $N -$y = $y + $x -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -print =============== step 3 - -$N1 = $N + 1 -$result1 = $N / 2 -$result2 = $N -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step - - -sql select * from $tb where ts < $start1 and ts > $end1 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 -print select * from $tb where ts < $start2 and ts > $end1 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 -print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 -print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 -if $rows != 0 then - return -1 -endi - -print ================= order by ts desc - -sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc -print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -clear: - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/insert/query_block1_memory.sim b/tests/script/windows/insert/query_block1_memory.sim deleted file mode 100644 index 6c3e58d70e..0000000000 --- a/tests/script/windows/insert/query_block1_memory.sim +++ /dev/null @@ -1,177 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_1m_db -$tbPrefix = tb_1m_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db - -sql create table $tb (ts timestamp, speed int) - -#commit to file will trigger if insert 82 rows - -$N = 82 - -print =============== step 1 -$x = $N -$y = $N / 2 -while $x > $y - $ms = $x . m - $xt = - . $x - sql insert into $tb values (now - $ms , -$x ) - $x = $x - 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $y then - return -1 -endi - -$x = $N / 2 -$y = $N -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $N then - return -1 -endi - -print =============== step 2 - -$N1 = $N + 1 -$result1 = $N / 2 -$result2 = $N -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step - -sql select * from $tb where ts < $start1 and ts > $end1 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 -print select * from $tb where ts < $start2 and ts > $end1 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 -print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 -print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 -if $rows != 0 then - return -1 -endi - -print ================= order by ts desc - -sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc -print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -clear: - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - diff --git a/tests/script/windows/insert/query_block2_file.sim b/tests/script/windows/insert/query_block2_file.sim deleted file mode 100644 index 164c8a1124..0000000000 --- a/tests/script/windows/insert/query_block2_file.sim +++ /dev/null @@ -1,210 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_2f_db -$tbPrefix = tb_2f_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 - -#commit to file will trigger if insert 82 rows -$N = 82 - -print =============== step 1 -$x = $N * 2 -$y = $N -$expect = $N -while $x > $y - $ms = $x . m - $xt = - . $x - sql insert into $tb values (now - $ms , $xt ) - $x = $x - 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -$x = $N -$y = $N * 2 -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -print =============== step 2 - -$R = 4 -$y = $N * $R - -$expect = $y + $N -$expect = $expect + $N - -$x = $N * 3 -$y = $y + $x - -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - - -print =============== step 2 - -$N2 = $N -$result1 = $N -$result2 = 2 * $N -$N1 = $result2 + 1 -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step - -sql select * from $tb where ts < $start1 and ts > $end1 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 -print select * from $tb where ts < $start2 and ts > $end1 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 -print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 -print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 -if $rows != 0 then - return -1 -endi - -print ================= order by ts desc - -sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc -print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -clear: - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - diff --git a/tests/script/windows/insert/query_block2_memory.sim b/tests/script/windows/insert/query_block2_memory.sim deleted file mode 100644 index f3ceb503ac..0000000000 --- a/tests/script/windows/insert/query_block2_memory.sim +++ /dev/null @@ -1,172 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_2m_db -$tbPrefix = tb_2m_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed int) - -$N = 82 - -$x = $N * 2 -$y = $N -while $x > $y - $ms = $x . m - $xt = - . $x - sql insert into $tb values (now - $ms , $xt ) - $x = $x - 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $y then - return -1 -endi - -$x = $N -$y = $N * 2 -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -print =============== step 2 - -$result1 = $N -$result2 = $N * 2 - -$N1 = $result2 + 1 -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step - -sql select * from $tb where ts < $start1 and ts > $end1 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 -print select * from $tb where ts < $start2 and ts > $end1 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 -print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 -print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 -if $rows != 0 then - return -1 -endi - -print ================= order by ts desc - -sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc -print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/insert/query_file_memory.sim b/tests/script/windows/insert/query_file_memory.sim deleted file mode 100644 index d9752c40c9..0000000000 --- a/tests/script/windows/insert/query_file_memory.sim +++ /dev/null @@ -1,209 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_fm_db -$tbPrefix = tb_fm_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 - -#commit to file will trigger if insert 82 rows - -$N = 82 - -$x = $N * 2 -$y = $N -$expect = $y -while $x > $y - $ms = $x . m - $xt = - . $x - sql insert into $tb values (now - $ms , $xt ) - $x = $x - 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -$x = $N -$y = $N * 2 -$expect = $N * 2 -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - -$R = 4 -$R = $R - 1 - -$y = $N * $R -$expect = $y + $N -$expect = $expect + $N - -$x = $N * 3 -$y = $y + $x -while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 -endw - -sql select * from $tb -print sql select * from $tb -> $rows points -if $rows != $expect then - return -1 -endi - - -print =============== step 2 - -$result1 = $N -$result2 = $N * 2 -$N1 = $result2 + 1 -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step - - -sql select * from $tb where ts < $start1 and ts > $end1 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 -print select * from $tb where ts < $start2 and ts > $end1 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 -print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 -print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 -if $rows != 0 then - return -1 -endi - -print ================= order by ts desc - -sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc -print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points -if $rows != $result2 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points -if $rows != $result1 then - return -1 -endi - -sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc -if $rows != 0 then - return -1 -endi - -clear: - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - - diff --git a/tests/script/windows/insert/query_multi_file.sim b/tests/script/windows/insert/query_multi_file.sim deleted file mode 100644 index ba617ce63c..0000000000 --- a/tests/script/windows/insert/query_multi_file.sim +++ /dev/null @@ -1,55 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = tb_mf_db -$tbPrefix = tb_mf_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database -x step1 -step1: -sql create database $db -sql use $db - -$x = 0 -create1: - $x = $x + 1 - sleep 1000 - if $x == 20 then - return -1 - endi -sql create table $tb (ts timestamp, speed int) -x create1 - -$N = 20000 - -$x = 0 - -while $x < $N - $ms = $x . s - #print insert into $tb values (now + $ms , $x ) - sql insert into $tb values (now + $ms , $x ) -x error_insert - $x = $x + 1 -endw -error_insert: - -sql select * from $tb -print $rows points data are retrieved -> exepct $N rows -if $rows < $N then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - diff --git a/tests/script/windows/table/binary.sim b/tests/script/windows/table/binary.sim deleted file mode 100644 index 5efa0bc666..0000000000 --- a/tests/script/windows/table/binary.sim +++ /dev/null @@ -1,63 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = lm_bn_db -$tbPrefix = lm_bn_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed binary(5)) - -sql insert into $tb values (now, ) -x step1 - return -1 -step1: - -print =============== step2 -sql insert into $tb values (now+1a, '1234') -sql select speed from $tb order by ts desc -if $rows != 1 then - return -1 -endi -if $data00 != 1234 then - return -1 -endi - -print =============== step3 -sql insert into $tb values (now+2a, '23456') -sql select speed from $tb order by ts desc -if $rows != 2 then - return -1 -endi -print ==> $data00 -if $data00 != 23456 then - return -1 -endi - -print =============== step4 -sql_error insert into $tb values (now+3a, '345678') -sql insert into $tb values (now+3a, '34567') -sql select speed from $tb order by ts desc -if $rows != 3 then - return -1 -endi -print ==> $data00 -if $data00 != 34567 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/table/bool.sim b/tests/script/windows/table/bool.sim deleted file mode 100644 index 0d185d31e8..0000000000 --- a/tests/script/windows/table/bool.sim +++ /dev/null @@ -1,92 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = lm_bo_db -$tbPrefix = lm_bo_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db -$x = 0 -sql create table $tb (ts timestamp, speed bool) - -sql insert into $tb values (now, true) -sql select * from $tb -if $rows != 1 then - return -1 -endi - -if $data01 != 1 then - return -1 -endi - -print =============== step2 -sql insert into $tb values (now+1m, 1) -sql select * from $tb order by ts desc -if $rows != 2 then - return -1 -endi - -if $data01 != 1 then - return -1 -endi - -print =============== step3 -sql insert into $tb values (now+2m, 2) -sql select * from $tb order by ts desc -if $rows != 3 then - return -1 -endi - -if $data01 != 1 then - return -1 -endi - -print =============== step4 -sql insert into $tb values (now+3m, 0) -sql select * from $tb order by ts desc -if $rows != 4 then - return -1 -endi - -if $data01 != 0 then - return -1 -endi - -print =============== step5 -sql insert into $tb values (now+4m, -1) -sql select * from $tb order by ts desc -if $rows != 5 then - return -1 -endi - -if $data01 != 1 then - return -1 -endi - -print =============== step6 -sql insert into $tb values (now+5m, false) -sql select * from $tb order by ts desc -if $rows != 6 then - return -1 -endi - -if $data01 != 0 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/table/column_name.sim b/tests/script/windows/table/column_name.sim deleted file mode 100644 index 6f9f954461..0000000000 --- a/tests/script/windows/table/column_name.sim +++ /dev/null @@ -1,91 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - - -$i = 0 -$dbPrefix = lm_cm_db -$tbPrefix = lm_cm_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db - -sql drop table dd -x step0 - return -1 -step0: - -sql create table $tb(ts timestamp, int) -x step1 - return -1 -step1: - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step2 -sql create table $tb (ts timestamp, s int) -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop table $tb -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql create table $tb (ts timestamp, a0123456789 int) -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop table $tb -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step4 -sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) -sql drop table $tb - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step5 -sql create table $tb (ts timestamp, a0123456789 int) -sql show tables -if $rows != 1 then - return -1 -endi - -sql insert into $tb values (now , 1) -sql select * from $tb -if $rows != 1 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - - - - diff --git a/tests/script/windows/table/column_num.sim b/tests/script/windows/table/column_num.sim deleted file mode 100644 index 395ee02cde..0000000000 --- a/tests/script/windows/table/column_num.sim +++ /dev/null @@ -1,86 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - - -$i = 0 -$dbPrefix = lm_cn_db -$tbPrefix = lm_cn_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db - -sql create table $tb() -x step1 - return -1 -step1: - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step2 -sql create table $tb (ts timestamp) -x step2 - return -1 -step2: - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql create table $tb (ts int) -x step3 - return -1 -step3: - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step4 -sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int) - -sql show tables -if $rows != 1 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int) - -sql show tables -if $rows != 2 then - return -1 -endi - -sql insert into $tb values (now, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 ,26 , 27 ,28 ,29,30,31, 32, 33, 34, 35, 36, 37) -sql select * from $tb -if $rows != 1 then - return -1 -endi - -sql drop table $tb -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/table/column_value.sim b/tests/script/windows/table/column_value.sim deleted file mode 100644 index 8db85f16ad..0000000000 --- a/tests/script/windows/table/column_value.sim +++ /dev/null @@ -1,80 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - - -$i = 0 -$dbPrefix = lm_cv_db -$tbPrefix = lm_cv_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db - -sql create table $tb (ts timestamp, speed int, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) -sql show tables -if $rows != 1 then - return -1 -endi -sql insert into $tb values(now, 1, '1', '2', '3', '4', '5') -sql insert into $tb values(now+1a, 1, '1', '2', '3', '4', '5') -sql select * from $tb -if $rows != 2 then - return -1 -endi -sql drop table $tb -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step2 -sql create table $tb (ts timestamp, speed bigint, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -sql show tables -if $rows != 1 then - return -1 -endi -sql drop table $tb - -print =============== step3 -sql create table $tb (ts timestamp, speed float, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) -sql show tables -if $rows != 1 then - return -1 -endi -sql insert into $tb values(now+2a, 1, '1', '2', '3', '4', '5') -sql insert into $tb values(now+3a, 1, '1', '2', '3', '4', '5') -sql select * from $tb -if $rows != 2 then - return -1 -endi -sql drop table $tb -sql show tables -if $rows != 0 then - return -1 -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)) -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - - - - diff --git a/tests/script/windows/table/db.table.sim b/tests/script/windows/table/db.table.sim deleted file mode 100644 index 0e207c9982..0000000000 --- a/tests/script/windows/table/db.table.sim +++ /dev/null @@ -1,48 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - - -$i = 0 -$dbPrefix = lm_dt_db -$tbPrefix = lm_dt_tb -$db = $dbPrefix -$tb = $tbPrefix - -print =============== step1 -sql create database $db -$table = lm_dt_db.lm_dt_tb - -print =============== step2 -sql create table $table (ts timestamp, speed int) - -print =============== step3 -sql insert into $table values (now, 1) - -print =============== step4 -sql select * from $table -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi - -print =============== step5 -sql describe $table - -print =============== step6 -sql drop table $table - - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/table/double.sim b/tests/script/windows/table/double.sim deleted file mode 100644 index b88ac4a199..0000000000 --- a/tests/script/windows/table/double.sim +++ /dev/null @@ -1,98 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = lm_do_db -$tbPrefix = lm_do_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed double) -#sql insert into $tb values (now, -1.79E+308) -x step1 -# return -1 -#step1: - -print =============== step2 -#sql insert into $tb values (now+1a, 1.79E+308) -x step2 -# return -1 -#step2: - -sql select * from $tb order by ts desc -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql insert into $tb values (now+2a, 2.85) -sql select * from $tb order by ts desc -if $rows != 1 then - return -1 -endi -if $data01 != 2.850000000 then - return -1 -endi - -print =============== step4 -sql insert into $tb values (now+3a, 3.4) -sql select * from $tb order by ts desc -if $rows != 2 then - return -1 -endi -if $data01 != 3.400000000 then - return -1 -endi - -print =============== step5 -sql insert into $tb values (now+4a, a2) -x step51 - return -1 -step51: -sql insert into $tb values (now+4a, 0) -sql select * from $tb order by ts desc -if $rows != 3 then - return -1 -endi -if $data01 != 0.000000000 then - return -1 -endi - -print =============== step6 -sql insert into $tb values (now+5a, 2a) -x step6 - return -1 -step6: -sql insert into $tb values(now+5a, 2) -sql select * from $tb order by ts desc -if $rows != 4 then - return -1 -endi -if $data01 != 2.000000000 then - return -1 -endi - -print =============== step7 -sql insert into $tb values (now+6a, 2a'1) -x step7 - return -1 -step7: -sql insert into $tb values(now+6a, 2) -sql select * from $tb order by ts desc -if $rows != 5 then - return -1 -endi -if $data01 != 2.000000000 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/table/float.sim b/tests/script/windows/table/float.sim deleted file mode 100644 index 741525830d..0000000000 --- a/tests/script/windows/table/float.sim +++ /dev/null @@ -1,98 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = lm_fl_db -$tbPrefix = lm_fl_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db -sql create table $tb (ts timestamp, speed float) -#sql insert into $tb values (now, -3.40E+38) -x step1 -# return -1 -#step1: - -print =============== step2 -#sql insert into $tb values (now+1a, 3.40E+308) -x step2 -# return -1 -#step2: - -sql select * from $tb order by ts desc -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql insert into $tb values (now+2a, 2.85) -sql select * from $tb order by ts desc -if $rows != 1 then - return -1 -endi -if $data01 != 2.85000 then - return -1 -endi - -print =============== step4 -sql insert into $tb values (now+3a, 3.4) -sql select * from $tb order by ts desc -if $rows != 2 then - return -1 -endi -if $data01 != 3.40000 then - return -1 -endi - -print =============== step5 -sql insert into $tb values (now+4a, a2) -x step5 - return -1 -step5: -sql insert into $tb values (now+4a, 0) -sql select * from $tb order by ts desc -if $rows != 3 then - return -1 -endi -if $data01 != 0.00000 then - return -1 -endi - -print =============== step6 -sql insert into $tb values (now+5a, 2a) -x step6 - return -1 -step6: -sql insert into $tb values (now+5a, 2) -sql select * from $tb order by ts desc -if $rows != 4 then - return -1 -endi -if $data01 != 2.00000 then - return -1 -endi - -print =============== step7 -sql insert into $tb values (now+6a, 2a'1) -x step7 - return -1 -step7: -sql insert into $tb values (now+6a, 2) -sql select * from $tb order by ts desc -if $rows != 5 then - return -1 -endi -if $data01 != 2.00000 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/table/table.sim b/tests/script/windows/table/table.sim deleted file mode 100644 index 13d1576277..0000000000 --- a/tests/script/windows/table/table.sim +++ /dev/null @@ -1,225 +0,0 @@ -sql connect -sleep 2000 -print ============================ dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = ob_tb_db -$tbPrefix = ob_tb_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop database $db -x step1 -step1: -sql create database $db - -print =============== step2-3-4 -sql use $db - -$i = 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val tinyint, val2 tinyint) -sql insert into $tb values(now, 1, 1) -sql select * from $tb -if $data01 != 1 then - return -1 -endi - -$i = 2 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val smallint, val2 smallint) -sql insert into $tb values(now, 2, 2) -sql select * from $tb -if $data01 != 2 then - return -1 -endi - -$i = 3 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val int, val2 int) -sql insert into $tb values(now, 3, 3) -sql select * from $tb -if $data01 != 3 then - return -1 -endi - -$i = 4 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val bigint, val2 bigint) -sql insert into $tb values(now, 4, 4) -sql select * from $tb -if $data01 != 4 then - return -1 -endi - -$i = 5 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val float, val2 float) -sql insert into $tb values(now, 5, 5) -sql select * from $tb -print ==> $data01 $data02 -if $data01 != 5.00000 then - return -1 -endi - -$i = 6 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val double, val2 double) -sql insert into $tb values(now, 6, 6) -sql select * from $tb -print ==> $data01 $data02 -if $data01 != 6.000000000 then - return -1 -endi - -$i = 7 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) -sql insert into $tb values(now, '7', '7') -sql select * from $tb -if $data01 != 7 then - return -1 -endi - -print =============== step5 -sql show tables -if $rows != 7 then - return -1 -endi - -$i = 1 -while $i < 8 - $tb = $tbPrefix . $i - sql drop table $tb - $i = $i + 1 -endw - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step6-9 -$i = 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val tinyint, val2 tinyint) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 1, 1) -sql select * from $tb -if $data01 != 1 then - return -1 -endi - -$i = 2 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val smallint, val2 smallint) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 2, 2) -sql select * from $tb -if $data01 != 2 then - return -1 -endi - -$i = 3 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val int, val2 int) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 3, 3) -sql select * from $tb -if $data01 != 3 then - return -1 -endi - -$i = 4 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val bigint, val2 bigint) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 4, 4) -sql select * from $tb -if $data01 != 4 then - return -1 -endi - -$i = 5 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val float, val2 float) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 5, 5) -sql select * from $tb -print ==> $data01 $data02 -if $data01 != 5.00000 then - return -1 -endi - -$i = 6 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val double, val2 double) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, 6, 6) -sql select * from $tb -print ==> $data01 $data02 -if $data01 != 6.000000000 then - return -1 -endi - -$i = 7 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) -sql select * from $tb -if $rows != 0 then - return -1 -endi -sql insert into $tb values(now, '7', '7') -sql select * from $tb -if $data01 != 7 then - return -1 -endi - -print =============== step10 -$i = 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, val tinyint, val2 tinyint) -sql show tables -if $rows != 7 then - return -1 -endi - -print =============== step11 -sql create table $tb (ts timestamp, val float, val2 double) -sql show tables -if $rows != 7 then - return -1 -endi - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - - diff --git a/tests/script/windows/table/table_len.sim b/tests/script/windows/table/table_len.sim deleted file mode 100644 index 72ed549466..0000000000 --- a/tests/script/windows/table/table_len.sim +++ /dev/null @@ -1,105 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$i = 0 -$dbPrefix = lm_tb_db -$tbPrefix = lm_tb_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql create database $db -sql use $db - -sql drop table dd -x step0 - return -1 -step0: - -sql create table (ts timestamp, speed int) -x step1 - return -1 -step1: - -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step2 -sql create table a (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop table a -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step3 -sql create table a0123456789 (ts timestamp, speed int) -sql show tables -if $rows != 1 then - return -1 -endi - -sql drop table a0123456789 -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step4 -sql create table ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789 (ts timestamp, speed int) -x step4 - return -1 -step4: -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step5 -sql create table a;1 (ts timestamp, speed int) -x step5 - return -1 -step5: -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step6 -sql create table a'1 (ts timestamp, speed int) -x step6 - return -1 -step6: -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step7 -sql create table (a) (ts timestamp, speed int) -x step7 - return -1 -step7: -sql show tables -if $rows != 0 then - return -1 -endi - -print =============== step8 -sql create table a.1 (ts timestamp, speed int) -x step8 - return -1 -step8: - -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/3.sim b/tests/script/windows/tag/3.sim deleted file mode 100644 index 5479be158b..0000000000 --- a/tests/script/windows/tag/3.sim +++ /dev/null @@ -1,521 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_3_db -$tbPrefix = ta_3_tb -$mtPrefix = ta_3_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> false -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tgcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol1 = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> false and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step15 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step16 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step17 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step18 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step19 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/4.sim b/tests/script/windows/tag/4.sim deleted file mode 100644 index 17552010b0..0000000000 --- a/tests/script/windows/tag/4.sim +++ /dev/null @@ -1,711 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_4_db -$tbPrefix = ta_4_tb -$mtPrefix = ta_4_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tgcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tgcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step19 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step20 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step21 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step22 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step23 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step24 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/5.sim b/tests/script/windows/tag/5.sim deleted file mode 100644 index f06d78e7b5..0000000000 --- a/tests/script/windows/tag/5.sim +++ /dev/null @@ -1,834 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_5_db -$tbPrefix = ta_5_tb -$mtPrefix = ta_5_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tgcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tgcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where tgcol5 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step8 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tgcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step19 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step20 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step21 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step22 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step23 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step24 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step25 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step26 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step27 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/6.sim b/tests/script/windows/tag/6.sim deleted file mode 100644 index 64cb9df6f0..0000000000 --- a/tests/script/windows/tag/6.sim +++ /dev/null @@ -1,989 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_6_db -$tbPrefix = ta_6_tb -$mtPrefix = ta_6_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol1 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where tgcol3 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol3 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step6 -sql select * from $mt where tgcol4 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol4 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step7 -sql select * from $mt where tgcol5 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol5 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step8 -sql select * from $mt where tgcol6 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol6 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol6 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol6 <> 1 -if $rows != 100 then - return -1 -endi - -print =============== step9 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step10 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step11 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step12 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step13 -sql select * from $mt where ts > now + 4m and tgcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step14 -sql select * from $mt where ts > now + 4m and tgcol6 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol6 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol6 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step15 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step16 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step17 -sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step18 -sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step19 -sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step20 -sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step21 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step22 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step23 -sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 -if $rows != 25 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step24 -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 -if $rows != 75 then - return -1 -endi -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 -if $rows != 75 then - return -1 -endi -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 -if $rows != 25 then - return -1 -endi -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 -if $rows != 25 then - return -1 -endi -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 -if $rows != 25 then - return -1 -endi -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 -if $rows != 25 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi -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 -if $rows != 5 then - return -1 -endi - -print =============== step25 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step26 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step27 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step28 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step29 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step30 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step31 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/add.sim b/tests/script/windows/tag/add.sim deleted file mode 100644 index 02d027ccf4..0000000000 --- a/tests/script/windows/tag/add.sim +++ /dev/null @@ -1,854 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_ad_db -$tbPrefix = ta_ad_tb -$mtPrefix = ta_ad_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i - -sql create database $db -sql use $db - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt add tag tgcol4 int -sql reset query cache -sql alter table $tb set tag tgcol4 =4 -sql reset query cache - -sql select * from $mt where tgcol4 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step2 - return -1 -step2: - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt add tag tgcol4 tinyint -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql reset query cache - -sql select * from $mt where tgcol4 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step3 - return -1 -step3: - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -sql describe $tb -print sql describe $tb -if $data21 != BIGINT then - return -1 -endi -if $data31 != FLOAT then - return -1 -endi -if $data23 != TAG then - return -1 -endi -if $data33 != TAG then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt add tag tgcol4 float -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql reset query cache - -sql select * from $mt where tgcol4 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4.00000 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step4 - return -1 -step4: - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt add tag tgcol4 smallint -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql reset query cache - -sql select * from $mt where tgcol4 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol3 = '1' -x step5 - return -1 -step5: - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) -sql create table $tb using $mt tags( 1, 2, 3 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt add tag tgcol5 binary(10) -sql alter table $mt add tag tgcol6 binary(10) - -sql reset query cache -sql alter table $tb set tag tgcol4=false -sql alter table $tb set tag tgcol5=5 -sql alter table $tb set tag tgcol6=6 -sql reset query cache - -sql select * from $mt where tgcol5 = '5' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 5 then - return -1 -endi -if $data04 != 6 then - return -1 -endi - -sql select * from $mt where tgcol6 = '6' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 5 then - return -1 -endi -if $data04 != 6 then - return -1 -endi - -sql select * from $mt where tgcol4 = 1 -if $rows != 0 then - return -1 -endi -sql select * from $mt where tgcol3 = 1 -x step52 - return -1 -step52: - -print =============== step7 -$i = 7 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, 2, '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol3 = '3' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt add tag tgcol5 bigint -sql alter table $mt add tag tgcol6 tinyint - -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql alter table $tb set tag tgcol5=5 -sql alter table $tb set tag tgcol6=6 -sql reset query cache - -sql select * from $mt where tgcol6 = 6 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 4 then - return -1 -endi -if $data03 != 5 then - return -1 -endi -if $data04 != 6 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step71 - return -1 -step71: -sql select * from $mt where tgcol3 = 1 -x step72 - return -1 -step72: - -print =============== step8 -$i = 8 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, 2, '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol3 = '3' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt add tag tgcol5 binary(17) -sql alter table $mt add tag tgcol6 bool -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql alter table $tb set tag tgcol5=5 -sql alter table $tb set tag tgcol6=1 -sql reset query cache - -sql select * from $mt where tgcol5 = '5' -print select * from $mt where tgcol5 = 5 -print $data01 $data02 $data03 $data04 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 4 then - return -1 -endi -if $data03 != 5 then - return -1 -endi -if $data04 != 1 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step81 - return -1 -step81: -sql select * from $mt where tgcol3 = 1 -x step82 - return -1 -step82: - -print =============== step9 -$i = 9 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, 2, '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt add tag tgcol5 bool -sql alter table $mt add tag tgcol6 float - -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql alter table $tb set tag tgcol5=1 -sql alter table $tb set tag tgcol6=6 -sql reset query cache - -sql select * from $mt where tgcol5 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 4.000000000 then - return -1 -endi -if $data03 != 1 then - return -1 -endi -if $data04 != 6.00000 then - return -1 -endi - -sql select * from $mt where tgcol3 = 1 -x step91 - return -1 -step91: -sql select * from $mt where tgcol2 = 1 -x step92 - return -1 -step92: - -print =============== step10 -$i = 10 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) -sql create table $tb using $mt tags( '1', '2', '3', '4' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol4 = '4' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -x step103 - return -1 -step103: - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol4 -sql reset query cache -sql alter table $mt add tag tgcol4 binary(10) -sql alter table $mt add tag tgcol5 bool - -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql alter table $tb set tag tgcol5=false -sql reset query cache - -sql select * from $mt where tgcol4 = '4' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4 then - return -1 -endi -if $data04 != 0 then - return -1 -endi -if $data05 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step101 - return -1 -step101: -sql select * from $mt where tgcol3 = 1 -x step102 - return -1 -step102: - -print =============== step11 -$i = 11 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) -sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4.00000 then - return -1 -endi -if $data06 != 5 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol4 -x step114 - return -1 -step114: - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol4 -sql alter table $mt drop tag tgcol5 -sql reset query cache -sql alter table $mt add tag tgcol4 binary(10) -sql alter table $mt add tag tgcol5 int -sql alter table $mt add tag tgcol6 binary(10) -sql alter table $mt add tag tgcol7 bigint -sql alter table $mt add tag tgcol8 smallint - -sql reset query cache -sql alter table $tb set tag tgcol4=4 -sql alter table $tb set tag tgcol5=5 -sql alter table $tb set tag tgcol6=6 -sql alter table $tb set tag tgcol7=7 -sql alter table $tb set tag tgcol8=8 -sql reset query cache - -sql select * from $mt where tgcol5 =5 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4 then - return -1 -endi -if $data04 != 5 then - return -1 -endi -if $data05 != 6 then - return -1 -endi -if $data06 != 7 then - return -1 -endi -if $data07 != 8 then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step111 - return -1 -step111: -sql select * from $mt where tgcol3 = 1 -x step112 - return -1 -step112: -sql select * from $mt where tgcol9 = 1 -x step113 - return -1 -step113: - -print =============== step12 -$i = 12 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) -sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3.00000 then - return -1 -endi -if $data05 != 4.000000000 then - return -1 -endi -if $data06 != 5 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol4 -sql alter table $mt drop tag tgcol5 -sql reset query cache -sql alter table $mt add tag tgcol2 binary(10) -sql alter table $mt add tag tgcol3 int -sql alter table $mt add tag tgcol4 binary(10) -sql alter table $mt add tag tgcol5 bigint - -sql reset query cache -sql alter table $tb set tag tgcol1=false -sql alter table $tb set tag tgcol2=5 -sql alter table $tb set tag tgcol3=4 -sql alter table $tb set tag tgcol4=3 -sql alter table $tb set tag tgcol5=2 -sql alter table $tb set tag tgcol6=1 -sql reset query cache - -sql select * from $mt where tgcol4 = '3' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 1 then - return -1 -endi -if $data04 != 5 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 3 then - return -1 -endi -if $data07 != 2 then - return -1 -endi - -sql select * from $mt where tgcol2 = '5' -if $rows != 1 then - return -1 -endi - -sql select * from $mt where tgcol3 = 4 -if $rows != 1 then - return -1 -endi - -sql select * from $mt where tgcol5 = 2 -if $rows != 1 then - return -1 -endi - -sql select * from $mt where tgcol6 = '1' -if $rows != 1 then - return -1 -endi - -print =============== step13 -$i = 13 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) -sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 5.000000000 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol4 -sql alter table $mt drop tag tgcol6 -sql reset query cache -sql alter table $mt add tag tgcol2 binary(10) -sql alter table $mt add tag tgcol4 int -sql alter table $mt add tag tgcol6 bigint - -sql reset query cache -sql alter table $tb set tag tgcol1=7 -sql alter table $tb set tag tgcol2=8 -sql alter table $tb set tag tgcol3=9 -sql alter table $tb set tag tgcol4=10 -sql alter table $tb set tag tgcol5=11 -sql alter table $tb set tag tgcol6=12 -sql reset query cache - -sql select * from $mt where tgcol2 = '8' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 9 then - return -1 -endi -if $data04 != 11.000000000 then - return -1 -endi -if $data05 != 8 then - return -1 -endi -if $data06 != 10 then - return -1 -endi -if $data07 != 12 then - return -1 -endi - -print =============== step14 -$i = 14 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) -sql create table $tb using $mt tags( 1, 1 ) -sql insert into $tb values(now, 1) - -sql alter table $mt add tag tgcol3 binary(10) -sql alter table $mt add tag tgcol4 int -sql alter table $mt add tag tgcol5 bigint -sql alter table $mt add tag tgcol6 bigint - -return -sql alter table $mt add tag tgcol7 bigint -x step141 - return -1 -step141: -sql reset query cache -sql alter table $mt drop tag tgcol6 -sql alter table $mt add tag tgcol7 bigint -sql alter table $mt add tag tgcol8 bigint -x step142 - return -1 -step142: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/bigint.sim b/tests/script/windows/tag/bigint.sim deleted file mode 100644 index ebb67d452c..0000000000 --- a/tests/script/windows/tag/bigint.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_bi_db -$tbPrefix = ta_bi_tb -$mtPrefix = ta_bi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary.sim b/tests/script/windows/tag/binary.sim deleted file mode 100644 index c59039b6a6..0000000000 --- a/tests/script/windows/tag/binary.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_by_db -$tbPrefix = ta_by_tb -$mtPrefix = ta_by_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '0' -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary_binary.sim b/tests/script/windows/tag/binary_binary.sim deleted file mode 100644 index 361a6edb8b..0000000000 --- a/tests/script/windows/tag/binary_binary.sim +++ /dev/null @@ -1,308 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_bib_db -$tbPrefix = ta_bib_tb -$mtPrefix = ta_bib_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '0', '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '1', '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> '0' -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '1' -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> '0' -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - - -print =============== step13 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool.sim b/tests/script/windows/tag/bool.sim deleted file mode 100644 index adf12338d0..0000000000 --- a/tests/script/windows/tag/bool.sim +++ /dev/null @@ -1,238 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_bo_db -$tbPrefix = ta_bo_tb -$mtPrefix = ta_bo_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> false -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_binary.sim b/tests/script/windows/tag/bool_binary.sim deleted file mode 100644 index 064677ee40..0000000000 --- a/tests/script/windows/tag/bool_binary.sim +++ /dev/null @@ -1,308 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_bob_db -$tbPrefix = ta_bob_tb -$mtPrefix = ta_bob_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> false -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '1' -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> false -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - - -print =============== step13 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_int.sim b/tests/script/windows/tag/bool_int.sim deleted file mode 100644 index ef5cd27553..0000000000 --- a/tests/script/windows/tag/bool_int.sim +++ /dev/null @@ -1,324 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_boi_db -$tbPrefix = ta_boi_tb -$mtPrefix = ta_boi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> false -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> true -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = false -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> false -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> true -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - - -print =============== step13 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/change.sim b/tests/script/windows/tag/change.sim deleted file mode 100644 index 4126ea1181..0000000000 --- a/tests/script/windows/tag/change.sim +++ /dev/null @@ -1,513 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_ch_db -$tbPrefix = ta_ch_tb -$mtPrefix = ta_ch_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i - -sql create database $db -sql use $db - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt change tag tagcx tgcol3 -x step21 - return -1 -step21: -sql alter table $mt change tag tgcol1 tgcol2 -x step22 - return -1 -step22: -#sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 -# return -1 -#step20: - -sql alter table $mt change tag tgcol1 tgcol3 -sql alter table $mt change tag tgcol2 tgcol4 -sql alter table $mt change tag tgcol4 tgcol3 -x step23 - return -1 -step23: - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol3 -sql alter table $mt change tag tgcol2 tgcol4 - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol3 -sql alter table $mt change tag tgcol2 tgcol4 - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt change tag tgcol1 tgcol3 -sql alter table $mt change tag tgcol2 tgcol4 - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) -sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 5.000000000 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol3 -sql reset query cache -sql alter table $mt change tag tgcol4 tgcol3 -sql alter table $mt change tag tgcol1 tgcol7 -sql alter table $mt change tag tgcol2 tgcol8 -sql reset query cache -sql alter table $mt change tag tgcol3 tgcol9 -sql alter table $mt change tag tgcol5 tgcol10 -sql alter table $mt change tag tgcol6 tgcol11 - -sleep 3000 -sql reset query cache - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -x step24 - return -1 -step24: -sql select * from $mt where tgcol2 = 1 -x step25 - return -1 -step25: - -sql select * from $mt where tgcol3 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql select * from $mt where tgcol4 = 2 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -x step31 - return -1 -step31: -sql select * from $mt where tgcol2 = 1 -x step32 - return -1 -step32: - -sql select * from $mt where tgcol3 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql select * from $mt where tgcol4 = 2 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -x step41 - return -1 -step41: -sql select * from $mt where tgcol2 = 1 -x step42 - return -1 -step42: - -sql select * from $mt where tgcol3 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -sql select * from $mt where tgcol4 = 2 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -x step51 - return -1 -step51: -sql select * from $mt where tgcol2 = 1 -x step52 - return -1 -step52: - -sql select * from $mt where tgcol3 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql select * from $mt where tgcol4 = '2' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -x step61 - return -1 -step61: -sql select * from $mt where tgcol2 = 1 -x step62 - return -1 -step62: -sql select * from $mt where tgcol3 = 1 -x step63 - return -1 -step63: -sql select * from $mt where tgcol4 = 1 -x step64 - return -1 -step64: -sql select * from $mt where tgcol5 = 1 -x step65 - return -1 -step65: -sql select * from $mt where tgcol6 = 1 -x step66 - return -1 -step66: - -sql select * from $mt where tgcol7 = '1' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 4 then - return -1 -endi -if $data05 != 5.000000000 then - return -1 -endi -if $data06 != 6 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol8 = 2 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 4 then - return -1 -endi -if $data05 != 5.000000000 then - return -1 -endi -if $data06 != 6 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol9 = '4' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 4 then - return -1 -endi -if $data05 != 5.000000000 then - return -1 -endi -if $data06 != 6 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol10 = 5 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 4 then - return -1 -endi -if $data05 != 5.000000000 then - return -1 -endi -if $data06 != 6 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol11 = '6' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 4 then - return -1 -endi -if $data05 != 5.000000000 then - return -1 -endi -if $data06 != 6 then - return -1 -endi -if $data07 != null then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi diff --git a/tests/script/windows/tag/column.sim b/tests/script/windows/tag/column.sim deleted file mode 100644 index 40159bcae3..0000000000 --- a/tests/script/windows/tag/column.sim +++ /dev/null @@ -1,93 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_co_db -$tbPrefix = ta_co_tb -$mtPrefix = ta_co_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db - -$i = 0 -sql create table $mt (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10)) - -print =============== step2 - -$i = 0 -$tb = $tbPrefix . $i -sql create table $tb using $mt tags( 0, '0' ) - -$i = 1 -$tb = $tbPrefix . $i -sql create table $tb using $mt tags( 1, 1 ) - -$i = 2 -$tb = $tbPrefix . $i -sql create table $tb using $mt tags( '2', '2' ) - -$i = 3 -$tb = $tbPrefix . $i -sql create table $tb using $mt tags( '3', 3 ) - -sql show tables -if $rows != 4 then - return -1 -endi - -print =============== step3 - -$i = 0 -$tb = $tbPrefix . $i -sql insert into $tb values(now, 0, '0') - -$i = 1 -$tb = $tbPrefix . $i -sql insert into $tb values(now, 1, 1 ) - -$i = 2 -$tb = $tbPrefix . $i -sql insert into $tb values(now, '2', '2') - -$i = 3 -$tb = $tbPrefix . $i -sql insert into $tb values(now, '3', 3) - -print =============== step4 -sql select * from $mt where tgcol2 = '1' -if $rows != 1 then - return -1 -endi - -print =============== step5 -sql select * from $mt -if $rows != 4 then - return -1 -endi - -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/create.sim b/tests/script/windows/tag/create.sim deleted file mode 100644 index 62dc8a7a21..0000000000 --- a/tests/script/windows/tag/create.sim +++ /dev/null @@ -1,601 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_cr_db -$tbPrefix = ta_cr_tb -$mtPrefix = ta_cr_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i - -sql create database $db -sql use $db - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step7 -$i = 7 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - print expect 0, actual: $rows - return -1 -endi - -print =============== step8 -$i = 8 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) -sql create table $tb using $mt tags( 1 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 0 then - return -1 -endi - -print =============== step9 -$i = 9 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) -sql create table $tb using $mt tags( '1') -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol = '0' -if $rows != 0 then - return -1 -endi - -print =============== step10 -$i = 10 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - print expect 1, actual: $rows - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step11 -$i = 11 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step12 -$i = 12 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step13 -$i = 13 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step14 -$i = 14 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi - -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi -print =============== step15 -$i = 15 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step16 -$i = 16 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step17 -$i = 17 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = true -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step18 -$i = 18 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step19 -$i = 19 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step20 -$i = 20 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step21 -$i = 21 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step22 -$i = 22 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step23 -$i = 23 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 0 then - return -1 -endi - -print =============== step24 -$i = 24 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10)) -sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol3 = 3 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol4 = 4 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol5 = 5 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol6 = '6' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol6 = '0' -if $rows != 0 then - return -1 -endi - -print =============== step25 -$i = 25 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10)) -sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol6 = '6' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol6 = '0' -if $rows != 0 then - return -1 -endi - -print =============== step26 -$i = 26 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -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)) -sql create table $tb using $mt tags( '1', '2', '3', '4', '5', '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol3 = '3' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -sql select * from $mt where tgcol3 = '0' -if $rows != 0 then - return -1 -endi - -print =============== step27 -$i = 27 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -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 - return -1 -step27: - -print =============== step28 -$i = 28 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250)) -sql create table $tb using $mt tags('1', '1') -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi - -print =============== step29 -$i = 29 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250)) -sql create table $tb using $mt tags('1', '1') -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi - -print =============== step30 -$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 -step30: - -print =============== step31 -$i = 31 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5)) -sql_error create table $tb using $mt tags('1234567') -sql create table $tb using $mt tags('12345') -sql insert into $tb values(now, 1) -sql select * from $mt -print sql select * from $mt -if $rows != 1 then - return -1 -endi - -print $data00 $data01 $data02 -if $data02 != 12345 then - return -1 -endi diff --git a/tests/script/windows/tag/delete.sim b/tests/script/windows/tag/delete.sim deleted file mode 100644 index 2b503fdf47..0000000000 --- a/tests/script/windows/tag/delete.sim +++ /dev/null @@ -1,825 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_de_db -$tbPrefix = ta_de_tb -$mtPrefix = ta_de_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i - -sql create database $db -sql use $db - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 < 3 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -sql describe $tb -if $data21 != BIGINT then - return -1 -endi -if $data31 != FLOAT then - return -1 -endi -if $data23 != TAG then - return -1 -endi - -sql alter table $mt drop tag tgcol1 -x step40 - return -1 -step40: -sql alter table $mt drop tag tgcol2 - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $mt drop tag tgcol1 -x step50 - return -1 -step50: -sql alter table $mt drop tag tgcol2 - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) -sql create table $tb using $mt tags( 1, 2, 3 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 - -print =============== step7 -$i = 7 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, 2, '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol3 = '3' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql describe $tb -if $data21 != SMALLINT then - return -1 -endi -if $data31 != TINYINT then - return -1 -endi -if $data41 != BINARY then - return -1 -endi -if $data22 != 2 then - return -1 -endi -if $data32 != 1 then - return -1 -endi -if $data42 != 10 then - return -1 -endi -if $data23 != TAG then - return -1 -endi -if $data33 != TAG then - return -1 -endi -if $data43 != TAG then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 - -print =============== step8 -$i = 8 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, 2, '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol3 = '3' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 - -print =============== step9 -$i = 9 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) -sql create table $tb using $mt tags( 1, '2', '3' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = 2 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi - -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol2 - -print =============== step10 -$i = 10 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) -sql create table $tb using $mt tags( '1', '2', '3', '4' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol4 = '4' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi - -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol4 - -print =============== step11 -$i = 11 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) -sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4.00000 then - return -1 -endi -if $data06 != 5 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol5 - -print =============== step12 -$i = 12 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) -sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3.00000 then - return -1 -endi -if $data05 != 4.000000000 then - return -1 -endi -if $data06 != 5 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol5 -sql alter table $mt drop tag tgcol6 - -print =============== step13 -$i = 13 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) -sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 5.000000000 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol3 -sql alter table $mt drop tag tgcol4 -sql alter table $mt drop tag tgcol6 - -sleep 3000 - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step2 - return -1 -step2: - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step3 - return -1 -step3: - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step4 - return -1 -step4: - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = '1' -x step5 - return -1 -step5: - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi -if $data04 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step51 - return -1 -step51: -sql select * from $mt where tgcol3 = 1 -x step52 - return -1 -step52: - -print =============== step7 -$i = 7 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi -if $data04 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step71 - return -1 -step71: -sql select * from $mt where tgcol3 = 1 -x step72 - return -1 -step72: - -print =============== step8 -$i = 8 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi -if $data04 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step81 - return -1 -step81: -sql select * from $mt where tgcol3 = 1 -x step82 - return -1 -step82: - -print =============== step9 -$i = 9 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = 1 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != null then - return -1 -endi -if $data04 != null then - return -1 -endi - -sql select * from $mt where tgcol3 = 1 -x step91 - return -1 -step91: -sql select * from $mt where tgcol2 = 1 -x step92 - return -1 -step92: - -print =============== step10 -$i = 10 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol1 = '1' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != null then - return -1 -endi -if $data04 != null then - return -1 -endi -if $data05 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step101 - return -1 -step101: -sql select * from $mt where tgcol3 = 1 -x step102 - return -1 -step102: -sql select * from $mt where tgcol4 = 1 -x step103 - return -1 -step103: - -print =============== step11 -$i = 11 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol4=4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4.00000 then - return -1 -endi -if $data04 != null then - return -1 -endi -if $data05 != null then - return -1 -endi -if $data06 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step111 - return -1 -step111: -sql select * from $mt where tgcol3 = 1 -x step112 - return -1 -step112: -sql select * from $mt where tgcol5 = 1 -x step113 - return -1 -step113: - -print =============== step12 -$i = 12 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql select * from $mt where tgcol4 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 4.000000000 then - return -1 -endi -if $data04 != null then - return -1 -endi -if $data05 != null then - return -1 -endi -if $data06 != null then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 1 -x step120 - return -1 -step120: -sql select * from $mt where tgcol3 = 1 -x step121 - return -1 -step121: -sql select * from $mt where tgcol5 = 1 -x step122 - return -1 -step122: -sql select * from $mt where tgcol6 = 1 -x step123 - return -1 -step123: - -print =============== step13 -$i = 13 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i - -sql reset query cache -sql select * from $mt where tgcol2 = 2 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 5.000000000 then - return -1 -endi -if $data05 != null then - return -1 -endi -if $data06 != null then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol3 = 1 -x step130 - return -1 -step130: -sql select * from $mt where tgcol4 = 1 -x step131 - return -1 -step131: -sql select * from $mt where tgcol6 = 1 -x step133 - return -1 -step133: - -print =============== step14 -$i = 14 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) -sql create table $tb using $mt tags( 1, 1 ) -sql insert into $tb values(now, 1) - -sql alter table xxmt drop tag tag1 -x step141 - return -1 -step141: -sql alter table $tb drop tag tag1 -x step142 - return -1 -step142: -sql alter table $mt drop tag tag1 -x step143 - return -1 -step143: - -sql alter table $mt drop tag tagcol1 -x step144 - return -1 -step144: - -sql alter table $mt drop tag tgcol2 -sql alter table $mt drop tag tgcol1 -x step145 - return -1 -step145: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/double.sim b/tests/script/windows/tag/double.sim deleted file mode 100644 index 4381aa20f9..0000000000 --- a/tests/script/windows/tag/double.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_do_db -$tbPrefix = ta_do_tb -$mtPrefix = ta_do_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/filter.sim b/tests/script/windows/tag/filter.sim deleted file mode 100644 index 802e9a312f..0000000000 --- a/tests/script/windows/tag/filter.sim +++ /dev/null @@ -1,149 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_fi_db -$tbPrefix = ta_fi_tb -$mtPrefix = ta_fi_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 - return -1 -step2: - -print =============== step3 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 - return -1 -step3: - -print =============== step4 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' -if $rows != 1 then - return -1 -endi -if $data00 != 10 then - return -1 -endi - -print =============== step5 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 - return -1 -step6: - -print =============== step7 -sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 - return -1 -step7: - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 - return -1 -step9: - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -sql select count(tbcol) as c from $mt group by tbcol - -print =============== step12 -sql select count(tbcol) as c from $mt group by noexist -x step12 - return -1 -step12: - -print =============== step13 -sql select count(tbcol) as c from $mt group by tgcol -print $data00 -if $data00 != 100 then - return -1 -endi - -print =============== step14 -sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - print expect 100, actual $data00 - return -1 -endi - -print =============== step15 -sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 - return -1 -step15: - -print =============== step16 -sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/float.sim b/tests/script/windows/tag/float.sim deleted file mode 100644 index 8df44c24a5..0000000000 --- a/tests/script/windows/tag/float.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_fl_db -$tbPrefix = ta_fl_tb -$mtPrefix = ta_fl_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/int.sim b/tests/script/windows/tag/int.sim deleted file mode 100644 index dbff8c15b6..0000000000 --- a/tests/script/windows/tag/int.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_in_db -$tbPrefix = ta_in_tb -$mtPrefix = ta_in_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_binary.sim b/tests/script/windows/tag/int_binary.sim deleted file mode 100644 index 94aa9eb7f4..0000000000 --- a/tests/script/windows/tag/int_binary.sim +++ /dev/null @@ -1,308 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_inb_db -$tbPrefix = ta_inb_tb -$mtPrefix = ta_inb_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5)) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, '0' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, '1' ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 = '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '0' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = '1' -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> '1' -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - - -print =============== step13 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_float.sim b/tests/script/windows/tag/int_float.sim deleted file mode 100644 index 9789c9ea06..0000000000 --- a/tests/script/windows/tag/int_float.sim +++ /dev/null @@ -1,324 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_inf_db -$tbPrefix = ta_inf_tb -$mtPrefix = ta_inf_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0, 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1, 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step3 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol2 > 0.5 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 < 0.5 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol2 <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step7 -sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step11 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - - -print =============== step13 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - -print =============== step14 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/set.sim b/tests/script/windows/tag/set.sim deleted file mode 100644 index 54b87c7d0c..0000000000 --- a/tests/script/windows/tag/set.sim +++ /dev/null @@ -1,457 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_se_db -$tbPrefix = ta_se_tb -$mtPrefix = ta_se_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i - -sql create database $db -sql use $db - -print =============== step2 -$i = 2 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $tb set tag tagcx 1 -x step21 - return -1 -step21: -sql alter table $tb set tag tgcol1=false -sql alter table $tb set tag tgcol2=4 - -sql reset query cache - -sql select * from $mt where tgcol1 = false -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql describe $tb -print $data21 $data23 $data32 $data33 -if $data21 != BOOL then - return -1 -endi -if $data31 != INT then - return -1 -endi -if $data23 != TAG then - return -1 -endi -if $data33 != TAG then - return -1 -endi - -print =============== step3 -$i = 3 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $tb set tag tgcol1=3 -sql alter table $tb set tag tgcol2=4 - -sql reset query cache - -sql select * from $mt where tgcol1 = 3 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = 2 -if $rows != 0 then - return -1 -endi - - -print =============== step4 -$i = 4 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) -sql create table $tb using $mt tags( 1, 2 ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = 1 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2.00000 then - return -1 -endi - -sql alter table $tb set tag tgcol1=3 -sql alter table $tb set tag tgcol2=4 - -sql reset query cache - -sql select * from $mt where tgcol1 = 3 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3 then - return -1 -endi -if $data03 != 4.00000 then - return -1 -endi - -sql select * from $mt where tgcol2 = 4 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3 then - return -1 -endi -if $data03 != 4.00000 then - return -1 -endi - - -print =============== step5 -$i = 5 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) -sql create table $tb using $mt tags( 1, '2' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol2 = '2' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1.000000000 then - return -1 -endi -if $data03 != 2 then - return -1 -endi - -sql alter table $tb set tag tgcol1=3 -sql alter table $tb set tag tgcol2='4' - -sql reset query cache - -sql select * from $mt where tgcol1 = 3 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3.000000000 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -sql select * from $mt where tgcol2 = '4' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 3.000000000 then - return -1 -endi -if $data03 != 4 then - return -1 -endi - -print =============== step6 -$i = 6 -$mt = $mtPrefix . $i -$tb = $tbPrefix . $i -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) -sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) -sql insert into $tb values(now, 1) -sql select * from $mt where tgcol1 = '1' -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data03 != 2 then - return -1 -endi -if $data04 != 3 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 5.000000000 then - return -1 -endi -if $data07 != 6 then - return -1 -endi - -sql alter table $mt drop tag tgcol3 -sql alter table $tb set tag tgcol1='7' -sql alter table $tb set tag tgcol2=8 -sql alter table $tb set tag tgcol4='9' -sql alter table $tb set tag tgcol5=10 -sql alter table $tb set tag tgcol6='11' - -sql reset query cache - -sql select * from $mt where tgcol1 = '7' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 8 then - return -1 -endi -if $data04 != 9 then - return -1 -endi -if $data05 != 10.000000000 then - return -1 -endi -if $data06 != 11 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol2 = 8 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 8 then - return -1 -endi -if $data04 != 9 then - return -1 -endi -if $data05 != 10.000000000 then - return -1 -endi -if $data06 != 11 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol4 = '9' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 8 then - return -1 -endi -if $data04 != 9 then - return -1 -endi -if $data05 != 10.000000000 then - return -1 -endi -if $data06 != 11 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol5 = 10 -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 8 then - return -1 -endi -if $data04 != 9 then - return -1 -endi -if $data05 != 10.000000000 then - return -1 -endi -if $data06 != 11 then - return -1 -endi -if $data07 != null then - return -1 -endi - -sql select * from $mt where tgcol6 = '11' -print $data01 $data02 $data03 -if $rows != 1 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data02 != 7 then - return -1 -endi -if $data03 != 8 then - return -1 -endi -if $data04 != 9 then - return -1 -endi -if $data05 != 10.000000000 then - return -1 -endi -if $data06 != 11 then - return -1 -endi -if $data07 != null then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/smallint.sim b/tests/script/windows/tag/smallint.sim deleted file mode 100644 index bc668b164d..0000000000 --- a/tests/script/windows/tag/smallint.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_sm_db -$tbPrefix = ta_sm_tb -$mtPrefix = ta_sm_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/tag/tinyint.sim b/tests/script/windows/tag/tinyint.sim deleted file mode 100644 index 44fc9ba4dc..0000000000 --- a/tests/script/windows/tag/tinyint.sim +++ /dev/null @@ -1,241 +0,0 @@ -sql connect -sleep 2000 -print ======================== dnode1 start - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = ta_ti_db -$tbPrefix = ta_ti_tb -$mtPrefix = ta_ti_mt -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) - -$i = 0 -while $i < 5 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 0 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw -while $i < 10 - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( 1 ) - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - $i = $i + 1 -endw - -print =============== step2 -sleep 100 -sql select * from $tb -if $rows != $rowNum then - return -1 -endi -sql select * from $tb where ts < now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts <= now + 4m -if $rows != 5 then - return -1 -endi -sql select * from $tb where ts > now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts >= now + 4m -if $rows != 15 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 5m -if $rows != 1 then - return -1 -endi -sql select * from $tb where ts < now + 4m and ts > now + 5m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > 100000 and ts < 100000 -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts < now + 3m -if $rows != 0 then - return -1 -endi -sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql select * from $mt -if $rows != $totalNum then - return -1 -endi - -sql select * from $mt where ts < now + 4m -if $rows != 50 then - return -1 -endi -sql select * from $mt where ts > now + 4m -if $rows != 150 then - return -1 -endi -sql select * from $mt where ts = now + 4m -if $rows != 0 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m -if $rows != 10 then - return -1 -endi - -print =============== step4 -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 1 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol = 0 -if $rows != 100 then - return -1 -endi -sql select * from $mt where tgcol <> 0 -if $rows != 100 then - return -1 -endi - -print =============== step5 -sql select * from $mt where ts > now + 4m and tgcol = 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 1 -if $rows != 75 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts < now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol = 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts <= now + 4m and tgcol <> 0 -if $rows != 25 then - return -1 -endi -sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 -if $rows != 5 then - return -1 -endi -sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m -if $rows != 5 then - return -1 -endi - -print =============== step6 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 200 then - return -1 -endi - -print =============== step7 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step8 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 50 then - return -1 -endi - -print =============== step9 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step10 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 100 then - return -1 -endi - -print =============== step11 -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 -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data00 != 25 then - return -1 -endi - - -print =============== step12 -sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol -print $data00 $data01 $data02 $data03 $data04 $data05 $data06 -if $data01 != 100 then - return -1 -endi - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/testSuite.sim b/tests/script/windows/testSuite.sim deleted file mode 100644 index e372217b62..0000000000 --- a/tests/script/windows/testSuite.sim +++ /dev/null @@ -1,93 +0,0 @@ -run windows/alter/table.sim -run windows/alter/metrics.sim - -run windows/compute/avg.sim -run windows/compute/bottom.sim -run windows/compute/count.sim -run windows/compute/diff.sim -run windows/compute/first.sim -run windows/compute/interval.sim -run windows/compute/last.sim -run windows/compute/leastsquare.sim -run windows/compute/max.sim -run windows/compute/min.sim -run windows/compute/percentile.sim -run windows/compute/stddev.sim -run windows/compute/sum.sim -run windows/compute/top.sim - -run windows/db/basic.sim -run windows/db/len.sim - -run windows/field/2.sim -run windows/field/3.sim -run windows/field/4.sim -run windows/field/5.sim -run windows/field/6.sim -run windows/field/bigint.sim -run windows/field/binary.sim -run windows/field/bool.sim -run windows/field/double.sim -run windows/field/float.sim -run windows/field/int.sim -run windows/field/single.sim -run windows/field/smallint.sim -run windows/field/tinyint.sim - -run windows/import/basic.sim - -run windows/insert/basic.sim -run windows/insert/query_block1_file.sim -run windows/insert/query_block1_memory.sim -run windows/insert/query_block2_file.sim -run windows/insert/query_block2_memory.sim -run windows/insert/query_file_memory.sim -run windows/insert/query_multi_file.sim - -run windows/table/binary.sim -run windows/table/bool.sim -run windows/table/column_num.sim -run windows/table/column_name.sim -run windows/table/column_value.sim -run windows/table/db.table.sim -run windows/table/double.sim -run windows/table/float.sim -run windows/table/table_len.sim -run windows/table/table.sim - -run windows/tag/3.sim -run windows/tag/4.sim -run windows/tag/5.sim -run windows/tag/6.sim -run windows/tag/add.sim -run windows/tag/bigint.sim -run windows/tag/binary_binary.sim -run windows/tag/binary.sim -run windows/tag/bool_binary.sim -run windows/tag/bool_int.sim -run windows/tag/bool.sim -run windows/tag/change.sim -run windows/tag/column.sim -run windows/tag/create.sim -run windows/tag/delete.sim -run windows/tag/double.sim -run windows/tag/filter.sim -run windows/tag/float.sim -run windows/tag/int_binary.sim -run windows/tag/int_float.sim -run windows/tag/int.sim -run windows/tag/set.sim -run windows/tag/smallint.sim -run windows/tag/tinyint.sim - -run windows/vector/metrics_field.sim -run windows/vector/metrics_mix.sim -run windows/vector/metrics_query.sim -run windows/vector/metrics_tag.sim -run windows/vector/metrics_time.sim -run windows/vector/multi.sim -run windows/vector/single.sim -run windows/vector/table_field.sim -run windows/vector/table_mix.sim -run windows/vector/table_query.sim -run windows/vector/table_time.sim diff --git a/tests/script/windows/vector/metrics_field.sim b/tests/script/windows/vector/metrics_field.sim deleted file mode 100644 index dfaa7e1d99..0000000000 --- a/tests/script/windows/vector/metrics_field.sim +++ /dev/null @@ -1,622 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mf_db -$tbPrefix = m_mf_tb -$mtPrefix = m_mf_mt - -$dbPrefix = db -$tbPrefix = tb -$mtPrefix = mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $mt where a = 5 -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $mt where a = 5 -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $mt where a = 5 -x step21 - return -1 -step21: - -sql select h - f from $mt where a = 5 -x step22 - return -1 -step22: - -sql select ts - f from $mt where a = 5 -x step23 - return -1 -step23: - -sql select a - e from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $mt where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a + f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $mt where a = 5 -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $mt where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a * f from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $mt where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $mt where a = 5 -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $mt where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a / f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $mt where a = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $mt where a = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $mt where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $mt where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $mt where a = 5 -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $mt where a = 5 -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $mt where a = 5 -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $mt where a = 5 -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $mt where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $mt where a = 5 -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_mix.sim b/tests/script/windows/vector/metrics_mix.sim deleted file mode 100644 index 111fdebb05..0000000000 --- a/tests/script/windows/vector/metrics_mix.sim +++ /dev/null @@ -1,622 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mx_db -$tbPrefix = m_mx_tb -$mtPrefix = m_mx_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - ffrom $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step020 - return -1 -step020: - -sql select a -f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 - return -1 -step21: - -sql select h - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 - return -1 -step22: - -sql select ts - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 - return -1 -step23: - -sql select a - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_query.sim b/tests/script/windows/vector/metrics_query.sim deleted file mode 100644 index 45e734f468..0000000000 --- a/tests/script/windows/vector/metrics_query.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mq_db -$tbPrefix = m_mq_tb -$mtPrefix = m_mq_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - a from $mt -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select b - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - b from $mt -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select c - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select d - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select e - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - f from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $mt -x step21 - return -1 -step21: - -sql select h - f from $mt -x step22 - return -1 -step22: - -sql select ts - f from $mt -x step23 - return -1 -step23: - -sql select a - e from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $mt -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb = $tbPrefix . $i - -sql select a + f from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + a from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select b + f from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + b from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select c + f from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select d + f from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select e + f from $mt -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + f from $mt -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + e from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + e from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select d + e from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + d from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + d from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + d from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + c from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + c from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + b from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + a from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb = $tbPrefix . $i - -sql select a * f from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * a from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b * f from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * b from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c * f from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d * f from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select e * f from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * f from $mt -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d * e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * c from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * c from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * b from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * a from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql select a / f from $mt -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / a from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b / f from $mt -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / b from $mt -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c / f from $mt -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select d / f from $mt -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select e / f from $mt -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / f from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $mt -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $mt -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $mt -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $mt -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $mt -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $mt -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $mt -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $mt -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $mt -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $mt -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $mt -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $mt -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_tag.sim b/tests/script/windows/vector/metrics_tag.sim deleted file mode 100644 index 80c204fa10..0000000000 --- a/tests/script/windows/vector/metrics_tag.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mtg_db -$tbPrefix = m_mtg_tb -$mtPrefix = m_mtg_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $mt -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select b - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select c - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select d - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select e - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $mt where tgcol = 5 -x step21 - return -1 -step21: - -sql select h - f from $mt where tgcol = 5 -x step22 - return -1 -step22: - -sql select ts - f from $mt where tgcol = 5 -x step23 - return -1 -step23: - -sql select a - e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb = $tbPrefix . $i - -sql select a + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select b + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select c + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select d + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select e + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select d + e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb = $tbPrefix . $i - -sql select a * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select e * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d * e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql select a / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select d / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select e / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_time.sim b/tests/script/windows/vector/metrics_time.sim deleted file mode 100644 index c127fe78fc..0000000000 --- a/tests/script/windows/vector/metrics_time.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mt_db -$tbPrefix = m_mt_tb -$mtPrefix = m_mt_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 - return -1 -step21: - -sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 - return -1 -step22: - -sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 - return -1 -step23: - -sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/multi.sim b/tests/script/windows/vector/multi.sim deleted file mode 100644 index ff63cda9a5..0000000000 --- a/tests/script/windows/vector/multi.sim +++ /dev/null @@ -1,215 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_mu_db -$tbPrefix = m_mu_tb -$mtPrefix = m_mu_mt - -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f binary(10), g bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a + b from $tb -print ===> $data00 $data10 $data20 $data30 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + c from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + d from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + e from $tb where ts < now + 4m order by ts desc - -sql select a + a from $tb where ts > now + 4m order by ts desc - -sql select a + c from $tb where ts < now + 4m order by ts asc - -sql select a + f from $tb where ts > now + 4m order by ts asc -x step24 - return -1 -step24: - -print =============== step3 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - e from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select a - b from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - e from $tb where ts > now + 4m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb = $tbPrefix . $i - -sql select a * b + e from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select a * b + c from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a * b -d from $tb where ts > now + 4m -print ===> $data20 -if $data20 != 42.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql select a / 2 + e from $tb -print ===> $data00 -if $data00 != 10.500000000 then - return -1 -endi - -sql select a / 2 from $tb where ts < now + 4m -print ===> $data10 -if $data10 != 1.000000000 then - return -1 -endi - -sql select a / 2 * e from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a / e from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb = $tbPrefix . $i -sql select a + ts from $tb -x step61 - return -1 -step61: - -sql select a + f from $tb -x step62 - return -1 -step62: - -sql select a + g from $tb -x step63 - return -1 -step63: - -print =============== step7 -$i = 1 -$tb = $tbPrefix . $i - -sql select a + b from $tb where a = 2 -print ===> $data00 -if $data00 != 4.000000000 then - return -1 -endi - -sql select * from $tb where b < 2 -print ===> $rows -if $rows != 1 then - return -1 -endi - -sql select * from $tb where b > 2 -print ===> $rows -if $rows != 17 then - return -1 -endi - -sql select a + c from $tb where b = 2 and ts < now + 4m -print ===> $data00 -if $data00 != 4.000000000 then - return -1 -endi - -sql select a + d from $tb where c = 10 and ts > now + 4m -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $tb where d = 2 and ts < now + 4m order by ts desc - -sql select a + a from $tb where e = 2 and ts > now + 4m order by ts desc - -sql select a + c from $tb where f = 2 and ts < now + 4m order by ts asc - -sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step74 - return -1 -step74: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/single.sim b/tests/script/windows/vector/single.sim deleted file mode 100644 index fb3a52760b..0000000000 --- a/tests/script/windows/vector/single.sim +++ /dev/null @@ -1,302 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_si_db -$tbPrefix = m_si_tb -$mtPrefix = m_si_mt - -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select tbcol + 1 from $tb -print ===> $data00 $data10 $data20 $data30 -if $data00 != 1.000000000 then - return -1 -endi - -sql select tbcol + 1 from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select tbcol + 1 from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 6.000000000 then - return -1 -endi - -sql select tbcol + 1 from $tb where ts < now + 4m order by ts desc - -sql select tbcol + 1 from $tb where ts > now + 4m order by ts desc - -sql select tbcol + 1 from $tb where ts < now + 4m order by ts asc - -sql select tbcol + 1 from $tb where ts > now + 4m order by ts asc - -print =============== step3 -$i = 1 -$tb = $tbPrefix . $i - -sql select tbcol - 1 from $tb -print ===> $data00 -if $data00 != -1.000000000 then - return -1 -endi - -sql select tbcol - 1 from $tb where ts < now + 4m -print ===> $data00 -if $data00 != -1.000000000 then - return -1 -endi - -sql select tbcol - 1 from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 4.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb = $tbPrefix . $i - -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select tbcol * 2 from $tb where ts < now + 4m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select tbcol * 2 from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select tbcol / 2 from $tb where ts < now + 4m -print ===> $data10 -if $data10 != 0.500000000 then - return -1 -endi - -sql select tbcol / 2 from $tb where ts > now + 4m -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select tbcol / 0 from $tb where ts > now + 4m -print ===> $data00 -#if $data00 != 0.000000000 then -# return -1 -#endi - -print =============== step6 -$i = 11 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol bool) -sql insert into $tb values(now, 0) -sql select tbcol + 2 from $tb -x step6 - return -1 -step6: - -print =============== step7 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol tinyint) -sql insert into $tb values(now, 0); -sql select tbcol + 2 from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi -sql select tbcol - 2 from $tb -print ===> $data00 -if $data00 != -2.000000000 then - return -1 -endi -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step8 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol smallint) -sql insert into $tb values(now, 0); -sql select tbcol + 2 from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi -sql select tbcol - 2 from $tb -print ===> $data00 -if $data00 != -2.000000000 then - return -1 -endi -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step9 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol bigint) -sql insert into $tb values(now, 0); -sql select tbcol + 2 from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi -sql select tbcol - 2 from $tb -print ===> $data00 -if $data00 != -2.000000000 then - return -1 -endi -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step10 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol float) -sql insert into $tb values(now, 0); -sql select tbcol + 2 from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi -sql select tbcol - 2 from $tb -print ===> $data00 -if $data00 != -2.000000000 then - return -1 -endi -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step11 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol double) -sql insert into $tb values(now, 0); -sql select tbcol + 2 from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi -sql select tbcol - 2 from $tb -print ===> $data00 -if $data00 != -2.000000000 then - return -1 -endi -sql select tbcol * 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi -sql select tbcol / 2 from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step12 -$i = $i + 1 -$tb = $tbPrefix . $i -sql create table $tb (ts timestamp, tbcol binary(100)) -sql insert into $tb values(now, '0'); -sql select tbcol + 2 from $tb -x step12 - return -1 -step12: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_field.sim b/tests/script/windows/vector/table_field.sim deleted file mode 100644 index 10c5148243..0000000000 --- a/tests/script/windows/vector/table_field.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_tf_db -$tbPrefix = m_tf_tb -$mtPrefix = m_tf_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $tb where a = 5 -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $tb where a = 5 -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $tb where a = 5 -x step21 - return -1 -step21: - -sql select h - f from $tb where a = 5 -x step22 - return -1 -step22: - -sql select ts - f from $tb where a = 5 -x step23 - return -1 -step23: - -sql select a - e from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $tb where a = 5 -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where a = 5 = $tbPrefix . $i - -sql select a + f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $tb where a = 5 -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $tb where a = 5 -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where a = 5 = $tbPrefix . $i - -sql select a * f from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $tb where a = 5 -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $tb where a = 5 -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $tb where a = 5 -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where a = 5 = $tbPrefix . $i - -sql select a / f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $tb where a = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $tb where a = 5 -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $tb where a = 5 -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $tb where a = 5 -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where a = 5 = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $tb where a = 5 -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $tb where a = 5 -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $tb where a = 5 -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $tb where a = 5 -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $tb where a = 5 -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $tb where a = 5 -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_mix.sim b/tests/script/windows/vector/table_mix.sim deleted file mode 100644 index 7418cb453d..0000000000 --- a/tests/script/windows/vector/table_mix.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_tm_db -$tbPrefix = m_tm_tb -$mtPrefix = m_tm_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $tb where a = 5 -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step21 - return -1 -step21: - -sql select h - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step22 - return -1 -step22: - -sql select ts - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step23 - return -1 -step23: - -sql select a - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_query.sim b/tests/script/windows/vector/table_query.sim deleted file mode 100644 index 7654688b26..0000000000 --- a/tests/script/windows/vector/table_query.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_tq_db -$tbPrefix = m_tq_tb -$mtPrefix = m_tq_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - a from $tb -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select b - f from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - b from $tb -print ===> $data00 -if $data00 != 9.000000000 then - return -1 -endi - -sql select c - f from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select d - f from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select e - f from $tb -print ===> $data00 -if $data00 != -9.000000000 then - return -1 -endi - -sql select f - f from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $tb -x step21 - return -1 -step21: - -sql select h - f from $tb -x step22 - return -1 -step22: - -sql select ts - f from $tb -x step23 - return -1 -step23: - -sql select a - e from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $tb -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb = $tbPrefix . $i - -sql select a + f from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + a from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select b + f from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + b from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select c + f from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select d + f from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select e + f from $tb -print ===> $data00 -if $data00 != 11.000000000 then - return -1 -endi - -sql select f + f from $tb -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + e from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + e from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select d + e from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + d from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + d from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c + d from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + c from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + c from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select a + b from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b + a from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb = $tbPrefix . $i - -sql select a * f from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * a from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b * f from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * b from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c * f from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d * f from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select e * f from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select f * f from $tb -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d * e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c * d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * c from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * c from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a * b from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b * a from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb = $tbPrefix . $i - -sql select a / f from $tb -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / a from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b / f from $tb -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / b from $tb -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c / f from $tb -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select d / f from $tb -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select e / f from $tb -print ===> $data00 -if $data00 != 0.100000000 then - return -1 -endi - -sql select f / f from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $tb -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $tb -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $tb -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $tb -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $tb -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $tb -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $tb -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $tb -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $tb -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $tb -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $tb -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $tb -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_time.sim b/tests/script/windows/vector/table_time.sim deleted file mode 100644 index bea9d41d1b..0000000000 --- a/tests/script/windows/vector/table_time.sim +++ /dev/null @@ -1,618 +0,0 @@ -sql connect -sleep 2000 - -sql show databases -sql drop database $data00 -x e1 -e1: -sql show databases -sql drop database $data00 -x e2 -e2: - -$dbPrefix = m_tt_db -$tbPrefix = m_tt_tb -$mtPrefix = m_tt_mt - -$tbNum = 10 -$rowNum = 21 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 1 - while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select a - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select b - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 5.000000000 then - return -1 -endi - -sql select c - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select d - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select e - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select f - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select g - f from $tb where ts > now + 4m and ts < now + 6m -x step21 - return -1 -step21: - -sql select h - f from $tb where ts > now + 4m and ts < now + 6m -x step22 - return -1 -step22: - -sql select ts - f from $tb where ts > now + 4m and ts < now + 6m -x step23 - return -1 -step23: - -sql select a - e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select d - e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select c - d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select a - b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -sql select b - a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.000000000 then - return -1 -endi - -print =============== step3 -$i = 1 -$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select b + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select c + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select d + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select e + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 20.000000000 then - return -1 -endi - -sql select a + e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select d + e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select c + d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select a + b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -sql select b + a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 10.000000000 then - return -1 -endi - -print =============== step4 -$i = 1 -$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select b * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select c * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select d * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select e * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 50.000000000 then - return -1 -endi - -sql select f * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 100.000000000 then - return -1 -endi - -sql select a * e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select d * e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select c * d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select a * b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -sql select b * a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 25.000000000 then - return -1 -endi - -print =============== step5 -$i = 1 -$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select a / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select b / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.000000000 then - return -1 -endi - -sql select c / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select d / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select e / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.500000000 then - return -1 -endi - -sql select f / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select d / e from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select c / d from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / c from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select a / b from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -sql select b / a from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 1.000000000 then - return -1 -endi - -print =============== step6 -$i = 1 -$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i - -sql select (a+b+c+d+e) / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 2.500000000 then - return -1 -endi - -sql select f / (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 0.400000000 then - return -1 -endi - -sql select (a+b+c+d+e) * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select f * (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 250.000000000 then - return -1 -endi - -sql select (a+b+c+d+e) - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != 15.000000000 then - return -1 -endi - -sql select f - (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -15.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) / f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1.500000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) * f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -150.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) + f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -5.000000000 then - return -1 -endi - -sql select (f - (a+b+c+d+e)) - f from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -25.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where ts > now + 4m and ts < now + 6m -print ===> $data00 -if $data00 != -1300.000000000 then - return -1 -endi - -sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where ts > now + 4m and ts < now + 6m -x step61 - return -1 -step61: - -sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where ts > now + 4m and ts < now + 6m -x step62 - return -1 -step62: - -sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where ts > now + 4m and ts < now + 6m -x step63 - return -1 -step63: - -print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi \ No newline at end of file diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index 79daf01295..e3bbff9db5 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -56,8 +56,14 @@ echo charset UTF-8 >> %TAOS_CFG% set "FILE_NAME=testSuite.sim" if "%1" == "-f" set "FILE_NAME=%2" +set FILE_NAME=%FILE_NAME:/=\% + +start cmd /k "timeout /t 600 /NOBREAK && taskkill /f /im tsim.exe & exit /b" rem echo FILE_NAME: %FILE_NAME% echo ExcuteCmd: %tsim% -c %CFG_DIR% -f %FILE_NAME% +set result=false +%TSIM% -c %CFG_DIR% -f %FILE_NAME% && set result=true -%TSIM% -c %CFG_DIR% -f %FILE_NAME% \ No newline at end of file +tasklist | grep timeout && taskkill /f /im timeout.exe +if "%result%" == "true" ( exit /b ) else ( exit /b 8 ) \ No newline at end of file diff --git a/tests/system-test/0-others/taosShell.py b/tests/system-test/0-others/taosShell.py index e03b34adca..f55813ac83 100644 --- a/tests/system-test/0-others/taosShell.py +++ b/tests/system-test/0-others/taosShell.py @@ -44,13 +44,13 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key tdLog.info ("taos cmd: %s" % taosCmd) - child = taosExpect.spawn(taosCmd, timeout=10) + child = taosExpect.spawn(taosCmd, timeout=20) #output = child.readline() #print (output.decode()) if len(expectString) != 0: - i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) + i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) else: - i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) + i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) if platform.system().lower() == 'windows': retResult = child.before @@ -62,7 +62,7 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key print ('taos login success! Here can run sql, taos> ') if len(sqlString) != 0: child.sendline (sqlString) - w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1) + w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) if w == 0: return "TAOS_OK" else: diff --git a/tests/system-test/0-others/udfTest.py b/tests/system-test/0-others/udfTest.py index 9b145e9093..375b7a6272 100644 --- a/tests/system-test/0-others/udfTest.py +++ b/tests/system-test/0-others/udfTest.py @@ -301,13 +301,13 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , first(num1) from tb;") + tdSql.query("select udf1(num1) , first(num1) from tb;") - tdSql.error("select abs(num1) , first(num1) from tb;") + tdSql.query("select abs(num1) , first(num1) from tb;") - tdSql.error("select udf1(num1) , last(num1) from tb;") + tdSql.query("select udf1(num1) , last(num1) from tb;") - tdSql.error("select round(num1) , last(num1) from tb;") + tdSql.query("select round(num1) , last(num1) from tb;") tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) @@ -327,9 +327,9 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , first(c1) from stb1;") + tdSql.query("select udf1(c1) , first(c1) from stb1;") - tdSql.error("select udf1(c1) , last(c1) from stb1;") + tdSql.query("select udf1(c1) , last(c1) from stb1;") tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index 11ad8e1584..5f3ab2e863 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -303,13 +303,13 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , first(num1) from tb;") + tdSql.query("select udf1(num1) , first(num1) from tb;") - tdSql.error("select abs(num1) , first(num1) from tb;") + tdSql.query("select abs(num1) , first(num1) from tb;") - tdSql.error("select udf1(num1) , last(num1) from tb;") + tdSql.query("select udf1(num1) , last(num1) from tb;") - tdSql.error("select round(num1) , last(num1) from tb;") + tdSql.query("select round(num1) , last(num1) from tb;") tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) @@ -329,9 +329,9 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , first(c1) from stb1;") + tdSql.query("select udf1(c1) , first(c1) from stb1;") - tdSql.error("select udf1(c1) , last(c1) from stb1;") + tdSql.query("select udf1(c1) , last(c1) from stb1;") tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) diff --git a/tests/system-test/0-others/udf_restart_taosd.py b/tests/system-test/0-others/udf_restart_taosd.py index c9eb22cf15..857921e32c 100644 --- a/tests/system-test/0-others/udf_restart_taosd.py +++ b/tests/system-test/0-others/udf_restart_taosd.py @@ -300,13 +300,13 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select ceil(num1) , min(num1) from tb;") tdSql.checkRows(1) - tdSql.error("select udf1(num1) , first(num1) from tb;") + tdSql.query("select udf1(num1) , first(num1) from tb;") - tdSql.error("select abs(num1) , first(num1) from tb;") + tdSql.query("select abs(num1) , first(num1) from tb;") - tdSql.error("select udf1(num1) , last(num1) from tb;") + tdSql.query("select udf1(num1) , last(num1) from tb;") - tdSql.error("select round(num1) , last(num1) from tb;") + tdSql.query("select round(num1) , last(num1) from tb;") tdSql.query("select udf1(num1) , top(num1,1) from tb;") tdSql.checkRows(1) @@ -326,9 +326,9 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select floor(c1) , min(c1) from stb1;") tdSql.checkRows(1) - tdSql.error("select udf1(c1) , first(c1) from stb1;") + tdSql.query("select udf1(c1) , first(c1) from stb1;") - tdSql.error("select udf1(c1) , last(c1) from stb1;") + tdSql.query("select udf1(c1) , last(c1) from stb1;") tdSql.query("select udf1(c1) , top(c1 ,1) from stb1;") tdSql.checkRows(1) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index a4e40d1b0b..0f7a830634 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -16,273 +16,272 @@ import string from util.log import * from util.cases import * from util.sql import * +from util import constant +from util.common import * +from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + self.ntbname = 'ntb' + self.stbname = 'stb' + self.binary_length = 20 # the length of binary for column_dict + self.nchar_length = 20 # the length of nchar for column_dict + self.column_dict = { + 'ts' : 'timestamp', + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': f'binary({self.binary_length})', + 'col13': f'nchar({self.nchar_length})' + } + self.tag_dict = { + 'ts_tag' : 'timestamp', + 't1': 'tinyint', + 't2': 'smallint', + 't3': 'int', + 't4': 'bigint', + 't5': 'tinyint unsigned', + 't6': 'smallint unsigned', + 't7': 'int unsigned', + 't8': 'bigint unsigned', + 't9': 'float', + 't10': 'double', + 't11': 'bool', + 't12': f'binary({self.binary_length})', + 't13': f'nchar({self.nchar_length})' + } + self.tag_list = [ + f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"' + ] + self.tbnum = 1 + self.values_list = [ + f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"' + ] + self.column_add_dict = { + 'col_time' : 'timestamp', + 'col_tinyint' : 'tinyint', + 'col_smallint' : 'smallint', + 'col_int' : 'int', + 'col_bigint' : 'bigint', + 'col_untinyint' : 'tinyint unsigned', + 'col_smallint' : 'smallint unsigned', + 'col_int' : 'int unsigned', + 'col_bigint' : 'bigint unsigned', + 'col_bool' : 'bool', + 'col_float' : 'float', + 'col_double' : 'double', + 'col_binary' : f'binary({constant.BINARY_LENGTH_MAX})', + 'col_nchar' : f'nchar({constant.NCAHR_LENGTH_MAX})' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) - - def alter_tb_tag_check(self): - tag_tinyint = random.randint(-127,129) - tag_int = random.randint(-2147483648,2147483647) - tag_smallint = random.randint(-32768,32768) - tag_bigint = random.randint(-2147483648,2147483647) - tag_untinyint = random.randint(0,256) - tag_unsmallint = random.randint(0,65536) - tag_unint = random.randint(0,4294967296) - tag_unbigint = random.randint(0,2147483647) - tag_binary = self.get_long_name(length=10, mode="letters") - tag_nchar = self.get_long_name(length=10, mode="letters") - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create stable if not exists {dbname}.{stbname} (col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int, \ - t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))') - tdSql.execute(f'create table if not exists {dbname}.{tbname} using {dbname}.{stbname} tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")') - tdSql.execute(f'insert into {dbname}.{tbname} values(now, 1)') - tdSql.execute(f'alter table {dbname}.{tbname} set tag tag_ts = 1640966400000') - tdSql.execute(f'alter table {dbname}.{tbname} set tag `t1` = 11') - tdSql.query(f'select * from {dbname}.{stbname}') - tdSql.checkData(0,3,11) - tdSql.execute(f'alter table {dbname}.{tbname} set tag t1 = {tag_tinyint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t2 = {tag_smallint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t3 = {tag_int}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t4 = {tag_bigint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t5 = {tag_untinyint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t6 = {tag_unsmallint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t7 = {tag_unint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t8 = {tag_unbigint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t11 = false') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"') - tdSql.query(f'select * from {dbname}.{stbname}') - # bug TD-15899 - tdSql.checkData(0,2,'2022-01-01 00:00:00.000') - tdSql.checkData(0,3,tag_tinyint) - tdSql.checkData(0,4,tag_smallint) - tdSql.checkData(0,5,tag_int) - tdSql.checkData(0,6,tag_bigint) - tdSql.checkData(0,7,tag_untinyint) - tdSql.checkData(0,8,tag_unsmallint) - tdSql.checkData(0,9,tag_unint) - tdSql.checkData(0,10,tag_unbigint) + } + def alter_check_ntb(self): - tdSql.checkData(0,13,False) - tdSql.checkData(0,14,tag_binary) - tdSql.checkData(0,15,tag_nchar) + tdSql.prepare() + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + for i in self.values_list: + tdSql.execute(f'insert into {self.ntbname} values({i})') + for key,values in self.column_add_dict.items(): + tdSql.execute(f'alter table {self.ntbname} add column {key} {values}') + tdSql.query(f'describe {self.ntbname}') + tdSql.checkRows(len(self.column_dict)+1) + tdSql.query(f'select {key} from {self.ntbname}') + tdSql.checkRows(len(self.values_list)) + tdSql.execute(f'alter table {self.ntbname} drop column {key}') + tdSql.query(f'describe {self.ntbname}') + tdSql.checkRows(len(self.column_dict)) + tdSql.error(f'select {key} from {self.ntbname} ') + for key,values in self.column_dict.items(): + if 'binary' in values.lower(): + v = f'binary({self.binary_length+1})' + v_error = f'binary({self.binary_length-1})' + tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') + tdSql.query(f'describe {self.ntbname}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + elif 'nchar' in values.lower(): + v = f'nchar({self.binary_length+1})' + v_error = f'nchar({self.binary_length-1})' + tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') + tdSql.query(f'describe {self.ntbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + else: + for v in self.column_dict.values(): + tdSql.error(f'alter table {self.ntbname} modify column {key} {v}') + for key,values in self.column_dict.items(): + rename_str = f'{tdCom.getLongName(constant.COL_NAME_LENGTH_MAX,"letters")}' + tdSql.execute(f'alter table {self.ntbname} rename column {key} {rename_str}') + tdSql.query(f'select {rename_str} from {self.ntbname}') + tdSql.checkRows(1) + + def alter_check_tb(self): + tag_tinyint = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) + tag_smallint = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) + tag_int = random.randint(constant.INT_MIN,constant.INT_MAX) + tag_bigint = random.randint(constant.BIGINT_MIN,constant.BIGINT_MAX) + tag_untinyint = random.randint(constant.TINYINT_UN_MIN,constant.TINYINT_UN_MAX) + tag_unsmallint = random.randint(constant.SMALLINT_UN_MIN,constant.SMALLINT_UN_MAX) + tag_unint = random.randint(constant.INT_UN_MIN,constant.INT_MAX) + tag_unbigint = random.randint(constant.BIGINT_UN_MIN,constant.BIGINT_UN_MAX) + tag_bool = random.randint(0,100)%2 + tag_float = random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX) + tag_double = random.uniform(constant.DOUBLE_MIN*(1E-300),constant.DOUBLE_MAX*(1E-300)) + tag_binary = tdCom.getLongName(self.binary_length) + tag_nchar = tdCom.getLongName(self.binary_length) + modify_column_dict = { + 'ts1' : 'timestamp', + 'c1': 'tinyint', + 'c2': 'smallint', + 'c3': 'int', + 'c4': 'bigint', + 'c5': 'tinyint unsigned', + 'c6': 'smallint unsigned', + 'c7': 'int unsigned', + 'c8': 'bigint unsigned', + 'c9': 'float', + 'c10': 'double', + 'c11': 'bool', + 'c12': f'binary({self.binary_length})', + 'c13': f'nchar({self.nchar_length})' + } + tdSql.prepare() + tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_list[i]})') + for j in self.values_list: + tdSql.execute(f'insert into {self.stbname}_{i} values({j})') + for i in range(self.tbnum): + for k,v in modify_column_dict.items(): + tdSql.error(f'alter table {self.stbname}_{i} add column {k} {v}') + for k in self.column_dict.keys(): + tdSql.error(f'alter table {self.stbname}_{i} drop column {k}') + for k,v in self.column_dict.items(): + if 'binary' in v.lower(): + values = [f'binary({self.binary_length+1})', f'binary({self.binary_length-1})'] + for j in values: + tdSql.error(f'alter table {self.stbname}_{i} modify {k} {j}') + elif 'nchar' in v.lower(): + values = [f'nchar({self.nchar_length+1})', f'binary({self.nchar_length-1})'] + for j in values: + tdSql.error(f'alter table {self.stbname}_{i} modify {k} {j}') + else: + for values in self.column_dict.values(): + tdSql.error(f'alter table {self.stbname}_{i} modify column {k} {values}') + for k,v in self.tag_dict.items(): + if v.lower() == 'tinyint': + self.tag_check(i,k,tag_tinyint) + elif v.lower() == 'smallint': + self.tag_check(i,k,tag_smallint) + elif v.lower() == 'int': + self.tag_check(i,k,tag_int) + elif v.lower() == 'bigint': + self.tag_check(i,k,tag_bigint) + elif v.lower() == 'tinyint unsigned': + self.tag_check(i,k,tag_untinyint) + elif v.lower() == 'smallint unsigned': + self.tag_check(i,k,tag_unsmallint) + elif v.lower() == 'int unsigned': + self.tag_check(i,k,tag_unint) + elif v.lower() == 'bigint unsigned': + self.tag_check(i,k,tag_unbigint) + elif v.lower() == 'bool': + self.tag_check(i,k,tag_bool) + elif v.lower() == 'float': + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = {tag_float}') + tdSql.query(f'select {k} from {self.stbname}_{i}') + if abs(tdSql.queryResult[0][0] - tag_float)/tag_float<=0.0001: + tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) + else: + tdLog.exit(f'select {k} from {self.stbname}_{i},data check failure') + elif v.lower() == 'double': + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = {tag_double}') + tdSql.query(f'select {k} from {self.stbname}_{i}') + if abs(tdSql.queryResult[0][0] - tag_double)/tag_double<=0.0001: + tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) + else: + tdLog.exit(f'select {k} from {self.stbname}_{i},data check failure') + elif 'binary' in v.lower(): + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = "{tag_binary}"') + tdSql.query(f'select {k} from {self.stbname}_{i}') + tdSql.checkData(0,0,tag_binary) + elif 'nchar' in v.lower(): + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = "{tag_nchar}"') + tdSql.query(f'select {k} from {self.stbname}_{i}') + tdSql.checkData(0,0,tag_nchar) + + def tag_check(self,tb_no,tag,values): + tdSql.execute(f'alter table {self.stbname}_{tb_no} set tag {tag} = {values}') + tdSql.query(f'select {tag} from {self.stbname}_{tb_no}') + tdSql.checkData(0,0,values) + def alter_check_stb(self): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_list[i]})') + for j in self.values_list: + tdSql.execute(f'insert into {self.stbname}_{i} values({j})') + for key,values in self.column_add_dict.items(): + tdSql.execute(f'alter table {self.stbname} add column {key} {values}') + tdSql.query(f'describe {self.stbname}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)+1) + tdSql.query(f'select {key} from {self.stbname}_{i}') + tdSql.checkRows(len(self.values_list)) + tdSql.execute(f'alter table {self.stbname} drop column {key}') + tdSql.query(f'describe {self.stbname}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)) + tdSql.error(f'select {key} from {self.stbname} ') + for key,values in self.column_dict.items(): + if 'binary' in values.lower(): + v = f'binary({self.binary_length+1})' + v_error = f'binary({self.binary_length-1})' + tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + elif 'nchar' in values.lower(): + v = f'nchar({self.binary_length+1})' + v_error = f'nchar({self.binary_length-1})' + tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + else: + for v in self.column_dict.values(): + tdSql.error(f'alter table {self.stbname} modify column {key} {v}') - # bug TD-16211 insert length more than setting binary and nchar - # error_tag_binary = self.get_long_name(length=21, mode="letters") - # error_tag_nchar = self.get_long_name(length=21, mode="letters") - # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') - # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') - error_tag_binary = self.get_long_name(length=25, mode="letters") - error_tag_nchar = self.get_long_name(length=25, mode="letters") - tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') - tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') - # bug TD-16210 modify binary to nchar - tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') - tdSql.execute(f"drop database {dbname}") - def alter_ntb_column_check(self): - ''' - alter ntb column check - ''' - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tbname = self.get_long_name(length=3, mode="letters") - tdLog.info('------------------normal table column check---------------------') - tdLog.info(f'-----------------create normal table {tbname}-------------------') - tdSql.execute(f'create table if not exists {dbname}.{tbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \ - c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20))') - tdSql.execute(f'insert into {dbname}.{tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - # bug TD-15757 - tdSql.execute(f'alter table {dbname}.{tbname} add column c14 int') - tdSql.query(f'select c14 from {dbname}.{tbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {dbname}.{tbname} add column `c15` int') - tdSql.query(f'select c15 from {dbname}.{tbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {dbname}.{tbname} drop column c14') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(15) - tdSql.execute(f'alter table {dbname}.{tbname} drop column `c15`') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(14) - #! TD-16422 - # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 binary(10)') - # tdSql.query(f'describe {dbname}.{tbname}') - # tdSql.checkRows(15) - # tdSql.checkEqual(tdSql.queryResult[14][2],10) - # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') - - # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 nchar(10)') - # tdSql.query(f'describe {dbname}.{tbname}') - # tdSql.checkRows(15) - # tdSql.checkEqual(tdSql.queryResult[14][2],10) - # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') - - - tdSql.execute(f'alter table {dbname}.{tbname} modify column c12 binary(30)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(12,2,30) - tdSql.execute(f'alter table {dbname}.{tbname} modify column `c12` binary(35)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(12,2,35) - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 binary(34)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 nchar(10)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 int') - tdSql.execute(f'alter table {dbname}.{tbname} modify column c13 nchar(30)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(13,2,30) - tdSql.execute(f'alter table {dbname}.{tbname} modify column `c13` nchar(35)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(13,2,35) - tdSql.error(f'alter table {dbname}.{tbname} modify column c13 nchar(34)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c13 binary(10)') - tdSql.execute(f'alter table {dbname}.{tbname} rename column c1 c21') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(1,0,'c21') - # !bug TD-16423 - # tdSql.error(f'select c1 from {dbname}.{tbname}') - # tdSql.query(f'select c21 from {dbname}.{tbname}') - # tdSql.checkData(0,1,1) - tdSql.execute(f'alter table {dbname}.{tbname} rename column `c21` c1') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(1,0,'c1') - # !bug TD-16423 - # tdSql.error(f'select c1 from {dbname}.{tbname}') - # tdSql.query(f'select c1 from {dbname}.{tbname}') - # tdSql.checkData(0,1,1) - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bigint') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c4 int') - tdSql.error(f'alter table {dbname}.{tbname} modify column `c1` double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c9 double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c10 float') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') - tdSql.execute(f'drop database {dbname}') - def alter_stb_column_check(self): - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tdSql.execute(f'use {dbname}') - tdSql.execute( - f'create table {stbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \ - c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) ') - tdSql.execute(f'create table {tbname} using {stbname} tags(1)') - tdSql.execute(f'insert into {tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - tdSql.execute(f'alter table {stbname} add column c14 int') - tdSql.query(f'select c14 from {stbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {stbname} add column `c15` int') - tdSql.query(f'select c15 from {stbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {stbname}') - tdSql.checkRows(17) - tdSql.execute(f'alter table {stbname} drop column c14') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {stbname} drop column `c15`') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(15) - tdSql.execute(f'alter table {stbname} modify column c12 binary(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(12,2,30) - tdSql.execute(f'alter table {stbname} modify column `c12` binary(35)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(12,2,35) - tdSql.error(f'alter table {stbname} modify column `c12` binary(34)') - tdSql.execute(f'alter table {stbname} modify column c13 nchar(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(13,2,30) - tdSql.error(f'alter table {stbname} modify column c13 nchar(29)') - tdSql.error(f'alter table {stbname} rename column c1 c21') - tdSql.error(f'alter table {stbname} modify column c1 int') - tdSql.error(f'alter table {stbname} modify column c4 int') - tdSql.error(f'alter table {stbname} modify column c8 int') - tdSql.error(f'alter table {stbname} modify column c1 unsigned int') - tdSql.error(f'alter table {stbname} modify column c9 double') - tdSql.error(f'alter table {stbname} modify column c10 float') - tdSql.error(f'alter table {stbname} modify column c11 int') - tdSql.execute(f'drop database {dbname}') - def alter_stb_tag_check(self): - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tdSql.execute(f'use {dbname}') - tdSql.execute( - f'create table {stbname} (ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int, \ - t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) ') - tdSql.execute(f'create table {tbname} using {stbname} tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - tdSql.execute(f'insert into {tbname} values(now,1)') - - tdSql.execute(f'alter table {stbname} add tag t14 int') - tdSql.query(f'select t14 from {stbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {stbname} add tag `t15` int') - tdSql.query(f'select t14 from {stbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {stbname}') - tdSql.checkRows(18) - tdSql.execute(f'alter table {stbname} drop tag t14') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(17) - tdSql.execute(f'alter table {stbname} drop tag `t15`') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {stbname} modify tag t12 binary(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(14,2,30) - tdSql.execute(f'alter table {stbname} modify tag `t12` binary(35)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(14,2,35) - tdSql.error(f'alter table {stbname} modify tag `t12` binary(34)') - tdSql.execute(f'alter table {stbname} modify tag t13 nchar(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(15,2,30) - tdSql.error(f'alter table {stbname} modify tag t13 nchar(29)') - tdSql.execute(f'alter table {stbname} rename tag t1 t21') - tdSql.query(f'describe {stbname}') - tdSql.checkData(3,0,'t21') - tdSql.execute(f'alter table {stbname} rename tag `t21` t1') - tdSql.query(f'describe {stbname}') - tdSql.checkData(3,0,'t1') - - for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']: - for j in [1,2,3]: - tdSql.error(f'alter table {stbname} modify tag t{j} {i}') - for i in ['int','unsigned int','float','binary(10)','nchar(10)']: - tdSql.error(f'alter table {stbname} modify tag t8 {i}') - tdSql.error(f'alter table {stbname} modify tag t4 int') - tdSql.execute(f'drop database {dbname}') def run(self): - self.alter_tb_tag_check() - self.alter_ntb_column_check() - self.alter_stb_column_check() - self.alter_stb_tag_check() + self.alter_check_ntb() + self.alter_check_tb() + self.alter_check_stb() def stop(self): tdSql.close() diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 5a0684e2ee..4b37eeb9a5 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -21,9 +21,9 @@ SINT_UN_COL = "c_sint_un" BINT_UN_COL = "c_bint_un" INT_UN_COL = "c_int_un" -BINARY_COL = "c8" -NCHAR_COL = "c9" -TS_COL = "c10" +BINARY_COL = "c_binary" +NCHAR_COL = "c_nchar" +TS_COL = "c_ts" NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] CHAR_COL = [ BINARY_COL, NCHAR_COL, ] @@ -51,12 +51,28 @@ class DataSet: binary_data : List[str] = None nchar_data : List[str] = None + def __post_init__(self): + self.ts_data = [] + self.int_data = [] + self.bint_data = [] + self.sint_data = [] + self.tint_data = [] + self.int_un_data = [] + self.bint_un_data = [] + self.sint_un_data = [] + self.tint_un_data = [] + self.float_data = [] + self.double_data = [] + self.bool_data = [] + self.binary_data = [] + self.nchar_data = [] + class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) @property def create_databases_sql_err(self): @@ -87,28 +103,28 @@ class TDTestCase: @property def create_stable_sql_err(self): return [ - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s maxdelay 1m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay -1s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) maxdelay 1m ", + # f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", + # f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ", f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) maxdelay 1m", - # f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s maxdelay 1s", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m", + # f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s", # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , - # watermark, maxdelay: [0, 900000], [ms, s, m, ?] - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1u", + # watermark, max_delay: [0, 900000], [ms, s, m, ?] + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 16m", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 901s", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1h", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 0.2h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 16m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 901s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 0.2h", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d", ] @@ -117,11 +133,11 @@ class TDTestCase: def create_stable_sql_current(self): return [ f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s maxdelay 1m", - f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s maxdelay 1m", - f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s maxdelay 1m", - # f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s maxdelay 1m", - # f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s maxdelay 1m", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s max_delay 1m", + f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s max_delay 1m", + f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s max_delay 1m", + # f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s max_delay 1m", + # f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m", ] def test_create_stb(self): @@ -135,7 +151,7 @@ class TDTestCase: tdSql.checkRows(len(self.create_stable_sql_current)) # tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup database - # tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) file_factor 5.0") + # tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m") def test_create_databases(self): @@ -177,21 +193,6 @@ class TDTestCase: def __data_set(self, rows): data_set = DataSet() - # neg_data_set = DataSet() - data_set.ts_data = [] - data_set.int_data = [] - data_set.bint_data = [] - data_set.sint_data = [] - data_set.tint_data = [] - data_set.int_un_data = [] - data_set.bint_un_data = [] - data_set.sint_un_data = [] - data_set.tint_un_data = [] - data_set.float_data = [] - data_set.double_data = [] - data_set.bool_data = [] - data_set.binary_data = [] - data_set.nchar_data = [] for i in range(rows): data_set.ts_data.append(NOW + 1 * (rows - i)) @@ -226,6 +227,7 @@ class TDTestCase: return data_set def __insert_data(self): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") data = self.__data_set(rows=self.rows) # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -264,10 +266,10 @@ class TDTestCase: def run(self): self.rows = 10 - + tdSql.prepare() tdLog.printNoPrefix("==========step0:all check") - # self.all_test() + self.all_test() tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 5387970d56..d4434987a6 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -17,25 +17,34 @@ TINT_COL = "c_tint" FLOAT_COL = "c_float" DOUBLE_COL = "c_double" BOOL_COL = "c_bool" -TINT_UN_COL = "c_tint_un" -SINT_UN_COL = "c_sint_un" -BINT_UN_COL = "c_bint_un" -INT_UN_COL = "c_int_un" +TINT_UN_COL = "c_utint" +SINT_UN_COL = "c_usint" +BINT_UN_COL = "c_ubint" +INT_UN_COL = "c_uint" BINARY_COL = "c_binary" NCHAR_COL = "c_nchar" TS_COL = "c_ts" - - NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] CHAR_COL = [BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [BOOL_COL, ] TS_TYPE_COL = [TS_COL, ] +INT_TAG = "t_int" + +ALL_COL = [PRIMARY_COL, INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BINARY_COL, NCHAR_COL, BOOL_COL, TS_COL] +TAG_COL = [INT_TAG] + # insert data args: TIME_STEP = 10000 NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) +# init db/table +DBNAME = "db" +STBNAME = "stb1" +CTBNAME = "ct1" +NTBNAME = "nt1" + @dataclass class DataSet: @@ -73,19 +82,25 @@ class DataSet: @dataclass class SMAschema: - creation : str = "CREATE" - index_name : str = "sma_index_1" - index_flag : str = "SMA INDEX" - operator : str = "ON" - tbname : str = None - watermark : str = None - maxdelay : str = None - func : Tuple[str] = None - interval : Tuple[str] = None - sliding : str = None - other : Any = None - drop : str = "DROP" - drop_flag : str = "INDEX" + creation : str = "CREATE" + index_name : str = "sma_index_1" + index_flag : str = "SMA INDEX" + operator : str = "ON" + tbname : str = None + watermark : str = "5s" + max_delay : str = "6m" + func : Tuple[str] = None + interval : Tuple[str] = ("6m", "10s") + sliding : str = "6m" + other : Any = None + drop : str = "DROP" + drop_flag : str = "INDEX" + querySmaOptimize : int = 1 + show : str = "SHOW" + show_msg : str = "INDEXES" + show_oper : str = "FROM" + dbname : str = None + rollup_db : bool = False def __post_init__(self): if isinstance(self.other, dict): @@ -111,8 +126,8 @@ class SMAschema: self.watermark = v del self.other[k] - if k.lower() == "maxdelay" and isinstance(v, str) and not self.maxdelay: - self.maxdelay = v + if k.lower() == "max_delay" and isinstance(v, str) and not self.max_delay: + self.max_delay = v del self.other[k] if k.lower() == "functions" and isinstance(v, tuple) and not self.func: @@ -131,12 +146,36 @@ class SMAschema: self.drop_flag = v del self.other[k] + if k.lower() == "show_msg" and isinstance(v, str) and not self.show_msg: + self.show_msg = v + del self.other[k] + + if k.lower() == "dbname" and isinstance(v, str) and not self.dbname: + self.dbname = v + del self.other[k] + + if k.lower() == "show_oper" and isinstance(v, str) and not self.show_oper: + self.show_oper = v + del self.other[k] + + if k.lower() == "rollup_db" and isinstance(v, bool) and not self.rollup_db: + self.rollup_db = v + del self.other[k] + + + +# from ...pytest.util.sql import * +# from ...pytest.util.constant import * class TDTestCase: + updatecfgDict = {"querySmaOptimize": 1} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) + self.precision = "ms" + self.sma_count = 0 + self.sma_created_index = [] """ create sma index : @@ -155,13 +194,17 @@ class TDTestCase: if sma.func: sql += f" function({', '.join(sma.func)})" if sma.interval: - sql += f" interval({', '.join(sma.interval)})" + interval, offset = self.__get_interval_offset(sma.interval) + if offset: + sql += f" interval({interval}, {offset})" + else: + sql += f" interval({interval})" if sma.sliding: sql += f" sliding({sma.sliding})" if sma.watermark: sql += f" watermark {sma.watermark}" - if sma.maxdelay: - sql += f" maxdelay {sma.maxdelay}" + if sma.max_delay: + sql += f" max_delay {sma.max_delay}" if isinstance(sma.other, dict): for k,v in sma.other.items(): if isinstance(v,tuple) or isinstance(v, list): @@ -171,53 +214,305 @@ class TDTestCase: if isinstance(sma.other, tuple) or isinstance(sma.other, list): sql += " ".join(sma.other) if isinstance(sma.other, int) or isinstance(sma.other, float) or isinstance(sma.other, str): - sql += sma.other + sql += f" {sma.other}" return sql - def sma_create_check(self, sma:SMAschema): + def __get_sma_func_col(self, func): + cols = [] + if isinstance(func, str): + cols.append( func.split("(")[-1].split(")")[0] ) + elif isinstance(func, tuple) or isinstance(func, list): + for func_col in func: + cols.append(func_col.split("(")[-1].split(")")[0]) + else: + cols = [] + return cols + + def __check_sma_func(self, func:tuple): + if not isinstance(func, str) and not isinstance(func, tuple) and not isinstance(func, list): + return False + if isinstance(func, str) : + if "(" not in func or ")" not in func: + return False + if func.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS: + return False + if func.split("(")[1].split(")")[0] not in ALL_COL and func.split("(")[1].split(")")[0] not in TAG_COL : + return False + if isinstance(func, tuple) or isinstance(func, list): + for arg in func: + if not isinstance(arg, str): + return False + if "(" not in arg or ")" not in arg: + return False + if arg.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS: + return False + if arg.split("(")[1].split(")")[0] not in ALL_COL and arg.split("(")[1].split(")")[0] not in TAG_COL : + return False + return True + + def __check_sma_watermark(self, arg): + if not arg: + return False + if not isinstance(arg, str): + return False + if arg[-1] not in SMA_WATMARK_MAXDELAY_INIT: + return False + if len(arg) == 1: + return False + if not arg[:-1].isdecimal(): + return False + if tdSql.get_times(arg) > WATERMARK_MAX: + return False + if tdSql.get_times(arg) < WATERMARK_MIN: + return False + + return True + + def __check_sma_max_delay(self, arg): + if not self.__check_sma_watermark(arg): + return False + if tdSql.get_times(arg) < MAX_DELAY_MIN: + return False + + return True + + def __check_sma_sliding(self, arg): + if not isinstance(arg, str): + return False + if arg[-1] not in TAOS_TIME_INIT: + return False + if len(arg) == 1: + return False + if not arg[:-1].isdecimal(): + return False + + return True + + def __get_interval_offset(self, args): + if isinstance(args, str): + interval, offset = args, None + elif isinstance(args,tuple) or isinstance(args, list): + if len(args) == 1: + interval, offset = args[0], None + elif len(args) == 2: + interval, offset = args + else: + interval, offset = False, False + else: + interval, offset = False, False + + return interval, offset + + def __check_sma_interval(self, args): + if not isinstance(args, tuple) and not isinstance(args,str): + return False + interval, offset = self.__get_interval_offset(args) + if not interval: + return False + if not self.__check_sma_sliding(interval): + return False + if tdSql.get_times(interval) < INTERVAL_MIN: + return False + if offset: + if not self.__check_sma_sliding(offset): + return False + if tdSql.get_times(interval) <= tdSql.get_times(offset) : + return False + + return True + + def __sma_create_check(self, sma:SMAschema): + if self.updatecfgDict["querySmaOptimize"] == 0: + return False + # # TODO: if database is a rollup-db, can not create sma index + # tdSql.query("select database()") + # if sma.rollup_db : + # return False tdSql.query("show stables") + if not sma.tbname: + return False stb_in_list = False for row in tdSql.queryResult: if sma.tbname == row[0]: stb_in_list = True - break if not stb_in_list: - tdSql.error(self.__create_sma_index(sma)) - if not sma.creation: - tdSql.error(self.__create_sma_index(sma)) - if not sma.index_flag: - tdSql.error(self.__create_sma_index(sma)) - if not sma.index_name: - tdSql.error(self.__create_sma_index(sma)) - if not sma.operator: - tdSql.error(self.__create_sma_index(sma)) - if not sma.tbname: - tdSql.error(self.__create_sma_index(sma)) - if not sma.func: - tdSql.error(self.__create_sma_index(sma)) - if not sma.interval: - tdSql.error(self.__create_sma_index(sma)) - if not sma.sliding: - tdSql.error(self.__create_sma_index(sma)) + return False + if not sma.creation or not isinstance(sma.creation, str) or sma.creation.upper() != "CREATE": + return False + if not sma.index_flag or not isinstance(sma.index_flag, str) or sma.index_flag.upper() != "SMA INDEX" : + return False + if not sma.index_name or not isinstance(sma.index_name, str) or sma.index_name.upper() in TAOS_KEYWORDS: + return False + if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON": + return False + + if not sma.func or not self.__check_sma_func(sma.func): + return False + tdSql.query(f"desc {sma.tbname}") + _col_list = [] + for col_row in tdSql.queryResult: + _col_list.append(col_row[0]) + _sma_func_cols = self.__get_sma_func_col(sma.func) + for _sma_func_col in _sma_func_cols: + if _sma_func_col not in _col_list: + return False + + if sma.sliding and not self.__check_sma_sliding(sma.sliding): + return False + interval, _ = self.__get_interval_offset(sma.interval) + if not sma.interval or not self.__check_sma_interval(sma.interval) : + return False + if sma.sliding and tdSql.get_times(interval) < tdSql.get_times(sma.sliding): + return False + if sma.watermark and not self.__check_sma_watermark(sma.watermark): + return False + if sma.max_delay and not self.__check_sma_max_delay(sma.max_delay): + return False if sma.other: + return False + + return True + + def sma_create_check(self, sma:SMAschema): + if self.__sma_create_check(sma): + tdSql.query(self.__create_sma_index(sma)) + self.sma_count += 1 + self.sma_created_index.append(sma.index_name) + tdSql.query("show streams") + tdSql.checkRows(self.sma_count) + + else: tdSql.error(self.__create_sma_index(sma)) + def __drop_sma_index(self, sma:SMAschema): + sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}" + return sql + + def __sma_drop_check(self, sma:SMAschema): + if not sma.drop: + return False + if not sma.drop_flag: + return False + if not sma.index_name: + return False + + return True + + def sma_drop_check(self, sma:SMAschema): + if self.__sma_drop_check(sma): + tdSql.query(self.__drop_sma_index(sma)) + print(self.__drop_sma_index(sma)) + self.sma_count -= 1 + self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index)) + tdSql.query("show streams") + tdSql.checkRows(self.sma_count) + + else: + tdSql.error(self.__drop_sma_index(sma)) + + def __show_sma_index(self, sma:SMAschema): + sql = f"{sma.show} {sma.show_msg} {sma.show_oper} {sma.tbname}" + return sql + + def __sma_show_check(self, sma:SMAschema): + if not sma.show: + return False + if not sma.show_msg: + return False + if not sma.show_oper: + return False + if not sma.tbname: + return False + + return True + + def sma_show_check(self, sma:SMAschema): + if self.__sma_show_check(sma): + tdSql.query(self.__show_sma_index(sma)) + tdSql.checkRows(self.sma_count) + else: + tdSql.error(self.__show_sma_index(sma)) + + @property + def __create_sma_sql(self): + err_sqls = [] + cur_sqls = [] + # err_set + # # case 1: required fields check + err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(func=("",),tbname=STBNAME ) ) + err_sqls.append( SMAschema(interval=(""),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + # # case 2: err fields + err_sqls.append( SMAschema(creation="show",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(creation="alter",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(creation="select",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + err_sqls.append( SMAschema(index_flag="SMA INDEXES", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_flag="SMA INDEX ,", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_name="tbname", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + + # current_set + + cur_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + cur_sqls.append( SMAschema(watermark="",index_name="sma_index_2",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + cur_sqls.append( SMAschema(sliding="",index_name='sma_index_3',tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + + return err_sqls, cur_sqls + + def test_create_sma(self): + err_sqls , cur_sqls = self.__create_sma_sql + for err_sql in err_sqls: + self.sma_create_check(err_sql) + for cur_sql in cur_sqls: + self.sma_create_check(cur_sql) + + @property + def __drop_sma_sql(self): + err_sqls = [] + cur_sqls = [] + # err_set + ## case 1: required fields check + err_sqls.append( SMAschema(drop="") ) + err_sqls.append( SMAschema(drop_flag="") ) + err_sqls.append( SMAschema(index_name="") ) + + for index in self.sma_created_index: + cur_sqls.append(SMAschema(index_name=index)) + + return err_sqls, cur_sqls + + def test_drop_sma(self): + err_sqls , cur_sqls = self.__drop_sma_sql + for err_sql in err_sqls: + self.sma_drop_check(err_sql) + # for cur_sql in cur_sqls: + # self.sma_drop_check(cur_sql) def all_test(self): + self.test_create_sma() + self.test_drop_sma() + pass def __create_tb(self): tdLog.printNoPrefix("==========step: create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {STBNAME}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned - ) tags (tag1 int) + ) tags ({INT_TAG} int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {NTBNAME}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, @@ -253,6 +548,7 @@ class TDTestCase: return data_set def __insert_data(self): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") data = self.__data_set(rows=self.rows) # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -278,7 +574,7 @@ class TDTestCase: tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") + f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )") @@ -295,28 +591,31 @@ class TDTestCase: f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )") def run(self): - sma1 = SMAschema(func=("min(c1)","max(c2)")) - sql1 = self.__create_sma_index(sma1) - print("================") - print(sql1) - # a = DataSet() - # return self.rows = 10 tdLog.printNoPrefix("==========step0:all check") - # self.all_test() tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() - self.__insert_data() + # self.__insert_data() + self.all_test() + + # drop databases, create same name db、stb and sma index + # tdSql.prepare() + # self.__create_tb() + # self.__insert_data() + # self.all_test() + + + return tdLog.printNoPrefix("==========step2:create table in rollup database") diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index 244cccb041..961a6446b5 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -23,7 +23,6 @@ class TDTestCase: self.time_step = 1000 def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ): - tdLog.info(" prepare datas for auto check abs function ") tdSql.execute(" create database test ") @@ -36,7 +35,7 @@ class TDTestCase: ts = self.ts for row in range(rownums): - ts += time_step*row + ts = self.ts + time_step*row c1 = random.randint(0,10000) c2 = random.randint(0,100000) c3 = random.randint(0,125) @@ -538,25 +537,41 @@ class TDTestCase: # tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash tdSql.query("select c1 ,t1 from stb1 where t1 =0 ") tdSql.checkRows(13) - # tdSql.query("select t1 from stb1 where t1 >0 ") - # tdSql.checkRows(3) + tdSql.query("select t1 from stb1 where t1 >0 ") + tdSql.checkRows(3) + tdSql.query("select t1 from stb1 where t1 =3 ") + tdSql.checkRows(1) # tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)") # tdSql.checkData(0,0,61) # tdSql.query("select distinct(c1) ,t1 from stb1") # tdSql.checkRows(20) - # tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") - # tdSql.checkData(0,3,33333) + tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") + tdSql.checkData(0,3,33333) # tag filter with abs function - # tdSql.query("select t1 from stb1 where abs(t1)=1") - # tdSql.checkRows(1) + tdSql.query("select t1 from stb1 where abs(t1)=1") + tdSql.checkRows(1) tdSql.query("select t1 from stb1 where abs(c1+t1)=1") tdSql.checkRows(1) - # tdSql.query("select t1 from stb1 where abs(t1+c1)=1") - # tdSql.checkRows(1) + tdSql.checkData(0,0,0) + tdSql.query( "select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") + def support_super_table_test(self): + tdSql.execute(" use testdb ") + self.check_result_auto( " select c1 from stb1 order by ts " , "select abs(c1) from stb1 order by ts" ) + self.check_result_auto( " select c1 from stb1 order by tbname " , "select abs(c1) from stb1 order by tbname" ) + self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c1 from stb1 order by ts " , "select t1, abs(c1) from stb1 order by ts" ) + self.check_result_auto( " select t2,c1 from stb1 order by tbname " , "select t2 ,abs(c1) from stb1 order by tbname" ) + self.check_result_auto( " select t3,c1 from stb1 where c1 > 0 order by tbname " , "select t3 ,abs(c1) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t4,c1 from stb1 where c1 > 0 order by tbname " , "select t4 , abs(c1) from stb1 where c1 > 0 order by tbname" ) + pass + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -593,6 +608,10 @@ class TDTestCase: self.insert_datas_and_check_abs(self.tb_nums,self.row_nums,self.time_step) + tdLog.printNoPrefix("==========step8: check abs result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/arccos.py b/tests/system-test/2-query/arccos.py index e15f7675f2..edb9e25c11 100644 --- a/tests/system-test/2-query/arccos.py +++ b/tests/system-test/2-query/arccos.py @@ -479,6 +479,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_acos("select num1,num2 from tb3;" , "select acos(num1),acos(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_acos( " select c5 from stb1 order by ts " , "select acos(c5) from stb1 order by ts" ) + self.check_result_auto_acos( " select c5 from stb1 order by tbname " , "select acos(c5) from stb1 order by tbname" ) + self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_acos( " select t1,c5 from stb1 order by ts " , "select acos(t1), acos(c5) from stb1 order by ts" ) + self.check_result_auto_acos( " select t1,c5 from stb1 order by tbname " , "select acos(t1) ,acos(c5) from stb1 order by tbname" ) + self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) ,acos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) , acos(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -512,6 +526,14 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: acos filter query ============") + + self.abs_func_filter() + + tdLog.printNoPrefix("==========step8: check acos result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/arcsin.py b/tests/system-test/2-query/arcsin.py index ee134a56a8..faed5ef3c4 100644 --- a/tests/system-test/2-query/arcsin.py +++ b/tests/system-test/2-query/arcsin.py @@ -479,6 +479,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_asin("select num1,num2 from tb3;" , "select asin(num1),asin(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_asin( " select c5 from stb1 order by ts " , "select asin(c5) from stb1 order by ts" ) + self.check_result_auto_asin( " select c5 from stb1 order by tbname " , "select asin(c5) from stb1 order by tbname" ) + self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_asin( " select t1,c5 from stb1 order by ts " , "select asin(t1), asin(c5) from stb1 order by ts" ) + self.check_result_auto_asin( " select t1,c5 from stb1 order by tbname " , "select asin(t1) ,asin(c5) from stb1 order by tbname" ) + self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) ,asin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) , asin(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -512,6 +526,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check asin result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/arctan.py b/tests/system-test/2-query/arctan.py index 1890c4605c..80d28b5ee5 100644 --- a/tests/system-test/2-query/arctan.py +++ b/tests/system-test/2-query/arctan.py @@ -476,6 +476,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_atan("select num1,num2 from tb3;" , "select atan(num1),atan(num2) from tb3") + + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_atan( " select c5 from stb1 order by ts " , "select atan(c5) from stb1 order by ts" ) + self.check_result_auto_atan( " select c5 from stb1 order by tbname " , "select atan(c5) from stb1 order by tbname" ) + self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_atan( " select t1,c5 from stb1 order by ts " , "select atan(t1), atan(c5) from stb1 order by ts" ) + self.check_result_auto_atan( " select t1,c5 from stb1 order by tbname " , "select atan(t1) ,atan(c5) from stb1 order by tbname" ) + self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) ,atan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) , atan(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +523,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check arctan result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/ceil.py b/tests/system-test/2-query/ceil.py index 4196a5a8ce..b269b54a17 100644 --- a/tests/system-test/2-query/ceil.py +++ b/tests/system-test/2-query/ceil.py @@ -427,6 +427,18 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select ceil(c1+1) ,ceil(c2) , ceil(c3*1) , ceil(c4/2), ceil(c5)/2, ceil(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select ceil(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select ceil(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select ceil(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select ceil(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select ceil(t1), ceil(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select ceil(t1) ,ceil(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select ceil(t1) ,ceil(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select ceil(t1) , ceil(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -455,6 +467,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check ceil result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/cos.py b/tests/system-test/2-query/cos.py index 0cb9f66937..1165d8d681 100644 --- a/tests/system-test/2-query/cos.py +++ b/tests/system-test/2-query/cos.py @@ -476,6 +476,19 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_cos("select num1,num2 from tb3;" , "select cos(num1),cos(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_cos( " select c5 from stb1 order by ts " , "select cos(c5) from stb1 order by ts" ) + self.check_result_auto_cos( " select c5 from stb1 order by tbname " , "select cos(c5) from stb1 order by tbname" ) + self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_cos( " select t1,c5 from stb1 order by ts " , "select cos(t1), cos(c5) from stb1 order by ts" ) + self.check_result_auto_cos( " select t1,c5 from stb1 order by tbname " , "select cos(t1) ,cos(c5) from stb1 order by tbname" ) + self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) ,cos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) , cos(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +522,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check cos result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/floor.py b/tests/system-test/2-query/floor.py index c955c24e05..7362191958 100644 --- a/tests/system-test/2-query/floor.py +++ b/tests/system-test/2-query/floor.py @@ -427,6 +427,19 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select floor(c1+1) ,floor(c2) , floor(c3*1) , floor(c4/2), floor(c5)/2, floor(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select floor(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select floor(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select floor(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select floor(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select floor(t1), floor(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select floor(t1) ,floor(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select floor(t1) ,floor(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select floor(t1) , floor(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -454,6 +467,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check floor result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/join.py b/tests/system-test/2-query/join.py index 5ff11c84dd..df6390f59c 100644 --- a/tests/system-test/2-query/join.py +++ b/tests/system-test/2-query/join.py @@ -28,7 +28,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def __query_condition(self,tbname): query_condition = [] diff --git a/tests/system-test/2-query/join2.py b/tests/system-test/2-query/join2.py index 40da41eee7..5533cb840e 100644 --- a/tests/system-test/2-query/join2.py +++ b/tests/system-test/2-query/join2.py @@ -28,7 +28,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def __query_condition(self,tbname): query_condition = [] diff --git a/tests/system-test/2-query/log.py b/tests/system-test/2-query/log.py index 907ba329ee..f9d6e91199 100644 --- a/tests/system-test/2-query/log.py +++ b/tests/system-test/2-query/log.py @@ -670,7 +670,19 @@ class TDTestCase: tdSql.checkData(0,2,math.log(32767.000000000,2)) tdSql.checkData(0,3,math.log(63.500000000,2)) tdSql.checkData(0,4,63.999401166) - + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_log2( " select c5 from stb1 order by ts " , "select log(c5,2) from stb1 order by ts" ) + self.check_result_auto_log2( " select c5 from stb1 order by tbname " , "select log(c5,2) from stb1 order by tbname" ) + self.check_result_auto_log2( " select c5 from stb1 where c1 > 0 order by tbname " , "select log(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log2( " select c5 from stb1 where c1 > 0 order by tbname " , "select log(c5,2) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_log2( " select t1,c5 from stb1 order by ts " , "select log(t1,2), log(c5,2) from stb1 order by ts" ) + self.check_result_auto_log2( " select t1,c5 from stb1 order by tbname " , "select log(t1,2) ,log(c5,2) from stb1 order by tbname" ) + self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) ,log(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) , log(c5,2) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -707,7 +719,9 @@ class TDTestCase: self.abs_func_filter() - + tdLog.printNoPrefix("==========step9: check log result of stable query ============") + + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/pow.py b/tests/system-test/2-query/pow.py index 8b0137b411..c67162961b 100644 --- a/tests/system-test/2-query/pow.py +++ b/tests/system-test/2-query/pow.py @@ -606,7 +606,23 @@ class TDTestCase: tdSql.checkData(0,3,math.pow(63.500000000,2)) tdSql.checkData(0,5,None) + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_pow2( " select c5 from stb1 order by ts " , "select pow(c5,2) from stb1 order by ts" ) + self.check_result_auto_pow2( " select c5 from stb1 order by tbname " , "select pow(c5,2) from stb1 order by tbname" ) + self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_pow2( " select t1,c5 from stb1 order by ts " , "select pow(t1,2), pow(c5,2) from stb1 order by ts" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 order by tbname" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) , pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + pass + + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -642,7 +658,9 @@ class TDTestCase: self.abs_func_filter() - + tdLog.printNoPrefix("==========step9: check pow result of stable query ============") + + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/round.py b/tests/system-test/2-query/round.py index 223e56bce6..cc272abf42 100644 --- a/tests/system-test/2-query/round.py +++ b/tests/system-test/2-query/round.py @@ -432,6 +432,20 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select round(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select round(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select round(t1), round(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select round(t1) ,round(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) ,round(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) , round(c5) from stb1 where c1 > 0 order by tbname" ) + pass + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -459,6 +473,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check round result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/sin.py b/tests/system-test/2-query/sin.py index 62d42a991e..2c4d90d3e7 100644 --- a/tests/system-test/2-query/sin.py +++ b/tests/system-test/2-query/sin.py @@ -476,6 +476,19 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_sin("select num1,num2 from tb3;" , "select sin(num1),sin(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_sin( " select c5 from stb1 order by ts " , "select sin(c5) from stb1 order by ts" ) + self.check_result_auto_sin( " select c5 from stb1 order by tbname " , "select sin(c5) from stb1 order by tbname" ) + self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sin( " select t1,c5 from stb1 order by ts " , "select sin(t1), sin(c5) from stb1 order by ts" ) + self.check_result_auto_sin( " select t1,c5 from stb1 order by tbname " , "select sin(t1) ,sin(c5) from stb1 order by tbname" ) + self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) ,sin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) , sin(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +522,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check sin result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/sqrt.py b/tests/system-test/2-query/sqrt.py index 28e869e044..772056fd93 100644 --- a/tests/system-test/2-query/sqrt.py +++ b/tests/system-test/2-query/sqrt.py @@ -505,7 +505,19 @@ class TDTestCase: tdSql.checkData(0,2,math.sqrt(32767.000000000)) tdSql.checkData(0,3,math.sqrt(63.500000000)) - + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_sqrt( " select c5 from stb1 order by ts " , "select sqrt(c5) from stb1 order by ts" ) + self.check_result_auto_sqrt( " select c5 from stb1 order by tbname " , "select sqrt(c5) from stb1 order by tbname" ) + self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sqrt( " select t1,c5 from stb1 order by ts " , "select sqrt(t1), sqrt(c5) from stb1 order by ts" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 order by tbname" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) , sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -541,6 +553,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step9: check sqrt result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/substr.py b/tests/system-test/2-query/substr.py index 79b5ac515b..f833a42b57 100644 --- a/tests/system-test/2-query/substr.py +++ b/tests/system-test/2-query/substr.py @@ -31,7 +31,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(),False) def __substr_condition(self): # sourcery skip: extract-method substr_condition = [] diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index 0e2110f912..a4c85cc5ed 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -188,8 +188,8 @@ class TDTestCase: def check_tail_table(self , tbname , col_name , tail_rows , offset): tail_sql = f"select tail({col_name} , {tail_rows} , {offset}) from {tbname}" - equal_sql = f"select {col_name} from (select ts , {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}) order by ts" - #equal_sql = f"select {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}" + #equal_sql = f"select {col_name} from (select ts , {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}) order by ts" + equal_sql = f"select {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}" tdSql.query(tail_sql) tail_result = tdSql.queryResult @@ -404,7 +404,7 @@ class TDTestCase: f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - tdSql.query("select tail(c2,2) from sub1_bound") + tdSql.query("select tail(c2,2) from sub1_bound order by 1 desc") tdSql.checkRows(2) tdSql.checkData(0,0,9223372036854775803) diff --git a/tests/system-test/2-query/tan.py b/tests/system-test/2-query/tan.py index c8914d18c0..9610ffef24 100644 --- a/tests/system-test/2-query/tan.py +++ b/tests/system-test/2-query/tan.py @@ -476,6 +476,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_tan("select num1,num2 from tb3;" , "select tan(num1),tan(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_tan( " select c5 from stb1 order by ts " , "select tan(c5) from stb1 order by ts" ) + self.check_result_auto_tan( " select c5 from stb1 order by tbname " , "select tan(c5) from stb1 order by tbname" ) + self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_tan( " select t1,c5 from stb1 order by ts " , "select tan(t1), tan(c5) from stb1 order by ts" ) + self.check_result_auto_tan( " select t1,c5 from stb1 order by tbname " , "select tan(t1) ,tan(c5) from stb1 order by tbname" ) + self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) ,tan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) , tan(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +523,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check tan result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index f910ff1439..aeebf2425a 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -266,7 +266,7 @@ class TDTestCase: tdSql.query("select unique(c1) from ct4") tdSql.checkRows(10) - tdSql.error("select unique(c1),tbname from ct1") + #tdSql.error("select unique(c1),tbname from ct1") #support #tdSql.error("select unique(c1),t1 from ct1") #support # unique with common col diff --git a/tests/system-test/7-tmq/stbTagFilter.py b/tests/system-test/7-tmq/stbTagFilter.py new file mode 100644 index 0000000000..2a2cb40c09 --- /dev/null +++ b/tests/system-test/7-tmq/stbTagFilter.py @@ -0,0 +1,113 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db2', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 10, + 'rowsPerTbl': 1000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum'], ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data") + tmqCom.asyncInsertData(paraDict) + + tdLog.info("create topics from stb with filter") + # queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where t2 == 'beijing' or t2 == 'changsha'" %(paraDict['dbName'], paraDict['stbName']) + queryString = "select * from %s.%s where t2 == 'beijing' or t2 == 'changsha'" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # start tmq consume processor + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 + topicList = topicNameList[0] + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:2000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + # tmqCom.getStartCommitNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() + tdLog.info("create some new ctb") + paraDict['ctbStartIdx'] = paraDict['ctbStartIdx'] + paraDict['ctbNum'] + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum'], ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data into new ctb") + pThread = tmqCom.asyncInsertData(paraDict) + + pThread.join() + tdLog.info("wait insert end") + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCheckData1.py b/tests/system-test/7-tmq/tmqCheckData1.py new file mode 100644 index 0000000000..6cf849d1b9 --- /dev/null +++ b/tests/system-test/7-tmq/tmqCheckData1.py @@ -0,0 +1,180 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) + else: + break + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1', 'topic2', 'topic3'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("insert data") + tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdLog.info("create topics from stb with filter") + queryString = "select ts,c1,c2 from %s.%s" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as stable %s.%s" %(topicNameList[0], paraDict["dbName"],paraDict["stbName"]) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as database %s" %(topicNameList[1], paraDict['dbName']) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + consumerId = 1 + topicList = topicNameList[1] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[1] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0])) + tdLog.exit("1 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[2], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + consumerId = 2 + topicList = topicNameList[2] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[2] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) + tdLog.exit("2 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 788ae3474c..9254f57c40 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -159,7 +159,7 @@ class TMQCom: tdLog.debug("complete to create %s.%s" %(dbName, stbName)) return - def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): + def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1,ctbStartIdx=0): tsql.execute("use %s" %dbName) pre_create = "create table" sql = pre_create @@ -168,8 +168,10 @@ class TMQCom: tagValue = 'beijing' if (i % 2 == 0): tagValue = 'shanghai' + elif (i % 3 == 0): + tagValue = 'changsha' - sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) + sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i+ctbStartIdx,stbName,i+ctbStartIdx+1, tagValue) if (i > 0) and (i%100 == 0): tsql.execute(sql) sql = pre_create @@ -235,7 +237,7 @@ class TMQCom: tdLog.debug("insert data ............ [OK]") return - def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): + def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs,ctbStartIdx=0): tdLog.debug("start to insert data ............") tsql.execute("use %s" %dbName) pre_insert = "insert into " @@ -245,7 +247,7 @@ class TMQCom: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) for i in range(ctbNum): - sql += " %s%d values "%(ctbPrefix,i) + sql += " %s%d values "%(ctbPrefix,i+ctbStartIdx) for j in range(rowsPerTbl): if (j % 2 == 0): sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, j, j) @@ -254,7 +256,7 @@ class TMQCom: if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): tsql.execute(sql) if j < rowsPerTbl - 1: - sql = "insert into %s%d values " %(ctbPrefix,i) + sql = "insert into %s%d values " %(ctbPrefix,i+ctbStartIdx) else: sql = "insert into " #end sql @@ -354,7 +356,10 @@ class TMQCom: def threadFunctionForInsert(self, **paraDict): # create new connector for new tdSql instance in my thread newTdSql = tdCom.newTdSql() - self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + if 'ctbStartIdx' in paraDict.keys(): + self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"],paraDict["ctbStartIdx"]) + else: + self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) return def asyncInsertData(self, paraDict): diff --git a/tests/system-test/fulltest.bat b/tests/system-test/fulltest.bat deleted file mode 100644 index 59ddd3fb7d..0000000000 --- a/tests/system-test/fulltest.bat +++ /dev/null @@ -1,102 +0,0 @@ - -python3 .\test.py -f 0-others\taosShell.py -python3 .\test.py -f 0-others\taosShellError.py -python3 .\test.py -f 0-others\taosShellNetChk.py -python3 .\test.py -f 0-others\telemetry.py -python3 .\test.py -f 0-others\taosdMonitor.py -python3 .\test.py -f 0-others\udfTest.py -python3 .\test.py -f 0-others\udf_create.py -python3 .\test.py -f 0-others\udf_restart_taosd.py -python3 .\test.py -f 0-others\cachelast.py - -python3 .\test.py -f 0-others\user_control.py -python3 .\test.py -f 0-others\fsync.py - -python3 .\test.py -f 1-insert\influxdb_line_taosc_insert.py -python3 .\test.py -f 1-insert\opentsdb_telnet_line_taosc_insert.py -python3 .\test.py -f 1-insert\opentsdb_json_taosc_insert.py -@REM #python3 .\test.py -f 1-insert\test_stmt_muti_insert_query.py -python3 .\test.py -f 1-insert\alter_stable.py -python3 .\test.py -f 1-insert\alter_table.py -python3 .\test.py -f 2-query\between.py -python3 .\test.py -f 2-query\distinct.py -python3 .\test.py -f 2-query\varchar.py -python3 .\test.py -f 2-query\ltrim.py -python3 .\test.py -f 2-query\rtrim.py -python3 .\test.py -f 2-query\length.py -python3 .\test.py -f 2-query\char_length.py -python3 .\test.py -f 2-query\upper.py -python3 .\test.py -f 2-query\lower.py -python3 .\test.py -f 2-query\join.py -python3 .\test.py -f 2-query\join2.py -python3 .\test.py -f 2-query\cast.py -python3 .\test.py -f 2-query\union.py -python3 .\test.py -f 2-query\union1.py -python3 .\test.py -f 2-query\concat.py -python3 .\test.py -f 2-query\concat2.py -python3 .\test.py -f 2-query\concat_ws.py -python3 .\test.py -f 2-query\concat_ws2.py -python3 .\test.py -f 2-query\check_tsdb.py -python3 .\test.py -f 2-query\spread.py -python3 .\test.py -f 2-query\hyperloglog.py - -python3 .\test.py -f 2-query\timezone.py -python3 .\test.py -f 2-query\Now.py -python3 .\test.py -f 2-query\Today.py -python3 .\test.py -f 2-query\max.py -python3 .\test.py -f 2-query\min.py -python3 .\test.py -f 2-query\count.py -python3 .\test.py -f 2-query\last.py -python3 .\test.py -f 2-query\first.py -python3 .\test.py -f 2-query\To_iso8601.py -python3 .\test.py -f 2-query\To_unixtimestamp.py -python3 .\test.py -f 2-query\timetruncate.py -python3 .\test.py -f 2-query\diff.py -python3 .\test.py -f 2-query\Timediff.py - -python3 .\test.py -f 2-query\top.py -python3 .\test.py -f 2-query\bottom.py -python3 .\test.py -f 2-query\percentile.py -python3 .\test.py -f 2-query\apercentile.py -python3 .\test.py -f 2-query\abs.py -python3 .\test.py -f 2-query\ceil.py -python3 .\test.py -f 2-query\floor.py -python3 .\test.py -f 2-query\round.py -python3 .\test.py -f 2-query\log.py -python3 .\test.py -f 2-query\pow.py -python3 .\test.py -f 2-query\sqrt.py -python3 .\test.py -f 2-query\sin.py -python3 .\test.py -f 2-query\cos.py -python3 .\test.py -f 2-query\tan.py -python3 .\test.py -f 2-query\arcsin.py -python3 .\test.py -f 2-query\arccos.py -python3 .\test.py -f 2-query\arctan.py -python3 .\test.py -f 2-query\query_cols_tags_and_or.py -@REM # python3 .\test.py -f 2-query\nestedQuery.py -@REM # TD-15983 subquery output duplicate name column. -@REM # Please Xiangyang Guo modify the following script -@REM # python3 .\test.py -f 2-query\nestedQuery_str.py - -python3 .\test.py -f 2-query\avg.py -python3 .\test.py -f 2-query\elapsed.py -python3 .\test.py -f 2-query\csum.py -python3 .\test.py -f 2-query\mavg.py -python3 .\test.py -f 2-query\diff.py -python3 .\test.py -f 2-query\sample.py -python3 .\test.py -f 2-query\function_diff.py -python3 .\test.py -f 2-query\unique.py -python3 .\test.py -f 2-query\stateduration.py -python3 .\test.py -f 2-query\function_stateduration.py -python3 .\test.py -f 2-query\statecount.py - -python3 .\test.py -f 7-tmq\basic5.py -python3 .\test.py -f 7-tmq\subscribeDb.py -python3 .\test.py -f 7-tmq\subscribeDb0.py -python3 .\test.py -f 7-tmq\subscribeDb1.py -python3 .\test.py -f 7-tmq\subscribeStb.py -python3 .\test.py -f 7-tmq\subscribeStb0.py -python3 .\test.py -f 7-tmq\subscribeStb1.py -python3 .\test.py -f 7-tmq\subscribeStb2.py -python3 .\test.py -f 7-tmq\subscribeStb3.py -python3 .\test.py -f 7-tmq\subscribeStb4.py -python3 .\test.py -f 7-tmq\db.py \ No newline at end of file diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 28b227761a..b0b8aa7108 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -146,6 +146,7 @@ python3 ./test.py -f 7-tmq/tmqError.py python3 ./test.py -f 7-tmq/schema.py python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py +python3 ./test.py -f 7-tmq/tmqCheckData1.py python3 ./test.py -f 7-tmq/tmqUdf.py #python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 python3 ./test.py -f 7-tmq/tmqConsumerGroup.py diff --git a/tests/system-test/test-all.bat b/tests/system-test/test-all.bat index adc9e0ce28..d4032cbc0d 100644 --- a/tests/system-test/test-all.bat +++ b/tests/system-test/test-all.bat @@ -6,19 +6,23 @@ if "%1" == "full" ( echo Windows Taosd Full Test set /a exitNum=0 del /Q /F failed.txt - set caseFile="fulltest.bat" + set caseFile="fulltest.sh" if not "%2" == "" ( set caseFile="%2" ) for /F "usebackq tokens=*" %%i in (!caseFile!) do ( - for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" ( - set /a a+=1 - echo !a! Processing %%i - call :GetTimeSeconds !time! - set time1=!_timeTemp! - echo Start at !time! - call %%i ARG1 > result_!a!.txt 2>error_!a!.txt - if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + call :CheckSkipCase %%i + if !skipCase! == false ( + set line=%%i + if "!line:~,7!" == "python3" ( + set /a a+=1 + echo !a! Processing %%i + call :GetTimeSeconds !time! + set time1=!_timeTemp! + echo Start at !time! + call %%i ARG1 > result_!a!.txt 2>error_!a!.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + ) ) ) exit !exitNum! @@ -83,3 +87,8 @@ for %%a in (%tt%) do ( ) set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% goto :eof + +:CheckSkipCase +set skipCase=false +if "%*" == "python3 ./test.py -f 1-insert/insertWithMoreVgroup.py" ( set skipCase=true ) +:goto eof \ No newline at end of file diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index cd6613b17a..2037f67089 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -339,8 +339,8 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { shell.info.clientVersion = "Welcome to the TDengine shell from %s, Client Version:%s\n" "Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\n\n"; - shell.info.promptHeader = "taos> "; - shell.info.promptContinue = " -> "; + shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER; + shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE; shell.info.promptSize = 6; snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version); diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index f236c1eb88..9cb3541017 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -411,8 +411,9 @@ char taosGetConsoleChar() { static char mbStr[5]; static unsigned long bufLen = 0; static uint16_t bufIndex = 0, mbStrIndex = 0, mbStrLen = 0; - if (bufLen == 0) { + while (bufLen == 0) { ReadConsoleW(console, buf, SHELL_INPUT_MAX_COMMAND_SIZE, &bufLen, NULL); + if (bufLen > 0 && buf[0] == 0) bufLen = 0; bufIndex = 0; } if (mbStrLen == 0){ @@ -466,6 +467,8 @@ int32_t shellReadCommand(char *command) { } else if (c < '\033') { // Ctrl keys. TODO: Implement ctrl combinations switch (c) { + case 0: + break; case 1: // ctrl A shellPositionCursorHome(&cmd); break; diff --git a/tools/taos-tools b/tools/taos-tools index a875a057d1..28a49b447f 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit a875a057d1225d85c6323b9edaccc2b1a9641987 +Subproject commit 28a49b447f71c4f014ebbac858b7215b897d57fd