diff --git a/.gitignore b/.gitignore index b62bd62d9c..3044348648 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ compile_commands.json .tasks .vimspector.json .vscode/ +.vscode .idea/ cmake-build-debug/ cmake-build-release/ diff --git a/2.0/src/query/inc/qExecutor.h b/2.0/src/query/inc/qExecutor.h index 967101fb41..34b306b129 100644 --- a/2.0/src/query/inc/qExecutor.h +++ b/2.0/src/query/inc/qExecutor.h @@ -179,7 +179,7 @@ typedef struct SQueryCostInfo { uint32_t totalBlocks; uint32_t loadBlocks; uint32_t loadBlockStatis; - uint32_t discardBlocks; + uint32_t skipBlocks; uint64_t elapsedTime; uint64_t firstStageMergeTime; uint64_t winInfoSize; diff --git a/2.0/src/query/src/qExecutor.c b/2.0/src/query/src/qExecutor.c index 1e879c3912..0c37a3d330 100644 --- a/2.0/src/query/src/qExecutor.c +++ b/2.0/src/query/src/qExecutor.c @@ -3144,7 +3144,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) { qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - pCost->discardBlocks += 1; + pCost->skipBlocks += 1; } else if ((*status) == BLK_DATA_STATIS_NEEDED) { // this function never returns error? pCost->loadBlockStatis += 1; @@ -3184,7 +3184,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockStatis[i].min), (char*)&(pBlock->pBlockStatis[i].max)); if (!load) { // current block has been discard due to filter applied - pCost->discardBlocks += 1; + pCost->skipBlocks += 1; qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); (*status) = BLK_DATA_DISCARD; @@ -3196,7 +3196,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa // current block has been discard due to filter applied if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) { - pCost->discardBlocks += 1; + pCost->skipBlocks += 1; qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); (*status) = BLK_DATA_DISCARD; diff --git a/CMakeLists.txt b/CMakeLists.txt index 0603055e3c..e1fbd54be3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ include(${TD_SUPPORT_DIR}/cmake.platform) include(${TD_SUPPORT_DIR}/cmake.define) include(${TD_SUPPORT_DIR}/cmake.options) include(${TD_SUPPORT_DIR}/cmake.version) +include(${TD_SUPPORT_DIR}/cmake.install) # contrib add_subdirectory(contrib) diff --git a/cmake/cmake.install b/cmake/cmake.install new file mode 100644 index 0000000000..5a05c0c7dc --- /dev/null +++ b/cmake/cmake.install @@ -0,0 +1,28 @@ +IF (TD_LINUX) + SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/make_install.sh") + INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") + INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})") +ELSEIF (TD_WINDOWS) + SET(CMAKE_INSTALL_PREFIX C:/TDengine) + + INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/go DESTINATION connector) + INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/nodejs DESTINATION connector) + INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector) + INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector) + INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .) + INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg) + INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taos.h DESTINATION include) + INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taoserror.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.exp DESTINATION driver) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) + + IF (TD_MVN_INSTALLED) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc) + ENDIF () +ELSEIF (TD_DARWIN) + SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh") + INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") + INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Darwin ${TD_VER_NUMBER})") +ENDIF () diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 54bb83d244..fe5f8cf7ed 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -18,15 +18,15 @@ target_sources(demoapi ) target_link_libraries(tmq - taos + taos_static ) target_link_libraries(tstream - taos + taos_static ) target_link_libraries(demoapi - taos + taos_static ) target_include_directories(tmq diff --git a/include/common/tmsg.h b/include/common/tmsg.h index cab8fea374..8c30f7d280 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -70,11 +70,7 @@ typedef uint16_t tmsg_t; #define TSDB_IE_TYPE_DNODE_EXT 6 #define TSDB_IE_TYPE_DNODE_STATE 7 -enum { - CONN_TYPE__QUERY = 1, - CONN_TYPE__TMQ, - CONN_TYPE__MAX -}; +enum { CONN_TYPE__QUERY = 1, CONN_TYPE__TMQ, CONN_TYPE__MAX }; enum { HEARTBEAT_KEY_DBINFO = 1, @@ -257,22 +253,16 @@ typedef struct { SSubmitRspBlock failedBlocks[]; } SSubmitRsp; +#define SCHEMA_SMA_ON 0x1 +#define SCHEMA_IDX_ON 0x2 typedef struct SSchema { int8_t type; - int8_t index; // default is 0, not index created + int8_t flags; col_id_t colId; int32_t bytes; char name[TSDB_COL_NAME_LEN]; } SSchema; -typedef struct { - int8_t type; - int8_t sma; // ETsdbBSmaType and default is TSDB_BSMA_TYPE_I - col_id_t colId; - int32_t bytes; - char name[TSDB_COL_NAME_LEN]; -} SSchemaEx; - #define SSCHMEA_TYPE(s) ((s)->type) #define SSCHMEA_SMA(s) ((s)->sma) #define SSCHMEA_COLID(s) ((s)->colId) @@ -342,13 +332,13 @@ int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); typedef struct { - int32_t acctId; - int64_t clusterId; + int32_t acctId; + int64_t clusterId; uint32_t connId; - int8_t superUser; - int8_t connType; - SEpSet epSet; - char sVersion[128]; + int8_t superUser; + int8_t connType; + SEpSet epSet; + char sVersion[128]; } SConnectRsp; int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp); @@ -663,14 +653,13 @@ typedef struct { int32_t outputLen; int32_t bufSize; int64_t signature; - int32_t commentSize; - int32_t codeSize; - char pComment[TSDB_FUNC_COMMENT_LEN]; - char pCode[TSDB_FUNC_CODE_LEN]; + char* pComment; + char* pCode; } SCreateFuncReq; int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq); int32_t tDeserializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq); +void tFreeSCreateFuncReq(SCreateFuncReq* pReq); typedef struct { char name[TSDB_FUNC_NAME_LEN]; @@ -687,6 +676,7 @@ typedef struct { int32_t tSerializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq); int32_t tDeserializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq); +void tFreeSRetrieveFuncReq(SRetrieveFuncReq* pReq); typedef struct { char name[TSDB_FUNC_NAME_LEN]; @@ -698,8 +688,8 @@ typedef struct { int64_t signature; int32_t commentSize; int32_t codeSize; - char pComment[TSDB_FUNC_COMMENT_LEN]; - char pCode[TSDB_FUNC_CODE_LEN]; + char* pComment; + char* pCode; } SFuncInfo; typedef struct { @@ -709,6 +699,7 @@ typedef struct { int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp); int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp); +void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp); typedef struct { int32_t statusInterval; @@ -1213,12 +1204,12 @@ typedef struct { #define STREAM_TRIGGER_WINDOW_CLOSE 2 typedef struct { - char name[TSDB_TOPIC_FNAME_LEN]; - char outputSTbName[TSDB_TABLE_FNAME_LEN]; - int8_t igExists; - char* sql; - char* ast; - int8_t triggerType; + char name[TSDB_TOPIC_FNAME_LEN]; + char outputSTbName[TSDB_TABLE_FNAME_LEN]; + int8_t igExists; + char* sql; + char* ast; + int8_t triggerType; int64_t watermark; } SCMCreateStreamReq; @@ -1457,7 +1448,7 @@ typedef struct SVCreateTbReq { tb_uid_t suid; col_id_t nCols; col_id_t nBSmaCols; - SSchemaEx* pSchema; + SSchema* pSchema; col_id_t nTagCols; SSchema* pTagSchema; SRSmaParam* pRSmaParam; @@ -1469,7 +1460,7 @@ typedef struct SVCreateTbReq { struct { col_id_t nCols; col_id_t nBSmaCols; - SSchemaEx* pSchema; + SSchema* pSchema; SRSmaParam* pRSmaParam; } ntbCfg; }; @@ -1671,14 +1662,14 @@ typedef struct { int32_t pid; char fqdn[TSDB_FQDN_LEN]; int32_t subPlanNum; - SArray* subDesc; // SArray + SArray* subDesc; // SArray } SQueryDesc; typedef struct { - uint32_t connId; - int32_t pid; - char app[TSDB_APP_NAME_LEN]; - SArray* queryDesc; // SArray + uint32_t connId; + int32_t pid; + char app[TSDB_APP_NAME_LEN]; + SArray* queryDesc; // SArray } SQueryHbReqBasic; typedef struct { @@ -1742,7 +1733,7 @@ static FORCE_INLINE void tFreeClientHbReq(void* pReq) { } taosMemoryFreeClear(req->query); } - + if (req->info) { tFreeReqKvHash(req->info); taosHashCleanup(req->info); @@ -2034,16 +2025,13 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq) typedef struct { uint32_t nCols; - union { - SSchema* pSchema; - SSchemaEx* pSchemaEx; - }; + SSchema* pSchema; } SSchemaWrapper; static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) { int32_t tlen = 0; tlen += taosEncodeFixedI8(buf, pSchema->type); - tlen += taosEncodeFixedI8(buf, pSchema->index); + tlen += taosEncodeFixedI8(buf, pSchema->flags); tlen += taosEncodeFixedI32(buf, pSchema->bytes); tlen += taosEncodeFixedI16(buf, pSchema->colId); tlen += taosEncodeString(buf, pSchema->name); @@ -2052,7 +2040,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) { buf = taosDecodeFixedI8(buf, &pSchema->type); - buf = taosDecodeFixedI8(buf, &pSchema->index); + buf = taosDecodeFixedI8(buf, &pSchema->flags); buf = taosDecodeFixedI32(buf, &pSchema->bytes); buf = taosDecodeFixedI16(buf, &pSchema->colId); buf = taosDecodeStringTo(buf, pSchema->name); @@ -2061,7 +2049,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) { static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSchema) { if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1; - if (tEncodeI8(pEncoder, pSchema->index) < 0) return -1; + if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1; if (tEncodeI32(pEncoder, pSchema->bytes) < 0) return -1; if (tEncodeI16(pEncoder, pSchema->colId) < 0) return -1; if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1; @@ -2070,7 +2058,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) { if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1; - if (tDecodeI8(pDecoder, &pSchema->index) < 0) return -1; + if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1; if (tDecodeI32(pDecoder, &pSchema->bytes) < 0) return -1; if (tDecodeI16(pDecoder, &pSchema->colId) < 0) return -1; if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1; diff --git a/include/common/trow.h b/include/common/trow.h index 282921087c..dbbdef84a0 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -48,9 +48,12 @@ extern "C" { #define TD_VTYPE_NONE 0x02U // none or unknown/undefined #define TD_VTYPE_MAX 0x03U // -#define TD_VTYPE_NORM_BYTE 0x0U -#define TD_VTYPE_NULL_BYTE 0x55U -#define TD_VTYPE_NONE_BYTE 0xAAU +#define TD_VTYPE_NORM_BYTE_I 0x0U +#define TD_VTYPE_NULL_BYTE_I 0xFFU + +#define TD_VTYPE_NORM_BYTE_II 0x0U +#define TD_VTYPE_NULL_BYTE_II 0x55U +#define TD_VTYPE_NONE_BYTE_II 0xAAU #define TD_ROWS_ALL_NORM 0x00U #define TD_ROWS_NULL_NORM 0x01U @@ -222,8 +225,12 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, T static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType); static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int8_t bitmapMode); int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode); -static FORCE_INLINE int32_t tdGetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT *pValType); -static FORCE_INLINE int32_t tdGetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT *pValType); +static FORCE_INLINE int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType); +static FORCE_INLINE int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType); +static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, + int8_t bitmapMode); +static FORCE_INLINE bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode); +bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode); int32_t tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int32_t numOfRows, int32_t maxPoints, int8_t bitmapMode); static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, @@ -231,7 +238,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId); -int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols); +int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols); /** * @brief @@ -325,7 +332,16 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, return TSDB_CODE_SUCCESS; } -static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) { +static FORCE_INLINE bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) { + TDRowValT valType = 0; + tdGetBitmapValType(pBitmap, idx, &valType, bitmapMode); + if (tdValTypeIsNorm(valType)) { + return true; + } + return false; +} + +static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) { switch (bitmapMode) { case 0: tdGetBitmapValTypeII(pBitmap, colIdx, pValType); @@ -350,7 +366,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD * @param pValType * @return FORCE_INLINE */ -static FORCE_INLINE int32_t tdGetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT *pValType) { +static FORCE_INLINE int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { TASSERT(0); terrno = TSDB_CODE_INVALID_PARA; @@ -449,7 +465,7 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, T * @param pValType * @return FORCE_INLINE */ -static FORCE_INLINE int32_t tdGetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT *pValType) { +static FORCE_INLINE int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { TASSERT(0); terrno = TSDB_CODE_INVALID_PARA; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 63ebbd9879..c98e5bf99d 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -195,45 +195,46 @@ #define TK_CAST 177 #define TK_NOW 178 #define TK_TODAY 179 -#define TK_COUNT 180 -#define TK_FIRST 181 -#define TK_LAST 182 -#define TK_LAST_ROW 183 -#define TK_BETWEEN 184 -#define TK_IS 185 -#define TK_NK_LT 186 -#define TK_NK_GT 187 -#define TK_NK_LE 188 -#define TK_NK_GE 189 -#define TK_NK_NE 190 -#define TK_MATCH 191 -#define TK_NMATCH 192 -#define TK_CONTAINS 193 -#define TK_JOIN 194 -#define TK_INNER 195 -#define TK_SELECT 196 -#define TK_DISTINCT 197 -#define TK_WHERE 198 -#define TK_PARTITION 199 -#define TK_BY 200 -#define TK_SESSION 201 -#define TK_STATE_WINDOW 202 -#define TK_SLIDING 203 -#define TK_FILL 204 -#define TK_VALUE 205 -#define TK_NONE 206 -#define TK_PREV 207 -#define TK_LINEAR 208 -#define TK_NEXT 209 -#define TK_GROUP 210 -#define TK_HAVING 211 -#define TK_ORDER 212 -#define TK_SLIMIT 213 -#define TK_SOFFSET 214 -#define TK_LIMIT 215 -#define TK_OFFSET 216 -#define TK_ASC 217 -#define TK_NULLS 218 +#define TK_TIMEZONE 180 +#define TK_COUNT 181 +#define TK_FIRST 182 +#define TK_LAST 183 +#define TK_LAST_ROW 184 +#define TK_BETWEEN 185 +#define TK_IS 186 +#define TK_NK_LT 187 +#define TK_NK_GT 188 +#define TK_NK_LE 189 +#define TK_NK_GE 190 +#define TK_NK_NE 191 +#define TK_MATCH 192 +#define TK_NMATCH 193 +#define TK_CONTAINS 194 +#define TK_JOIN 195 +#define TK_INNER 196 +#define TK_SELECT 197 +#define TK_DISTINCT 198 +#define TK_WHERE 199 +#define TK_PARTITION 200 +#define TK_BY 201 +#define TK_SESSION 202 +#define TK_STATE_WINDOW 203 +#define TK_SLIDING 204 +#define TK_FILL 205 +#define TK_VALUE 206 +#define TK_NONE 207 +#define TK_PREV 208 +#define TK_LINEAR 209 +#define TK_NEXT 210 +#define TK_GROUP 211 +#define TK_HAVING 212 +#define TK_ORDER 213 +#define TK_SLIMIT 214 +#define TK_SOFFSET 215 +#define TK_LIMIT 216 +#define TK_OFFSET 217 +#define TK_ASC 218 +#define TK_NULLS 219 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 23b260849d..7f2e59ea85 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -248,8 +248,8 @@ typedef struct tDataTypeDescriptor { int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); int32_t (*decompFunc)(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output, int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize); - void (*statisFunc)(const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minindex, - int16_t *maxindex, int16_t *numofnull); + void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull); } tDataTypeDescriptor; extern tDataTypeDescriptor tDataTypes[15]; diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 9d4f554c2c..01e03a983d 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -53,6 +53,11 @@ typedef struct SScanLogicNode { double ratio; SNodeList* pDynamicScanFuncs; int32_t dataRequired; + int64_t interval; + int64_t offset; + int64_t sliding; + int8_t intervalUnit; + int8_t slidingUnit; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -208,6 +213,11 @@ typedef struct STableScanPhysiNode { double ratio; int32_t dataRequired; SNodeList* pDynamicScanFuncs; + int64_t interval; + int64_t offset; + int64_t sliding; + int8_t intervalUnit; + int8_t slidingUnit; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; @@ -264,7 +274,6 @@ typedef struct SIntervalPhysiNode { int64_t sliding; int8_t intervalUnit; int8_t slidingUnit; - uint8_t precision; SFillNode* pFill; } SIntervalPhysiNode; @@ -346,8 +355,11 @@ typedef struct SQueryPlan { int32_t numOfSubplans; SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0. SExplainInfo explainInfo; + SNodeList* pPlaceholderValues; } SQueryPlan; +void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 3e78da63de..d2f73e4071 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -57,6 +57,7 @@ typedef enum EColumnType { typedef struct SColumnNode { SExprNode node; // QUERY_NODE_COLUMN uint64_t tableId; + int8_t tableType; col_id_t colId; EColumnType colType; // column or tag char dbName[TSDB_DB_NAME_LEN]; @@ -81,6 +82,7 @@ typedef struct SValueNode { bool isDuration; bool translate; bool genByCalc; + int16_t placeholderNo; union { bool b; int64_t i; @@ -196,8 +198,8 @@ typedef struct SStateWindowNode { typedef struct SSessionWindowNode { ENodeType type; // QUERY_NODE_SESSION_WINDOW - SNode* pCol; // timestamp primary key - SNode* pGap; // gap between two session window(in microseconds) + SColumnNode* pCol; // timestamp primary key + SValueNode* pGap; // gap between two session window(in microseconds) } SSessionWindowNode; typedef struct SIntervalWindowNode { diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index 0b164bf43f..f343295c56 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -21,6 +21,7 @@ extern "C" { #endif #include "plannodes.h" +#include "taos.h" typedef struct SPlanContext { uint64_t queryId; @@ -32,6 +33,7 @@ typedef struct SPlanContext { bool showRewrite; int8_t triggerType; int64_t watermark; + bool isStmtQuery; } SPlanContext; // Create the physical plan for the query, according to the AST. @@ -43,6 +45,9 @@ 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); +typedef TAOS_MULTI_BIND TAOS_BIND_v2; // todo remove +int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_BIND_v2* pParams); + // 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/scalar/scalar.h b/include/libs/scalar/scalar.h index 49af10cd2c..7d765bf139 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -80,6 +80,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 4efe69e204..92d9319d5c 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -36,12 +36,12 @@ void *taosMemoryStrDup(void *ptr); void taosMemoryFree(void *ptr); int32_t taosMemorySize(void *ptr); -#define taosMemoryFreeClear(ptr) \ - do { \ - if (ptr) { \ - taosMemoryFree((void*)ptr); \ - (ptr) = NULL; \ - } \ +#define taosMemoryFreeClear(ptr) \ + do { \ + if (ptr) { \ + taosMemoryFree((void *)ptr); \ + (ptr) = NULL; \ + } \ } while (0) #ifdef __cplusplus diff --git a/include/os/osThread.h b/include/os/osThread.h index a145b0da07..18c1b290ab 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -22,6 +22,10 @@ extern "C" { #endif +#ifndef __USE_XOPEN2K +typedef pthread_mutex_t pthread_spinlock_t; +#endif + typedef pthread_t TdThread; typedef pthread_spinlock_t TdThreadSpinlock; typedef pthread_mutex_t TdThreadMutex; @@ -33,8 +37,6 @@ typedef pthread_rwlockattr_t TdThreadRwlockAttr; typedef pthread_cond_t TdThreadCond; typedef pthread_condattr_t TdThreadCondAttr; typedef pthread_key_t TdThreadKey; -typedef pthread_barrier_t TdThreadBarrier; -typedef pthread_barrierattr_t TdThreadBarrierAttr; #define taosThreadCleanupPush pthread_cleanup_push #define taosThreadCleanupPop pthread_cleanup_pop @@ -156,13 +158,6 @@ int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_para int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy); int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope); int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize); -int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier); -int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count); -int32_t taosThreadBarrierWait(TdThreadBarrier * barrier); -int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr); -int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared); -int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr); -int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared); int32_t taosThreadCancel(TdThread thread); int32_t taosThreadCondDestroy(TdThreadCond * cond); int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index d51217874a..c5b477343d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -579,7 +579,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612) #define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613) #define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614) -#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615) +#define TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615) #define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616) #define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617) #define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618) @@ -598,6 +598,17 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625) #define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626) #define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627) +#define TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628) +#define TSDB_CODE_PAR_INVALID_STATE_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2629) +#define TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE TAOS_DEF_ERROR_CODE(0, 0x262A) +#define TSDB_CODE_PAR_INTER_SESSION_GAP TAOS_DEF_ERROR_CODE(0, 0x262B) +#define TSDB_CODE_PAR_INTER_SESSION_COL TAOS_DEF_ERROR_CODE(0, 0x262C) +#define TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE TAOS_DEF_ERROR_CODE(0, 0x262D) +#define TSDB_CODE_PAR_INTER_OFFSET_UNIT TAOS_DEF_ERROR_CODE(0, 0x262E) +#define TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x262F) +#define TSDB_CODE_PAR_INTER_SLIDING_UNIT TAOS_DEF_ERROR_CODE(0, 0x2630) +#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631) +#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632) //planner #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) diff --git a/include/util/tdef.h b/include/util/tdef.h index 5fc30540ee..5b863f5920 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -128,17 +128,17 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_QUERIES "queries" #define TSDB_INS_TABLE_VNODES "vnodes" -#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" -#define TSDB_PERFS_TABLE_CONNECTIONS "connections" -#define TSDB_PERFS_TABLE_QUERIES "queries" -#define TSDB_PERFS_TABLE_TOPICS "topics" -#define TSDB_PERFS_TABLE_CONSUMERS "consumers" -#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes" +#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" +#define TSDB_PERFS_TABLE_CONNECTIONS "connections" +#define TSDB_PERFS_TABLE_QUERIES "queries" +#define TSDB_PERFS_TABLE_TOPICS "topics" +#define TSDB_PERFS_TABLE_CONSUMERS "consumers" +#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes" #define TSDB_INDEX_TYPE_SMA "SMA" #define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT" -#define TSDB_INS_USER_STABLES_DBNAME_COLID 2 +#define TSDB_INS_USER_STABLES_DBNAME_COLID 2 #define TSDB_TICK_PER_SECOND(precision) \ ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \ @@ -234,8 +234,8 @@ typedef enum ELogicConditionType { #define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_FUNC_NAME_LEN 65 -#define TSDB_FUNC_COMMENT_LEN 4096 -#define TSDB_FUNC_CODE_LEN (65535 - 512) +#define TSDB_FUNC_COMMENT_LEN 1024 * 1024 +#define TSDB_FUNC_CODE_LEN 10 * 1024 * 1024 #define TSDB_FUNC_BUF_SIZE 512 #define TSDB_FUNC_TYPE_SCALAR 1 #define TSDB_FUNC_TYPE_AGGREGATE 2 @@ -339,12 +339,12 @@ typedef enum ELogicConditionType { #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 6 -#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute +#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute #define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) #define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute -#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. +#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. #define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MIN_ROW_FBLOCK 10 @@ -419,11 +419,11 @@ typedef enum ELogicConditionType { #define TSDB_DEFAULT_EXPLAIN_VERBOSE false -#define TSDB_MIN_EXPLAIN_RATIO 0 -#define TSDB_MAX_EXPLAIN_RATIO 1 -#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001 +#define TSDB_MIN_EXPLAIN_RATIO 0 +#define TSDB_MAX_EXPLAIN_RATIO 1 +#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001 -#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024 +#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024 #define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN" #define TSDB_MAX_JOIN_TABLE_NUM 10 @@ -509,13 +509,13 @@ enum { SND_WORKER_TYPE__UNIQUE, }; -#define MNODE_HANDLE -1 -#define QNODE_HANDLE 1 +#define MNODE_HANDLE -1 +#define QNODE_HANDLE 1 #define DEFAULT_HANDLE 0 -#define TSDB_CONFIG_OPTION_LEN 16 -#define TSDB_CONIIG_VALUE_LEN 48 -#define TSDB_CONFIG_NUMBER 8 +#define TSDB_CONFIG_OPTION_LEN 16 +#define TSDB_CONIIG_VALUE_LEN 48 +#define TSDB_CONFIG_NUMBER 8 #define QUERY_ID_SIZE 20 #define QUERY_OBJ_ID_SIZE 18 @@ -524,7 +524,6 @@ enum { #define MAX_NUM_STR_SIZE 40 - #ifdef __cplusplus } #endif diff --git a/packaging/make_install.sh b/packaging/make_install.sh new file mode 100755 index 0000000000..f70f176a40 --- /dev/null +++ b/packaging/make_install.sh @@ -0,0 +1,657 @@ +#!/bin/bash +# +# This file is used to install TAOS time-series database on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +#set -x + +# -----------------------Variables definition +source_dir=$1 +binary_dir=$2 +osType=$3 +verNumber=$4 + +if [ "$osType" != "Darwin" ]; then + script_dir=$(dirname $(readlink -f "$0")) +else + script_dir=${source_dir}/packaging/tools +fi + +# Dynamic directory +clientName="taos" +serverName="taosd" +logDir="/var/log/taos" +dataDir="/var/lib/taos" +configDir="/etc/taos" +configFile="taos.cfg" +installDir="/usr/local/taos" +productName="TDengine" +emailName="taosdata.com" +uninstallScript="rmtaos" + +if [ "$osType" != "Darwin" ]; then + data_dir=${dataDir} + log_dir=${logDir} + + cfg_install_dir=${configDir} + + bin_link_dir="/usr/bin" + lib_link_dir="/usr/lib" + lib64_link_dir="/usr/lib64" + inc_link_dir="/usr/include" + + install_main_dir=${installDir} + + bin_dir="${installDir}/bin" +else + data_dir="/usr/local${dataDir}" + log_dir="/usr/local${logDir}" + + cfg_install_dir="/usr/local${configDir}" + + bin_link_dir="/usr/local/bin" + lib_link_dir="/usr/local/lib" + inc_link_dir="/usr/local/include" + + install_main_dir="/usr/local/Cellar/tdengine/${verNumber}" + install_main_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}" + + bin_dir="/usr/local/Cellar/tdengine/${verNumber}/bin" + bin_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}/bin" +fi + +service_config_dir="/etc/systemd/system" + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +csudo="" + +service_mod=2 +os_type=0 + +if [ "$osType" != "Darwin" ]; then + if command -v sudo >/dev/null; then + csudo="sudo " + fi + initd_mod=0 + if pidof systemd &>/dev/null; then + service_mod=0 + elif $(which service &>/dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &>/dev/null); then + initd_mod=1 + elif $(which insserv &>/dev/null); then + initd_mod=2 + elif $(which update-rc.d &>/dev/null); then + initd_mod=3 + else + service_mod=2 + fi + else + service_mod=2 + fi + + # get the operating system type for using the corresponding init file + # ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification + #osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) + osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) + #echo "osinfo: ${osinfo}" + if echo $osinfo | grep -qwi "ubuntu"; then + echo "this is ubuntu system" + os_type=1 + elif echo $osinfo | grep -qwi "debian"; then + echo "this is debian system" + os_type=1 + elif echo $osinfo | grep -qwi "Kylin"; then + echo "this is Kylin system" + os_type=1 + elif echo $osinfo | grep -qwi "centos"; then + echo "this is centos system" + os_type=2 + elif echo $osinfo | grep -qwi "fedora"; then + echo "this is fedora system" + os_type=2 + else + echo "${osinfo}: This is an officially unverified linux system, If there are any problems with the installation and operation, " + echo "please feel free to contact ${emailName} for support." + os_type=1 + fi +fi + +function kill_taosadapter() { + pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo}kill -9 $pid || : + fi +} + +function kill_taosd() { + ps -ef | grep ${serverName} + pid=$(ps -ef | grep -w ${serverName} | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo}kill -9 $pid || : + fi +} + +function install_main_path() { + #create install main dir and all sub dir + if [ "$osType" != "Darwin" ]; then + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + # ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + # ${csudo}mkdir -p ${install_main_dir}/init.d + else + ${csudo}rm -rf ${install_main_dir} || ${csudo}rm -rf ${install_main_2_dir} || : + ${csudo}mkdir -p ${install_main_dir} || ${csudo}mkdir -p ${install_main_2_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg || ${csudo}mkdir -p ${install_main_2_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin || ${csudo}mkdir -p ${install_main_2_dir}/bin + # ${csudo}mkdir -p ${install_main_dir}/connector || ${csudo}mkdir -p ${install_main_2_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver || ${csudo}mkdir -p ${install_main_2_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples || ${csudo}mkdir -p ${install_main_2_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include || ${csudo}mkdir -p ${install_main_2_dir}/include + fi +} + +function install_bin() { + # Remove links + ${csudo}rm -f ${bin_link_dir}/${clientName} || : + ${csudo}rm -f ${bin_link_dir}/${serverName} || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + + if [ "$osType" != "Darwin" ]; then + ${csudo}rm -f ${bin_link_dir}/perfMonitor || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : + + ${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosBenchmark ] && ${csudo}cp -r ${binary_dir}/build/bin/taosBenchmark ${install_main_dir}/bin || : + [ -f ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -sf ${install_main_dir}/bin/taosBenchmark ${install_main_dir}/bin/taosdemo || : + [ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || : + ${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || : + ${csudo}cp -r ${binary_dir}/build/bin/tarbitrator ${install_main_dir}/bin || : + + ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || : + ${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin || : + ${csudo}cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin || : + ${csudo}cp -r ${script_dir}/run_taosd_and_taosadapter.sh ${install_main_dir}/bin || : + ${csudo}cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin || : + + ${csudo}chmod 0555 ${install_main_dir}/bin/* + #Make link + [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : + [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : + [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : + [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : + [ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : + else + + ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || : + ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || : + ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin || : + ${csudo}chmod 0555 ${install_main_dir}/bin/* || ${csudo}chmod 0555 ${install_main_2_dir}/bin/* + #Make link + [ -x ${install_main_dir}/bin/${clientName} ] || [ -x ${install_main_2_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || ${csudo}ln -s ${install_main_2_dir}/bin/${clientName} || : + [ -x ${install_main_dir}/bin/${serverName} ] || [ -x ${install_main_2_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || ${csudo}ln -s ${install_main_2_dir}/bin/${serverName} || : + [ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo}ln -s ${install_main_2_dir}/bin/taosadapter || : + [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + fi +} + +function install_jemalloc() { + if [ "$osType" != "Darwin" ]; then + /usr/bin/install -c -d /usr/local/bin + + if [ -f "${binary_dir}/build/bin/jemalloc-config" ]; then + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin + fi + if [ -f "${binary_dir}/build/bin/jemalloc.sh" ]; then + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin + fi + if [ -f "${binary_dir}/build/bin/jeprof" ]; then + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin + fi + if [ -f "${binary_dir}/build/include/jemalloc/jemalloc.h" ]; then + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h \ + /usr/local/include/jemalloc + fi + if [ -f "${binary_dir}/build/lib/libjemalloc.so.2" ]; then + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib + [ -f ${binary_dir}/build/lib/libjemalloc.a ] && + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib + [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ] && + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib + if [ -f "${binary_dir}/build/lib/pkgconfig/jemalloc.pc" ]; then + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc \ + /usr/local/lib/pkgconfig + fi + if [ -d /etc/ld.so.conf.d ]; then + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig + else + echo "/etc/ld.so.conf.d not found!" + fi + fi + if [ -f "${binary_dir}/build/share/doc/jemalloc/jemalloc.html" ]; then + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html \ + /usr/local/share/doc/jemalloc + fi + if [ -f "${binary_dir}/build/share/man/man3/jemalloc.3" ]; then + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3 \ + /usr/local/share/man/man3 + fi + fi +} + +function install_avro() { + if [ "$osType" != "Darwin" ]; then + if [ -f "${binary_dir}/build/$1/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then + ${csudo}/usr/bin/install -c -d /usr/local/$1 + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1 + ${csudo}ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23 + ${csudo}ln -sf libavro.so.23 /usr/local/$1/libavro.so + ${csudo}/usr/bin/install -c -d /usr/local/$1 + [ -f ${binary_dir}/build/$1/libavro.a ] && + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1 + + if [ -d /etc/ld.so.conf.d ]; then + echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf" + ${csudo}ldconfig + else + echo "/etc/ld.so.conf.d not found!" + fi + fi + fi +} + +function install_lib() { + # Remove links + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + if [ "$osType" != "Darwin" ]; then + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + fi + + if [ "$osType" != "Darwin" ]; then + ${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \ + ${install_main_dir}/driver && + ${csudo}chmod 777 ${install_main_dir}/driver/* + + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + + if [ -d "${lib64_link_dir}" ]; then + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 + ${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so + fi + else + ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ + ${install_main_dir}/driver || + ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ + ${install_main_2_dir}/driver && + ${csudo}chmod 777 ${install_main_dir}/driver/* || + ${csudo}chmod 777 ${install_main_2_dir}/driver/* + + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* \ + ${install_main_dir}/driver/libtaos.1.dylib || + ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.* \ + ${install_main_2_dir}/driver/libtaos.1.dylib || : + + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.1.dylib \ + ${install_main_dir}/driver/libtaos.dylib || + ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \ + ${install_main_2_dir}/driver/libtaos.dylib || : + + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \ + ${lib_link_dir}/libtaos.1.dylib || + ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \ + ${lib_link_dir}/libtaos.1.dylib || : + + ${csudo}ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : + fi + + install_jemalloc + install_avro lib + install_avro lib64 + + if [ "$osType" != "Darwin" ]; then + ${csudo}ldconfig + fi +} + +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 \ + ${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 + else + ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.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 \ + ${install_main_2_dir}/include && + ${csudo}chmod 644 ${install_main_dir}/include/* || + ${csudo}chmod 644 ${install_main_2_dir}/include/* + fi +} + +function install_config() { + if [ ! -f ${cfg_install_dir}/${configFile} ]; then + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/../cfg/${configFile} ] && + ${csudo}cp ${script_dir}/../cfg/${configFile} ${cfg_install_dir} || : + ${csudo}chmod 644 ${cfg_install_dir}/${configFile} + ${csudo}cp -f ${script_dir}/../cfg/${configFile} \ + ${cfg_install_dir}/${configFile}.${verNumber} || : + ${csudo}ln -s ${cfg_install_dir}/${configFile} \ + ${install_main_dir}/cfg/${configFile} + else + ${csudo}cp -f ${script_dir}/../cfg/${configFile} \ + ${cfg_install_dir}/${configFile}.${verNumber} || : + fi +} + +function install_taosadapter_config() { + if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then + ${csudo}mkdir -p ${cfg_install_dir} || : + [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} || : + [ -f ${cfg_install_dir}/taosadapter.toml ] && + ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml || : + [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && + ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \ + ${cfg_install_dir}/taosadapter.toml.${verNumber} || : + [ -f ${cfg_install_dir}/taosadapter.toml ] && + ${csudo}ln -s ${cfg_install_dir}/taosadapter.toml \ + ${install_main_dir}/cfg/taosadapter.toml || : + else + if [ -f "${binary_dir}/test/cfg/taosadapter.toml" ]; then + ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \ + ${cfg_install_dir}/taosadapter.toml.${verNumber} || : + fi + fi +} + +function install_log() { + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} + if [ "$osType" != "Darwin" ]; then + ${csudo}ln -s ${log_dir} ${install_main_dir}/log + else + ${csudo}ln -s ${log_dir} ${install_main_dir}/log || ${csudo}ln -s ${log_dir} ${install_main_2_dir}/log + fi +} + +function install_data() { + ${csudo}mkdir -p ${data_dir} + if [ "$osType" != "Darwin" ]; then + ${csudo}ln -s ${data_dir} ${install_main_dir}/data + else + ${csudo}ln -s ${data_dir} ${install_main_dir}/data || ${csudo}ln -s ${data_dir} ${install_main_2_dir}/data + fi +} + +function install_connector() { + if find ${source_dir}/src/connector/go -mindepth 1 -maxdepth 1 | read; then + ${csudo}cp -r ${source_dir}/src/connector/go ${install_main_dir}/connector || : + else + echo "WARNING: go connector not found, please check if want to use it!" + fi + if [ "$osType" != "Darwin" ]; then + ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || : + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || : + else + ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_2_dir}/connector || : + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || : + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_2_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_2_dir}/connector/*.jar || echo &>/dev/null || : + fi +} + +function install_examples() { + if [ "$osType" != "Darwin" ]; then + ${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || : + else + ${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || ${csudo}cp -rf ${source_dir}/examples/* ${install_main_2_dir}/examples || : + fi +} + +function clean_service_on_sysvinit() { + if pidof ${serverName} &>/dev/null; then + ${csudo}service ${serverName} stop || : + fi + + if ((${initd_mod} == 1)); then + ${csudo}chkconfig --del ${serverName} || : + elif ((${initd_mod} == 2)); then + ${csudo}insserv -r ${serverName} || : + elif ((${initd_mod} == 3)); then + ${csudo}update-rc.d -f ${serverName} remove || : + fi + + ${csudo}rm -f ${service_config_dir}/${serverName} || : + + if $(which init &>/dev/null); then + ${csudo}init q || : + fi +} + +function install_service_on_sysvinit() { + clean_service_on_sysvinit + + sleep 1 + + if ((${os_type} == 1)); then + # ${csudo}cp -f ${script_dir}/../deb/${serverName} ${install_main_dir}/init.d + ${csudo}cp ${script_dir}/../deb/${serverName} ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/${serverName} || : + elif ((${os_type} == 2)); then + # ${csudo}cp -f ${script_dir}/../rpm/${serverName} ${install_main_dir}/init.d + ${csudo}cp ${script_dir}/../rpm/${serverName} ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/${serverName} || : + fi + + if ((${initd_mod} == 1)); then + ${csudo}chkconfig --add ${serverName} || : + ${csudo}chkconfig --level 2345 ${serverName} on || : + elif ((${initd_mod} == 2)); then + ${csudo}insserv ${serverName} || : + ${csudo}insserv -d ${serverName} || : + elif ((${initd_mod} == 3)); then + ${csudo}update-rc.d ${serverName} defaults || : + fi +} + +function clean_service_on_systemd() { + taosd_service_config="${service_config_dir}/${serverName}.service" + + if systemctl is-active --quiet ${serverName}; then + echo "${productName} is running, stopping it..." + ${csudo}systemctl stop ${serverName} &>/dev/null || echo &>/dev/null + fi + ${csudo}systemctl disable ${serverName} &>/dev/null || echo &>/dev/null + + ${csudo}rm -f ${taosd_service_config} +} + +function install_service_on_systemd() { + clean_service_on_systemd + + taosd_service_config="${service_config_dir}/${serverName}.service" + + ${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Description=${productName} server service' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/${serverName}' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=${installDir}/bin/startPre.sh' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" + ${csudo}systemctl enable ${serverName} +} + +function install_taosadapter_service() { + if ((${service_mod} == 0)); then + [ -f ${binary_dir}/test/cfg/taosadapter.service ] && + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.service \ + ${service_config_dir}/ || : + ${csudo}systemctl daemon-reload + fi +} + +function install_service() { + if ((${service_mod} == 0)); then + install_service_on_systemd + elif ((${service_mod} == 1)); then + install_service_on_sysvinit + else + kill_taosd + fi +} + +function update_TDengine() { + echo -e "${GREEN}Start to update ${productName}...${NC}" + # Stop the service if running + + if pidof ${serverName} &>/dev/null; then + if ((${service_mod} == 0)); then + ${csudo}systemctl stop ${serverName} || : + elif ((${service_mod} == 1)); then + ${csudo}service ${serverName} stop || : + else + kill_taosadapter + kill_taosd + fi + sleep 1 + fi + + install_main_path + + install_log + install_header + install_lib + # install_connector + install_examples + install_bin + + install_service + install_taosadapter_service + + install_config + install_taosadapter_config + + echo + echo -e "\033[44;32;1m${productName} is updated successfully!${NC}" + echo + + echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" + echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit ${configDir}/taosadapter.toml" + if ((${service_mod} == 0)); then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" + elif ((${service_mod} == 1)); then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" + else + echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" + fi + + echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}" + echo + echo -e "\033[44;32;1m${productName} is updated successfully!${NC}" +} + +function install_TDengine() { + # Start to install + echo -e "${GREEN}Start to install ${productName}...${NC}" + + install_main_path + + install_data + install_log + install_header + install_lib + # install_connector + install_examples + install_bin + + install_service + install_taosadapter_service + + install_config + install_taosadapter_config + + # Ask if to start the service + echo + echo -e "\033[44;32;1m${productName} is installed successfully!${NC}" + echo + echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" + echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit ${configDir}/taosadapter.toml" + if ((${service_mod} == 0)); then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" + elif ((${service_mod} == 1)); then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" + else + echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}" + fi + + echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}" + echo + echo -e "\033[44;32;1m${productName} is installed successfully!${NC}" +} + +## ==============================Main program starts from here============================ +echo source directory: $1 +echo binary directory: $2 +if [ "$osType" != "Darwin" ]; then + if [ -x ${bin_dir}/${clientName} ]; then + update_TDengine + else + install_TDengine + fi +else + if [ -x ${bin_dir}/${clientName} ] || [ -x ${bin_2_dir}/${clientName} ]; then + update_TDengine + else + install_TDengine + fi +fi diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index bbceaa8fed..3ff671d536 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -1,5 +1,5 @@ aux_source_directory(src CLIENT_SRC) -add_library(taos ${CLIENT_SRC}) +add_library(taos SHARED ${CLIENT_SRC}) target_include_directories( taos PUBLIC "${TD_SOURCE_DIR}/include/client" @@ -11,6 +11,25 @@ target_link_libraries( PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom ) +set_target_properties( + taos + PROPERTIES + VERSION ${TD_VER_NUMBER} + SOVERSION ${TD_VER_NUMBER} +) + +add_library(taos_static STATIC ${CLIENT_SRC}) +target_include_directories( + taos_static + PUBLIC "${TD_SOURCE_DIR}/include/client" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) +target_link_libraries( + taos_static + INTERFACE api + PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom +) + if(${BUILD_TEST}) ADD_SUBDIRECTORY(test) endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 73ac059276..903018d5c3 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -69,9 +69,10 @@ void taos_cleanup(void) { rpcCleanup(); catalogDestroy(); schedulerDestroy(); - taosCloseLog(); tscInfo("all local resources released"); + taosCleanupCfg(); + taosCloseLog(); } setConfRet taos_set_config(const char *config) { diff --git a/source/client/test/CMakeLists.txt b/source/client/test/CMakeLists.txt index 73e11caa95..9df6b260f6 100644 --- a/source/client/test/CMakeLists.txt +++ b/source/client/test/CMakeLists.txt @@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(clientTest clientTests.cpp) TARGET_LINK_LIBRARIES( clientTest - PUBLIC os util common transport parser catalog scheduler function gtest taos qcom + PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom ) ADD_EXECUTABLE(tmqTest tmqTest.cpp) TARGET_LINK_LIBRARIES( tmqTest - PUBLIC os util common transport parser catalog scheduler function gtest taos qcom + PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom ) TARGET_INCLUDE_DIRECTORIES( diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 2730723a17..53b0fec8ff 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); taos_free_result(pRes); - pRes = taos_query(pConn, "select * from test_block_raw.all_type"); + pRes = taos_query(pConn, "select count(*) from tu"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); @@ -674,9 +674,6 @@ TEST(testCase, agg_query_tables) { int32_t numOfFields = taos_num_fields(pRes); int32_t n = 0; - void* data = NULL; - int32_t code = taos_fetch_raw_block(pRes, &n, &data); - char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t* length = taos_fetch_lengths(pRes); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index beabc1b6eb..14b7fe5d0e 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1100,6 +1100,11 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows) pColumn->nullbitmap = tmp; memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows)); + + if (pColumn->info.type == TSDB_DATA_TYPE_NULL) { + return TSDB_CODE_SUCCESS; + } + assert(pColumn->info.bytes); tmp = taosMemoryRealloc(pColumn->pData, numOfRows * pColumn->info.bytes); if (tmp == NULL) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 9226e9aa37..49f4afc12b 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -238,7 +238,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) { if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) { - uError("failed to load from config file:%s since %s", cfgFile, terrstr()); + uInfo("cfg file:%s not read since %s", cfgFile, terrstr()); return 0; } } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 3adb0102ce..6df2341af4 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -142,10 +142,10 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq if (tEncodeU32(pEncoder, pReq->query->connId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->query->pid) < 0) return -1; if (tEncodeCStr(pEncoder, pReq->query->app) < 0) return -1; - + int32_t num = taosArrayGetSize(pReq->query->queryDesc); if (tEncodeI32(pEncoder, num) < 0) return -1; - + for (int32_t i = 0; i < num; ++i) { SQueryDesc *desc = taosArrayGet(pReq->query->queryDesc, i); if (tEncodeCStr(pEncoder, desc->sql) < 0) return -1; @@ -169,7 +169,7 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq if (tEncodeI32(pEncoder, queryNum) < 0) return -1; } } - + int32_t kvNum = taosHashGetSize(pReq->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; void *pIter = taosHashIterate(pReq->info, NULL); @@ -200,7 +200,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (num > 0) { pReq->query->queryDesc = taosArrayInit(num, sizeof(SQueryDesc)); if (NULL == pReq->query->queryDesc) return -1; - + for (int32_t i = 0; i < num; ++i) { SQueryDesc desc = {0}; if (tDecodeCStrTo(pDecoder, desc.sql) < 0) return -1; @@ -217,7 +217,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (snum > 0) { desc.subDesc = taosArrayInit(snum, sizeof(SQuerySubDesc)); if (NULL == desc.subDesc) return -1; - + for (int32_t m = 0; m < snum; ++m) { SQuerySubDesc sDesc = {0}; if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1; @@ -254,7 +254,7 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp int32_t queryNum = 0; if (pRsp->query) { queryNum = 1; - if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; if (tEncodeU32(pEncoder, pRsp->query->connId) < 0) return -1; if (tEncodeU64(pEncoder, pRsp->query->killRid) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->query->totalDnodes) < 0) return -1; @@ -262,9 +262,9 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp if (tEncodeI8(pEncoder, pRsp->query->killConnection) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pRsp->query->epSet) < 0) return -1; } else { - if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; } - + int32_t kvNum = taosArrayGetSize(pRsp->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; for (int32_t i = 0; i < kvNum; i++) { @@ -411,7 +411,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) { tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nBSmaCols); for (col_id_t i = 0; i < pReq->stbCfg.nCols; ++i) { tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].type); - tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].sma); + tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].flags); tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pSchema[i].colId); tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pSchema[i].bytes); tlen += taosEncodeString(buf, pReq->stbCfg.pSchema[i].name); @@ -419,7 +419,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) { tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nTagCols); for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) { tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].type); - tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].index); + tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].flags); tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pTagSchema[i].colId); tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes); tlen += taosEncodeString(buf, pReq->stbCfg.pTagSchema[i].name); @@ -443,7 +443,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) { tlen += taosEncodeFixedI16(buf, pReq->ntbCfg.nBSmaCols); for (col_id_t i = 0; i < pReq->ntbCfg.nCols; ++i) { tlen += taosEncodeFixedI8(buf, pReq->ntbCfg.pSchema[i].type); - tlen += taosEncodeFixedI8(buf, pReq->ntbCfg.pSchema[i].sma); + tlen += taosEncodeFixedI8(buf, pReq->ntbCfg.pSchema[i].flags); tlen += taosEncodeFixedI16(buf, pReq->ntbCfg.pSchema[i].colId); tlen += taosEncodeFixedI32(buf, pReq->ntbCfg.pSchema[i].bytes); tlen += taosEncodeString(buf, pReq->ntbCfg.pSchema[i].name); @@ -478,10 +478,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid)); buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nCols)); buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols)); - pReq->stbCfg.pSchema = (SSchemaEx *)taosMemoryMalloc(pReq->stbCfg.nCols * sizeof(SSchemaEx)); + pReq->stbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nCols * sizeof(SSchema)); for (col_id_t i = 0; i < pReq->stbCfg.nCols; ++i) { buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type)); - buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].sma)); + buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].flags)); buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.pSchema[i].colId)); buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].bytes)); buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name); @@ -490,7 +490,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema)); for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) { buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type)); - buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].index)); + buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].flags)); buf = taosDecodeFixedI16(buf, &pReq->stbCfg.pTagSchema[i].colId); buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes); buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name); @@ -520,10 +520,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { case TD_NORMAL_TABLE: buf = taosDecodeFixedI16(buf, &pReq->ntbCfg.nCols); buf = taosDecodeFixedI16(buf, &(pReq->ntbCfg.nBSmaCols)); - pReq->ntbCfg.pSchema = (SSchemaEx *)taosMemoryMalloc(pReq->ntbCfg.nCols * sizeof(SSchemaEx)); + pReq->ntbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->ntbCfg.nCols * sizeof(SSchema)); for (col_id_t i = 0; i < pReq->ntbCfg.nCols; ++i) { buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type); - buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].sma); + buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].flags); buf = taosDecodeFixedI16(buf, &pReq->ntbCfg.pSchema[i].colId); buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].bytes); buf = taosDecodeStringTo(buf, pReq->ntbCfg.pSchema[i].name); @@ -1492,10 +1492,25 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq if (tEncodeI32(&encoder, pReq->outputLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->bufSize) < 0) return -1; if (tEncodeI64(&encoder, pReq->signature) < 0) return -1; - if (tEncodeI32(&encoder, pReq->commentSize) < 0) return -1; - if (tEncodeI32(&encoder, pReq->codeSize) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->pCode) < 0) return -1; + + int32_t codeSize = 0; + if (pReq->pCode != NULL) { + codeSize = strlen(pReq->pCode) + 1; + } + if (tEncodeI32(&encoder, codeSize) < 0) return -1; + if (pReq->pCode != NULL) { + if (tEncodeCStr(&encoder, pReq->pCode) < 0) return -1; + } + + int32_t commentSize = 0; + if (pReq->pComment != NULL) { + commentSize = strlen(pReq->pComment) + 1; + } + if (tEncodeI32(&encoder, commentSize) < 0) return -1; + if (pReq->pComment != NULL) { + if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1; + } + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1516,16 +1531,40 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR if (tDecodeI32(&decoder, &pReq->outputLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->bufSize) < 0) return -1; if (tDecodeI64(&decoder, &pReq->signature) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->commentSize) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->codeSize) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->pCode) < 0) return -1; + + int32_t codeSize = 0; + if (tDecodeI32(&decoder, &codeSize) < 0) return -1; + if (codeSize > 0) { + pReq->pCode = taosMemoryCalloc(1, codeSize); + if (pReq->pCode == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + if (tDecodeCStrTo(&decoder, pReq->pCode) < 0) return -1; + } + + int32_t commentSize = 0; + if (tDecodeI32(&decoder, &commentSize) < 0) return -1; + if (commentSize > 0) { + pReq->pComment = taosMemoryCalloc(1, commentSize); + if (pReq->pComment == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1; + } + tEndDecode(&decoder); tCoderClear(&decoder); return 0; } +void tFreeSCreateFuncReq(SCreateFuncReq *pReq) { + taosMemoryFree(pReq->pCode); + taosMemoryFree(pReq->pComment); +} + int32_t tSerializeSDropFuncReq(void *buf, int32_t bufLen, SDropFuncReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -1594,6 +1633,8 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq return 0; } +void tFreeSRetrieveFuncReq(SRetrieveFuncReq *pReq) { taosArrayDestroy(pReq->pFuncNames); } + int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -1612,10 +1653,10 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp * if (tEncodeI32(&encoder, pInfo->outputLen) < 0) return -1; if (tEncodeI32(&encoder, pInfo->bufSize) < 0) return -1; if (tEncodeI64(&encoder, pInfo->signature) < 0) return -1; - if (tEncodeI32(&encoder, pInfo->commentSize) < 0) return -1; if (tEncodeI32(&encoder, pInfo->codeSize) < 0) return -1; - if (tEncodeCStr(&encoder, pInfo->pComment) < 0) return -1; + if (tEncodeI32(&encoder, pInfo->commentSize) < 0) return -1; if (tEncodeCStr(&encoder, pInfo->pCode) < 0) return -1; + if (tEncodeCStr(&encoder, pInfo->pComment) < 0) return -1; } tEndEncode(&encoder); @@ -1644,10 +1685,17 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp if (tDecodeI32(&decoder, &fInfo.outputLen) < 0) return -1; if (tDecodeI32(&decoder, &fInfo.bufSize) < 0) return -1; if (tDecodeI64(&decoder, &fInfo.signature) < 0) return -1; - if (tDecodeI32(&decoder, &fInfo.commentSize) < 0) return -1; if (tDecodeI32(&decoder, &fInfo.codeSize) < 0) return -1; - if (tDecodeCStrTo(&decoder, fInfo.pComment) < 0) return -1; + if (tDecodeI32(&decoder, &fInfo.commentSize) < 0) return -1; + fInfo.pCode = taosMemoryCalloc(1, fInfo.codeSize); + fInfo.pComment = taosMemoryCalloc(1, fInfo.commentSize); + if (fInfo.pCode == NULL || fInfo.pComment == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + if (tDecodeCStrTo(&decoder, fInfo.pCode) < 0) return -1; + if (tDecodeCStrTo(&decoder, fInfo.pComment) < 0) return -1; taosArrayPush(pRsp->pFuncInfos, &fInfo); } tEndDecode(&decoder); @@ -1656,6 +1704,16 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp return 0; } +void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp *pRsp) { + int32_t size = taosArrayGetSize(pRsp->pFuncInfos); + for (int32_t i = 0; i < size; ++i) { + SFuncInfo *pInfo = taosArrayGet(pRsp->pFuncInfos, i); + taosMemoryFree(pInfo->pCode); + taosMemoryFree(pInfo->pComment); + } + taosArrayDestroy(pRsp->pFuncInfos); +} + int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 7392b0bf8b..a1a2d236f9 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -16,10 +16,19 @@ #define _DEFAULT_SOURCE #include "trow.h" -const uint8_t tdVTypeByte[3] = { - TD_VTYPE_NORM_BYTE, // TD_VTYPE_NORM - TD_VTYPE_NONE_BYTE, // TD_VTYPE_NONE - TD_VTYPE_NULL_BYTE, // TD_VTYPE_NULL +const uint8_t tdVTypeByte[2][3] = {{ + // 2 bits + TD_VTYPE_NORM_BYTE_II, + TD_VTYPE_NONE_BYTE_II, + TD_VTYPE_NULL_BYTE_II, + }, + { + // 1 bit + TD_VTYPE_NORM_BYTE_I, + TD_VTYPE_NULL_BYTE_I, + TD_VTYPE_NULL_BYTE_I, // padding + } + }; // declaration @@ -266,21 +275,53 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index, bool setBit // } // } +/** + * @brief Set bitmap area by byte preferentially and then by bit. + * + * @param pBitmap + * @param nEle + * @param valType + * @param bitmapMode 0 for 2 bits, 1 for 1 bit + * @return int32_t + */ int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode) { TASSERT(valType < TD_VTYPE_MAX); - int16_t nBytes = nEle / TD_VTYPE_PARTS; + int32_t nBytes = (bitmapMode == 0 ? nEle / TD_VTYPE_PARTS : nEle / TD_VTYPE_PARTS_I); + uint8_t vTypeByte = tdVTypeByte[bitmapMode][valType]; for (int i = 0; i < nBytes; ++i) { - *(uint8_t *)pBitmap = tdVTypeByte[valType]; + *(uint8_t *)pBitmap = vTypeByte; pBitmap = POINTER_SHIFT(pBitmap, 1); } - int16_t nLeft = nEle - nBytes * TD_VTYPE_BITS; + int32_t nLeft = nEle - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I); for (int j = 0; j < nLeft; ++j) { tdSetBitmapValType(pBitmap, j, valType, bitmapMode); } return TSDB_CODE_SUCCESS; } +bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode) { + int32_t nBytes = (bitmapMode == 0 ? numOfBits / TD_VTYPE_PARTS : numOfBits / TD_VTYPE_PARTS_I); + uint8_t vTypeByte = tdVTypeByte[bitmapMode][TD_VTYPE_NORM]; + for (int i = 0; i < nBytes; ++i) { + if (*((uint8_t *)pBitmap) != vTypeByte) { + return false; + } + pBitmap = POINTER_SHIFT(pBitmap, 1); + } + + int32_t nLeft = numOfBits - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I); + + for (int j = 0; j < nLeft; ++j) { + uint8_t vType; + tdGetBitmapValType(pBitmap, j, &vType, bitmapMode); + if (vType != TD_VTYPE_NORM) { + return false; + } + } + return true; +} + static FORCE_INLINE void dataColSetNoneAt(SDataCol *pCol, int index, bool setBitmap, int8_t bitmapMode) { if (IS_VAR_DATA_TYPE(pCol->type)) { pCol->dataOff[index] = pCol->len; diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 4686d856cc..2f3677330b 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -415,7 +415,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec if (type == TSDB_DATA_TYPE_BINARY) { newColData = taosMemoryCalloc(1, charLen + 1); memcpy(newColData, varDataVal(inputData), charLen); - taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, 0); + bool ret = taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, 0); + if (ret != TSDB_CODE_SUCCESS) { + taosMemoryFree(newColData); + return ret; + } taosMemoryFree(newColData); } else if (type == TSDB_DATA_TYPE_NCHAR) { newColData = taosMemoryCalloc(1, charLen / TSDB_NCHAR_SIZE + 1); @@ -425,7 +429,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec return TSDB_CODE_FAILED; } newColData[len] = 0; - taosParseTime(newColData, timeVal, len + 1, (int32_t)timePrec, 0); + bool ret = taosParseTime(newColData, timeVal, len + 1, (int32_t)timePrec, 0); + if (ret != TSDB_CODE_SUCCESS) { + taosMemoryFree(newColData); + return ret; + } taosMemoryFree(newColData); } else { return TSDB_CODE_FAILED; diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index cb8746c963..cb01a17273 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "ttypes.h" #include "tcompression.h" +#include "trow.h" const int32_t TYPE_BYTES[15] = { -1, // TSDB_DATA_TYPE_NULL @@ -49,8 +50,8 @@ const int32_t TYPE_BYTES[15] = { } \ } while (0) -static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_bool(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int8_t *data = (int8_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -60,7 +61,8 @@ static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, i assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (data[i] == TSDB_DATA_BOOL_NULL) { + // if (data[i] == TSDB_DATA_BOOL_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -69,8 +71,8 @@ static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, i } } -static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_i8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int8_t *data = (int8_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -80,7 +82,8 @@ static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) { + // if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -89,8 +92,8 @@ static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int } } -static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { uint8_t *data = (uint8_t *)pData; uint64_t _min = UINT64_MAX; uint64_t _max = 0; @@ -102,7 +105,8 @@ static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) { + // if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -115,8 +119,8 @@ static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int *sum = _sum; } -static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_i16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int16_t *data = (int16_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -126,7 +130,8 @@ static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) { + // if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -135,8 +140,8 @@ static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, in } } -static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { uint16_t *data = (uint16_t *)pData; uint64_t _min = UINT64_MAX; uint64_t _max = 0; @@ -148,7 +153,8 @@ static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) { + // if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -161,8 +167,8 @@ static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, in *sum = _sum; } -static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_i32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int32_t *data = (int32_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -172,7 +178,8 @@ static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) { + // if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -181,8 +188,8 @@ static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, in } } -static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { uint32_t *data = (uint32_t *)pData; uint64_t _min = UINT64_MAX; uint64_t _max = 0; @@ -194,7 +201,8 @@ static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) { + // if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -207,8 +215,8 @@ static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, in *sum = _sum; } -static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_i64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int64_t *data = (int64_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -218,7 +226,8 @@ static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) { + // if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -227,8 +236,8 @@ static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, in } } -static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { uint64_t *data = (uint64_t *)pData; uint64_t _min = UINT64_MAX; uint64_t _max = 0; @@ -240,7 +249,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) { + // if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -253,8 +263,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in *sum = _sum; } -static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_f(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { float *data = (float *)pData; float fmin = FLT_MAX; float fmax = -FLT_MAX; @@ -265,7 +275,8 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6 assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) { + // if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -289,8 +300,8 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6 SET_DOUBLE_VAL(min, fmin); } -static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_d(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { double *data = (double *)pData; double dmin = DBL_MAX; double dmax = -DBL_MAX; @@ -301,7 +312,8 @@ static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int6 assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) { + // if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; continue; } @@ -325,13 +337,14 @@ static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int6 SET_DOUBLE_PTR(min, &dmin); } -static void getStatics_bin(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_bin(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { const char *data = pData; assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull(data, TSDB_DATA_TYPE_BINARY)) { + // if (isNull(data, TSDB_DATA_TYPE_BINARY)) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; } @@ -345,13 +358,14 @@ static void getStatics_bin(const void *pData, int32_t numOfRow, int64_t *min, in *maxIndex = 0; } -static void getStatics_nchr(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_nchr(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, + int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { const char *data = pData; assert(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull(data, TSDB_DATA_TYPE_NCHAR)) { + // if (isNull(data, TSDB_DATA_TYPE_NCHAR)) { + if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) { (*numOfNull) += 1; } @@ -391,19 +405,19 @@ tDataTypeDescriptor tDataTypes[15] = { }; char tTokenTypeSwitcher[13] = { - TSDB_DATA_TYPE_NULL, // no type - TSDB_DATA_TYPE_BINARY, // TK_ID - TSDB_DATA_TYPE_BOOL, // TK_BOOL - TSDB_DATA_TYPE_BIGINT, // TK_TINYINT - TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT - TSDB_DATA_TYPE_BIGINT, // TK_INTEGER - TSDB_DATA_TYPE_BIGINT, // TK_BIGINT - TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT - TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE - TSDB_DATA_TYPE_BINARY, // TK_STRING - TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP + TSDB_DATA_TYPE_NULL, // no type + TSDB_DATA_TYPE_BINARY, // TK_ID + TSDB_DATA_TYPE_BOOL, // TK_BOOL + TSDB_DATA_TYPE_BIGINT, // TK_TINYINT + TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT + TSDB_DATA_TYPE_BIGINT, // TK_INTEGER + TSDB_DATA_TYPE_BIGINT, // TK_BIGINT + TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT + TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE + TSDB_DATA_TYPE_BINARY, // TK_STRING + TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP TSDB_DATA_TYPE_VARCHAR, // TK_BINARY - TSDB_DATA_TYPE_NCHAR, // TK_NCHAR + TSDB_DATA_TYPE_NCHAR, // TK_NCHAR }; float floatMin = -FLT_MAX, floatMax = FLT_MAX; diff --git a/source/dnode/mgmt/interface/CMakeLists.txt b/source/dnode/mgmt/interface/CMakeLists.txt index 69cb6e040f..a99fc2703d 100644 --- a/source/dnode/mgmt/interface/CMakeLists.txt +++ b/source/dnode/mgmt/interface/CMakeLists.txt @@ -6,5 +6,5 @@ target_include_directories( PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( - dnode_interface cjson mnode vnode qnode snode bnode wal sync taos tfs monitor + dnode_interface cjson mnode vnode qnode snode bnode wal sync taos_static tfs monitor ) \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c index baf16f591d..75c48e79eb 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c @@ -121,7 +121,7 @@ int32_t mmWriteFile(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq, bool deploye int32_t len = 0; int32_t maxLen = 4096; char *content = taosMemoryCalloc(1, maxLen + 1); - + len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, " \"mnodes\": [{\n"); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 925197d708..7eb08a8f4f 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -83,9 +83,9 @@ int32_t vmProcessGetVnodeLoadsReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->vgId = pCreate->vgId; - pCfg->wsize = pCreate->cacheBlockSize; - pCfg->ssize = pCreate->cacheBlockSize; - pCfg->lsize = pCreate->cacheBlockSize; + pCfg->wsize = pCreate->cacheBlockSize * 1024 * 1024; + pCfg->ssize = 1024; + pCfg->lsize = 1024 * 1024; pCfg->isHeapAllocator = true; pCfg->ttl = 4; pCfg->keep = pCreate->daysToKeep0; @@ -96,13 +96,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0; pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize; pCfg->tsdbCfg.retentions = pCreate->pRetensions; - pCfg->metaCfg.lruSize = pCreate->cacheBlockSize; - pCfg->walCfg.fsyncPeriod = pCreate->fsyncPeriod; - pCfg->walCfg.level = pCreate->walLevel; - pCfg->walCfg.retentionPeriod = 10; - pCfg->walCfg.retentionSize = 128; - pCfg->walCfg.rollPeriod = 128; - pCfg->walCfg.segSize = 128; + pCfg->walCfg.level = TAOS_WAL_WRITE; + pCfg->walCfg.fsyncPeriod = 0; + pCfg->walCfg.retentionPeriod = 0; + pCfg->walCfg.retentionSize = 0; + pCfg->walCfg.rollPeriod = 0; + pCfg->walCfg.segSize = 0; pCfg->walCfg.vgId = pCreate->vgId; pCfg->hashBegin = pCreate->hashBegin; pCfg->hashEnd = pCreate->hashEnd; @@ -160,13 +159,10 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue; msgCb.qsizeFp = vmGetQueueSize; - vnodeCfg.msgCb = msgCb; - vnodeCfg.pTfs = pMgmt->pTfs; - vnodeCfg.dbId = wrapperCfg.dbUid; - SVnode *pImpl = vnodeOpen(wrapperCfg.path, &vnodeCfg); + SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, msgCb); if (pImpl == NULL) { - tFreeSCreateVnodeReq(&createReq); dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr()); + tFreeSCreateVnodeReq(&createReq); return -1; } @@ -175,7 +171,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { tFreeSCreateVnodeReq(&createReq); dError("vgId:%d, failed to open vnode since %s", createReq.vgId, terrstr()); vnodeClose(pImpl); - vnodeDestroy(wrapperCfg.path); + vnodeDestroy(path, pMgmt->pTfs); terrno = code; return code; } @@ -184,7 +180,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { if (code != 0) { tFreeSCreateVnodeReq(&createReq); vnodeClose(pImpl); - vnodeDestroy(wrapperCfg.path); + vnodeDestroy(path, pMgmt->pTfs); terrno = code; return code; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 1b8e0eb961..a212d7edf4 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -84,6 +84,8 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) { } void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) { + char path[TSDB_FILENAME_LEN]; + taosWLockLatch(&pMgmt->latch); taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t)); taosWUnLockLatch(&pMgmt->latch); @@ -104,7 +106,8 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) { if (pVnode->dropped) { dDebug("vgId:%d, vnode is destroyed for dropped:%d", pVnode->vgId, pVnode->dropped); - vnodeDestroy(pVnode->path); + snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pVnode->vgId); + vnodeDestroy(path, pMgmt->pTfs); } taosMemoryFree(pVnode->path); @@ -116,6 +119,7 @@ static void *vmOpenVnodeFunc(void *param) { SVnodeThread *pThread = param; SVnodesMgmt *pMgmt = pThread->pMgmt; SDnode *pDnode = pMgmt->pDnode; + char path[TSDB_FILENAME_LEN]; dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum); setThreadName("open-vnodes"); @@ -134,8 +138,8 @@ static void *vmOpenVnodeFunc(void *param) { msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue; msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue; msgCb.qsizeFp = vmGetQueueSize; - SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid}; - SVnode *pImpl = vnodeOpen(pCfg->path, &cfg); + snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pCfg->vgId); + SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, msgCb); if (pImpl == NULL) { dError("vgId:%d, failed to open vnode by thread:%d", pCfg->vgId, pThread->threadIndex); pThread->failed++; @@ -258,6 +262,7 @@ static void vmCleanup(SMgmtWrapper *pWrapper) { vmCloseVnodes(pMgmt); vmStopWorker(pMgmt); vnodeCleanup(); + tfsClose(pMgmt->pTfs); // walCleanUp(); taosMemoryFree(pMgmt); pWrapper->pMgmt = NULL; diff --git a/source/dnode/mgmt/test/vnode/CMakeLists.txt b/source/dnode/mgmt/test/vnode/CMakeLists.txt index 34402286aa..c399474277 100644 --- a/source/dnode/mgmt/test/vnode/CMakeLists.txt +++ b/source/dnode/mgmt/test/vnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. DND_VNODE_TEST_SRC) -add_executable(dvnodeTest ${DND_VNODE_TEST_SRC}) -target_link_libraries( - dvnodeTest - PUBLIC sut -) +# aux_source_directory(. DND_VNODE_TEST_SRC) +# add_executable(dvnodeTest ${DND_VNODE_TEST_SRC}) +# target_link_libraries( +# dvnodeTest +# PUBLIC sut +# ) -add_test( - NAME dvnodeTest - COMMAND dvnodeTest -) +# add_test( +# NAME dvnodeTest +# COMMAND dvnodeTest +# ) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 5b96416fd7..4a6455c0ed 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -275,16 +275,17 @@ typedef struct { } SDbCfg; typedef struct { - char name[TSDB_DB_FNAME_LEN]; - char acct[TSDB_USER_LEN]; - char createUser[TSDB_USER_LEN]; - int64_t createdTime; - int64_t updateTime; - int64_t uid; - int32_t cfgVersion; - int32_t vgVersion; - int8_t hashMethod; // default is 1 - SDbCfg cfg; + char name[TSDB_DB_FNAME_LEN]; + char acct[TSDB_USER_LEN]; + char createUser[TSDB_USER_LEN]; + int64_t createdTime; + int64_t updateTime; + int64_t uid; + int32_t cfgVersion; + int32_t vgVersion; + int8_t hashMethod; // default is 1 + SDbCfg cfg; + SRWLatch lock; } SDbObj; typedef struct { diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index f7c4a6c225..168bd1db76 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -33,7 +33,7 @@ static int32_t mndProcessCreateBnodeReq(SNodeMsg *pReq); static int32_t mndProcessCreateBnodeRsp(SNodeMsg *pRsp); static int32_t mndProcessDropBnodeReq(SNodeMsg *pReq); static int32_t mndProcessDropBnodeRsp(SNodeMsg *pRsp); -static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); +static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextBnode(SMnode *pMnode, void *pIter); int32_t mndInitBnode(SMnode *pMnode) { @@ -437,7 +437,7 @@ static int32_t mndProcessDropBnodeRsp(SNodeMsg *pRsp) { return 0; } -static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -449,8 +449,8 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p if (pShow->pIter == NULL) break; cols = 0; - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pObj->id, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); char buf[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(buf, pObj->pDnode->ep, pShow->bytes[cols]); @@ -459,7 +459,7 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p colDataAppend(pColInfo, numOfRows, buf, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pObj->createdTime, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); numOfRows++; sdbRelease(pSdb, pObj); diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 13fbcdf9b3..755e2828de 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -219,10 +219,14 @@ static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) { static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { mTrace("db:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); + taosWLockLatch(&pOld->lock); + SArray *pOldRetensions = pOld->cfg.pRetensions; pOld->updateTime = pNew->updateTime; pOld->cfgVersion = pNew->cfgVersion; pOld->vgVersion = pNew->vgVersion; memcpy(&pOld->cfg, &pNew->cfg, sizeof(SDbCfg)); + pNew->cfg.pRetensions = pOldRetensions; + taosWUnLockLatch(&pOld->lock); return 0; } @@ -1354,7 +1358,7 @@ char *mndGetDbStr(char *src) { return pos; } -static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables) { +static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables, bool sysDb) { int32_t cols = 0; char* buf = taosMemoryMalloc(pShow->bytes[cols]); @@ -1366,100 +1370,117 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in ASSERT(0); } - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, buf, false); - taosMemoryFree(buf); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->createdTime, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&numOfTables, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.quorum, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false); - - char tmp[128] = {0}; - int32_t len = 0; - if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { - len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep0); - } else { - len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); - } - - varDataSetLen(tmp, len); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)tmp, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.fsyncPeriod, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheLastRow, false); - - char *prec = NULL; - switch (pDb->cfg.precision) { - case TSDB_TIME_PRECISION_MILLI: - prec = TSDB_TIME_PRECISION_MILLI_STR; - break; - case TSDB_TIME_PRECISION_MICRO: - prec = TSDB_TIME_PRECISION_MICRO_STR; - break; - case TSDB_TIME_PRECISION_NANO: - prec = TSDB_TIME_PRECISION_NANO_STR; - break; - default: - prec = "none"; - break; - } - - char t[10] = {0}; - STR_WITH_SIZE_TO_VARSTR(t, prec, 2); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)t, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false); - char *status = "ready"; - char b[24] = {0}; + char b[24] = {0}; STR_WITH_SIZE_TO_VARSTR(b, status, strlen(status)); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)b, false); + if (sysDb) { + for(int32_t i = 0; i < pShow->numOfColumns; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i); + if (i == 0) { + colDataAppend(pColInfo, rows, buf, false); + } else if (i == 3) { + colDataAppend(pColInfo, rows, (const char *)&numOfTables, false); + } else if (i == 20) { + colDataAppend(pColInfo, rows, b, false); + } else { + colDataAppendNULL(pColInfo, rows); + } + } + } else { + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, buf, false); + taosMemoryFree(buf); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->createdTime, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&numOfTables, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.quorum, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false); + + char tmp[128] = {0}; + int32_t len = 0; + if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { + len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, + pDb->cfg.daysToKeep0); + } else { + len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, + pDb->cfg.daysToKeep2); + } + + varDataSetLen(tmp, len); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)tmp, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.fsyncPeriod, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheLastRow, false); + + char *prec = NULL; + switch (pDb->cfg.precision) { + case TSDB_TIME_PRECISION_MILLI: + prec = TSDB_TIME_PRECISION_MILLI_STR; + break; + case TSDB_TIME_PRECISION_MICRO: + prec = TSDB_TIME_PRECISION_MICRO_STR; + break; + case TSDB_TIME_PRECISION_NANO: + prec = TSDB_TIME_PRECISION_NANO_STR; + break; + default: + prec = "none"; + break; + } + + char t[10] = {0}; + STR_WITH_SIZE_TO_VARSTR(t, prec, 2); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)t, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + colDataAppend(pColInfo, rows, (const char *)b, false); + } // pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); // *(int8_t *)pWrite = pDb->cfg.update; @@ -1508,13 +1529,13 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo if (!pShow->sysDbRsp) { SDbObj infoschemaDb = {0}; setInformationSchemaDbCfg(&infoschemaDb); - dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14); + dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true); numOfRows += 1; SDbObj perfschemaDb = {0}; setPerfSchemaDbCfg(&perfschemaDb); - dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3); + dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true); numOfRows += 1; pShow->sysDbRsp = true; @@ -1529,7 +1550,7 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo int32_t numOfTables = 0; sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL); - dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables); + dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false); numOfRows++; sdbRelease(pSdb, pDb); } diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index a18afbea73..26c7b4d200 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -34,7 +34,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SNodeMsg *pReq, SFuncObj *pFunc); static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq); static int32_t mndProcessDropFuncReq(SNodeMsg *pReq); static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq); -static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); +static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextFunc(SMnode *pMnode, void *pIter); int32_t mndInitFunc(SMnode *pMnode) { @@ -63,28 +63,28 @@ static SSdbRaw *mndFuncActionEncode(SFuncObj *pFunc) { int32_t size = pFunc->commentSize + pFunc->codeSize + sizeof(SFuncObj) + SDB_FUNC_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_FUNC, SDB_FUNC_VER, size); - if (pRaw == NULL) goto FUNC_ENCODE_OVER; + if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pFunc->name, TSDB_FUNC_NAME_LEN, FUNC_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pFunc->createdTime, FUNC_ENCODE_OVER) - SDB_SET_INT8(pRaw, dataPos, pFunc->funcType, FUNC_ENCODE_OVER) - SDB_SET_INT8(pRaw, dataPos, pFunc->scriptType, FUNC_ENCODE_OVER) - SDB_SET_INT8(pRaw, dataPos, pFunc->align, FUNC_ENCODE_OVER) - SDB_SET_INT8(pRaw, dataPos, pFunc->outputType, FUNC_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pFunc->outputLen, FUNC_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pFunc->bufSize, FUNC_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pFunc->signature, FUNC_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pFunc->commentSize, FUNC_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pFunc->codeSize, FUNC_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pFunc->pComment, pFunc->commentSize, FUNC_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, FUNC_ENCODE_OVER) - SDB_SET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, FUNC_ENCODE_OVER) - SDB_SET_DATALEN(pRaw, dataPos, FUNC_ENCODE_OVER); + SDB_SET_BINARY(pRaw, dataPos, pFunc->name, TSDB_FUNC_NAME_LEN, _OVER) + SDB_SET_INT64(pRaw, dataPos, pFunc->createdTime, _OVER) + SDB_SET_INT8(pRaw, dataPos, pFunc->funcType, _OVER) + SDB_SET_INT8(pRaw, dataPos, pFunc->scriptType, _OVER) + SDB_SET_INT8(pRaw, dataPos, pFunc->align, _OVER) + SDB_SET_INT8(pRaw, dataPos, pFunc->outputType, _OVER) + SDB_SET_INT32(pRaw, dataPos, pFunc->outputLen, _OVER) + SDB_SET_INT32(pRaw, dataPos, pFunc->bufSize, _OVER) + SDB_SET_INT64(pRaw, dataPos, pFunc->signature, _OVER) + SDB_SET_INT32(pRaw, dataPos, pFunc->commentSize, _OVER) + SDB_SET_INT32(pRaw, dataPos, pFunc->codeSize, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pFunc->pComment, pFunc->commentSize, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER) + SDB_SET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, _OVER) + SDB_SET_DATALEN(pRaw, dataPos, _OVER); terrno = 0; -FUNC_ENCODE_OVER: +_OVER: if (terrno != 0) { mError("func:%s, failed to encode to raw:%p since %s", pFunc->name, pRaw, terrstr()); sdbFreeRaw(pRaw); @@ -99,45 +99,45 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; int8_t sver = 0; - if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto FUNC_DECODE_OVER; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; if (sver != SDB_FUNC_VER) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - goto FUNC_DECODE_OVER; + goto _OVER; } SSdbRow *pRow = sdbAllocRow(sizeof(SFuncObj)); - if (pRow == NULL) goto FUNC_DECODE_OVER; + if (pRow == NULL) goto _OVER; SFuncObj *pFunc = sdbGetRowObj(pRow); - if (pFunc == NULL) goto FUNC_DECODE_OVER; + if (pFunc == NULL) goto _OVER; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, dataPos, pFunc->name, TSDB_FUNC_NAME_LEN, FUNC_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pFunc->createdTime, FUNC_DECODE_OVER) - SDB_GET_INT8(pRaw, dataPos, &pFunc->funcType, FUNC_DECODE_OVER) - SDB_GET_INT8(pRaw, dataPos, &pFunc->scriptType, FUNC_DECODE_OVER) - SDB_GET_INT8(pRaw, dataPos, &pFunc->align, FUNC_DECODE_OVER) - SDB_GET_INT8(pRaw, dataPos, &pFunc->outputType, FUNC_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pFunc->outputLen, FUNC_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pFunc->bufSize, FUNC_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pFunc->signature, FUNC_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, FUNC_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, FUNC_DECODE_OVER) + SDB_GET_BINARY(pRaw, dataPos, pFunc->name, TSDB_FUNC_NAME_LEN, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pFunc->createdTime, _OVER) + SDB_GET_INT8(pRaw, dataPos, &pFunc->funcType, _OVER) + SDB_GET_INT8(pRaw, dataPos, &pFunc->scriptType, _OVER) + SDB_GET_INT8(pRaw, dataPos, &pFunc->align, _OVER) + SDB_GET_INT8(pRaw, dataPos, &pFunc->outputType, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pFunc->outputLen, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pFunc->bufSize, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pFunc->signature, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, _OVER) pFunc->pComment = taosMemoryCalloc(1, pFunc->commentSize); pFunc->pCode = taosMemoryCalloc(1, pFunc->codeSize); if (pFunc->pComment == NULL || pFunc->pCode == NULL) { - goto FUNC_DECODE_OVER; + goto _OVER; } - SDB_GET_BINARY(pRaw, dataPos, pFunc->pComment, pFunc->commentSize, FUNC_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, FUNC_DECODE_OVER) - SDB_GET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, FUNC_DECODE_OVER) + SDB_GET_BINARY(pRaw, dataPos, pFunc->pComment, pFunc->commentSize, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER) + SDB_GET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, _OVER) terrno = 0; -FUNC_DECODE_OVER: +_OVER: if (terrno != 0) { mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); @@ -192,40 +192,40 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr func.outputLen = pCreate->outputLen; func.bufSize = pCreate->bufSize; func.signature = pCreate->signature; - func.commentSize = pCreate->commentSize; - func.codeSize = pCreate->codeSize; + func.commentSize = strlen(pCreate->pComment) + 1; + func.codeSize = strlen(pCreate->pCode) + 1; func.pComment = taosMemoryMalloc(func.commentSize); func.pCode = taosMemoryMalloc(func.codeSize); if (func.pCode == NULL || func.pCode == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - goto CREATE_FUNC_OVER; + goto _OVER; } - memcpy(func.pComment, pCreate->pComment, pCreate->commentSize); + memcpy(func.pComment, pCreate->pComment, func.commentSize); memcpy(func.pCode, pCreate->pCode, func.codeSize); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_FUNC, &pReq->rpcMsg); - if (pTrans == NULL) goto CREATE_FUNC_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create func:%s", pTrans->id, pCreate->name); SSdbRaw *pRedoRaw = mndFuncActionEncode(&func); - if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto CREATE_FUNC_OVER; - if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto CREATE_FUNC_OVER; + if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER; SSdbRaw *pUndoRaw = mndFuncActionEncode(&func); - if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto CREATE_FUNC_OVER; - if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) goto CREATE_FUNC_OVER; + if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) goto _OVER; SSdbRaw *pCommitRaw = mndFuncActionEncode(&func); - if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto CREATE_FUNC_OVER; - if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto CREATE_FUNC_OVER; + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto CREATE_FUNC_OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -CREATE_FUNC_OVER: +_OVER: taosMemoryFree(func.pCode); taosMemoryFree(func.pComment); mndTransDrop(pTrans); @@ -235,27 +235,27 @@ CREATE_FUNC_OVER: static int32_t mndDropFunc(SMnode *pMnode, SNodeMsg *pReq, SFuncObj *pFunc) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_DROP_FUNC, &pReq->rpcMsg); - if (pTrans == NULL) goto DROP_FUNC_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop user:%s", pTrans->id, pFunc->name); SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc); - if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto DROP_FUNC_OVER; + if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc); - if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto DROP_FUNC_OVER; + if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc); - if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto DROP_FUNC_OVER; + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); - if (mndTransPrepare(pMnode, pTrans) != 0) goto DROP_FUNC_OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -DROP_FUNC_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -269,7 +269,7 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) { if (tDeserializeSCreateFuncReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_FUNC_OVER; + goto _OVER; } mDebug("func:%s, start to create", createReq.name); @@ -279,60 +279,66 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) { if (createReq.igExists) { mDebug("func:%s, already exist, ignore exist is set", createReq.name); code = 0; - goto CREATE_FUNC_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_FUNC_ALREADY_EXIST; - goto CREATE_FUNC_OVER; + goto _OVER; } } else if (terrno == TSDB_CODE_MND_FUNC_ALREADY_EXIST) { - goto CREATE_FUNC_OVER; + goto _OVER; } if (createReq.name[0] == 0) { terrno = TSDB_CODE_MND_INVALID_FUNC_NAME; - goto CREATE_FUNC_OVER; + goto _OVER; } - if (createReq.commentSize <= 0 || createReq.commentSize > TSDB_FUNC_COMMENT_LEN) { + if (createReq.pComment == NULL) { terrno = TSDB_CODE_MND_INVALID_FUNC_COMMENT; - goto CREATE_FUNC_OVER; + goto _OVER; } - if (createReq.codeSize <= 0 || createReq.codeSize > TSDB_FUNC_CODE_LEN) { + if (createReq.pComment[0] == 0) { + terrno = TSDB_CODE_MND_INVALID_FUNC_COMMENT; + goto _OVER; + } + + if (createReq.pCode == NULL) { terrno = TSDB_CODE_MND_INVALID_FUNC_CODE; - goto CREATE_FUNC_OVER; + goto _OVER; } if (createReq.pCode[0] == 0) { terrno = TSDB_CODE_MND_INVALID_FUNC_CODE; - goto CREATE_FUNC_OVER; + goto _OVER; } if (createReq.bufSize <= 0 || createReq.bufSize > TSDB_FUNC_BUF_SIZE) { terrno = TSDB_CODE_MND_INVALID_FUNC_BUFSIZE; - goto CREATE_FUNC_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; - goto CREATE_FUNC_OVER; + goto _OVER; } if (mndCheckFuncAuth(pUser)) { - goto CREATE_FUNC_OVER; + goto _OVER; } code = mndCreateFunc(pMnode, pReq, &createReq); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -CREATE_FUNC_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("func:%s, failed to create since %s", createReq.name, terrstr()); } mndReleaseFunc(pMnode, pFunc); mndReleaseUser(pMnode, pUser); + tFreeSCreateFuncReq(&createReq); return code; } @@ -346,14 +352,14 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) { if (tDeserializeSDropFuncReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto DROP_FUNC_OVER; + goto _OVER; } mDebug("func:%s, start to drop", dropReq.name); if (dropReq.name[0] == 0) { terrno = TSDB_CODE_MND_INVALID_FUNC_NAME; - goto DROP_FUNC_OVER; + goto _OVER; } pFunc = mndAcquireFunc(pMnode, dropReq.name); @@ -361,27 +367,27 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) { if (dropReq.igNotExists) { mDebug("func:%s, not exist, ignore not exist is set", dropReq.name); code = 0; - goto DROP_FUNC_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_FUNC_NOT_EXIST; - goto DROP_FUNC_OVER; + goto _OVER; } } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; - goto DROP_FUNC_OVER; + goto _OVER; } if (mndCheckFuncAuth(pUser)) { - goto DROP_FUNC_OVER; + goto _OVER; } code = mndDropFunc(pMnode, pReq, pFunc); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -DROP_FUNC_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("func:%s, failed to drop since %s", dropReq.name, terrstr()); } @@ -434,6 +440,12 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) { funcInfo.signature = pFunc->signature; funcInfo.commentSize = pFunc->commentSize; funcInfo.codeSize = pFunc->codeSize; + funcInfo.pCode = taosMemoryCalloc(1, sizeof(funcInfo.codeSize)); + funcInfo.pComment = taosMemoryCalloc(1, sizeof(funcInfo.commentSize)); + if (funcInfo.pCode == NULL || funcInfo.pComment == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto RETRIEVE_FUNC_OVER; + } memcpy(funcInfo.pComment, pFunc->pComment, pFunc->commentSize); memcpy(funcInfo.pCode, pFunc->pCode, pFunc->codeSize); taosArrayPush(retrieveRsp.pFuncInfos, &funcInfo); @@ -455,8 +467,8 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) { code = 0; RETRIEVE_FUNC_OVER: - taosArrayDestroy(retrieveReq.pFuncNames); - taosArrayDestroy(retrieveRsp.pFuncInfos); + tFreeSRetrieveFuncReq(&retrieveReq); + tFreeSRetrieveFuncRsp(&retrieveRsp); return code; } @@ -479,7 +491,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int16_t le return tDataTypes[type].name; } -static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -496,34 +508,35 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pB char b1[tListLen(pFunc->name) + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(b1, pFunc->name, pShow->bytes[cols]); - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) b1, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)b1, false); - char* b2 = taosMemoryCalloc(1, pShow->bytes[cols]); + char *b2 = taosMemoryCalloc(1, pShow->bytes[cols]); STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->bytes[cols]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) b2, false); + colDataAppend(pColInfo, numOfRows, (const char *)b2, false); int32_t isAgg = (pFunc->funcType == TSDB_FUNC_TYPE_AGGREGATE) ? 1 : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &isAgg, false); + colDataAppend(pColInfo, numOfRows, (const char *)&isAgg, false); char b3[TSDB_TYPE_STR_MAX_LEN] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(b3, mnodeGenTypeStr(buf, TSDB_TYPE_STR_MAX_LEN, pFunc->outputType, pFunc->outputLen), pShow->bytes[cols]); + STR_WITH_MAXSIZE_TO_VARSTR(b3, mnodeGenTypeStr(buf, TSDB_TYPE_STR_MAX_LEN, pFunc->outputType, pFunc->outputLen), + pShow->bytes[cols]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) b3, false); + colDataAppend(pColInfo, numOfRows, (const char *)b3, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pFunc->createdTime, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pFunc->createdTime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pFunc->codeSize, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pFunc->codeSize, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pFunc->bufSize, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false); numOfRows++; sdbRelease(pSdb, pFunc); diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 6be7097e6a..f403da2f2d 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -78,13 +78,13 @@ void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) { const char *mndGetRoleStr(int32_t showType) { switch (showType) { case TAOS_SYNC_STATE_FOLLOWER: - return "unsynced"; + return "FOLLOWER"; case TAOS_SYNC_STATE_CANDIDATE: - return "slave"; + return "CANDIDATE"; case TAOS_SYNC_STATE_LEADER: - return "master"; + return "LEADER"; default: - return "undefined"; + return "ERROR"; } } @@ -615,7 +615,7 @@ static int32_t mndProcessDropMnodeRsp(SNodeMsg *pRsp) { return 0; } -static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -628,8 +628,8 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p if (pShow->pIter == NULL) break; cols = 0; - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) &pObj->id, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, pShow->bytes[cols]); @@ -638,11 +638,11 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p colDataAppend(pColInfo, numOfRows, b1, false); const char *roles = mndGetRoleStr(pObj->role); - char* b2 = taosMemoryCalloc(1, strlen(roles) + VARSTR_HEADER_SIZE); + char *b2 = taosMemoryCalloc(1, strlen(roles) + VARSTR_HEADER_SIZE); STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->bytes[cols]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) b2, false); + colDataAppend(pColInfo, numOfRows, (const char *)b2, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)&pObj->roleTime, false); diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 3b622795cb..96dba9baf6 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -34,7 +34,7 @@ static int32_t mndProcessCreateQnodeRsp(SNodeMsg *pRsp); static int32_t mndProcessDropQnodeReq(SNodeMsg *pReq); static int32_t mndProcessDropQnodeRsp(SNodeMsg *pRsp); static int32_t mndProcessQnodeListReq(SNodeMsg *pReq); -static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); +static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextQnode(SMnode *pMnode, void *pIter); int32_t mndInitQnode(SMnode *pMnode) { @@ -497,7 +497,7 @@ static int32_t mndProcessDropQnodeRsp(SNodeMsg *pRsp) { return 0; } -static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -510,8 +510,8 @@ static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p if (pShow->pIter == NULL) break; cols = 0; - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*)&pObj->id, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->bytes[cols]); diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 686cf1400d..b7d0ed8f5a 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -33,7 +33,7 @@ static int32_t mndProcessCreateSnodeReq(SNodeMsg *pReq); static int32_t mndProcessCreateSnodeRsp(SNodeMsg *pRsp); static int32_t mndProcessDropSnodeReq(SNodeMsg *pReq); static int32_t mndProcessDropSnodeRsp(SNodeMsg *pRsp); -static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); +static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextSnode(SMnode *pMnode, void *pIter); int32_t mndInitSnode(SMnode *pMnode) { @@ -447,7 +447,7 @@ static int32_t mndProcessDropSnodeRsp(SNodeMsg *pRsp) { return 0; } -static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -459,8 +459,8 @@ static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p if (pShow->pIter == NULL) break; cols = 0; - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*)&pObj->id, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->bytes[cols]); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 0ce73005e8..2aa20df2e6 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -18,8 +18,8 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndInfoSchema.h" -#include "mndPerfSchema.h" #include "mndMnode.h" +#include "mndPerfSchema.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" @@ -40,7 +40,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp); static int32_t mndProcessVAlterStbRsp(SNodeMsg *pRsp); static int32_t mndProcessVDropStbRsp(SNodeMsg *pRsp); static int32_t mndProcessTableMetaReq(SNodeMsg *pReq); -static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); +static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); int32_t mndInitStb(SMnode *pMnode) { @@ -74,59 +74,59 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags + pStb->numOfSmas) * sizeof(SSchema) + TSDB_STB_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, TSDB_STB_VER_NUMBER, size); - if (pRaw == NULL) goto STB_ENCODE_OVER; + if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->createdTime, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->updateTime, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->uid, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->version, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->aggregationMethod, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->delay, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->ttl, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfSmas, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, STB_ENCODE_OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->createdTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->updateTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->uid, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->version, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER) + SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->aggregationMethod, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->delay, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->ttl, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfSmas, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, _OVER) for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfTags; ++i) { SSchema *pSchema = &pStb->pTags[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfSmas; ++i) { SSchema *pSchema = &pStb->pSmas[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } if (pStb->commentLen > 0) { - SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_ENCODE_OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, _OVER) } - SDB_SET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, STB_ENCODE_OVER) - SDB_SET_DATALEN(pRaw, dataPos, STB_ENCODE_OVER) + SDB_SET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER) + SDB_SET_DATALEN(pRaw, dataPos, _OVER) terrno = 0; -STB_ENCODE_OVER: +_OVER: if (terrno != 0) { mError("stb:%s, failed to encode to raw:%p since %s", pStb->name, pRaw, terrstr()); sdbFreeRaw(pRaw); @@ -141,80 +141,80 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; int8_t sver = 0; - if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto STB_DECODE_OVER; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; if (sver != TSDB_STB_VER_NUMBER) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - goto STB_DECODE_OVER; + goto _OVER; } SSdbRow *pRow = sdbAllocRow(sizeof(SStbObj)); - if (pRow == NULL) goto STB_DECODE_OVER; + if (pRow == NULL) goto _OVER; SStbObj *pStb = sdbGetRowObj(pRow); - if (pStb == NULL) goto STB_DECODE_OVER; + if (pStb == NULL) goto _OVER; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->createdTime, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->updateTime, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->uid, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->version, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, STB_DECODE_OVER) + SDB_GET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->createdTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->updateTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->uid, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->version, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER) int32_t xFilesFactor = 0; - SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, STB_DECODE_OVER) + SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, _OVER) pStb->xFilesFactor = xFilesFactor / 10000.0f; - SDB_GET_INT32(pRaw, dataPos, &pStb->aggregationMethod, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->delay, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, STB_DECODE_OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->aggregationMethod, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->delay, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, _OVER) pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema)); pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema)); pStb->pSmas = taosMemoryCalloc(pStb->numOfSmas, sizeof(SSchema)); if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pSmas == NULL) { - goto STB_DECODE_OVER; + goto _OVER; } for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfTags; ++i) { SSchema *pSchema = &pStb->pTags[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfSmas; ++i) { SSchema *pSchema = &pStb->pSmas[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } if (pStb->commentLen > 0) { pStb->comment = taosMemoryCalloc(pStb->commentLen, 1); - if (pStb->comment == NULL) goto STB_DECODE_OVER; - SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_DECODE_OVER) + if (pStb->comment == NULL) goto _OVER; + SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, _OVER) } - SDB_GET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, STB_DECODE_OVER) + SDB_GET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER) terrno = 0; -STB_DECODE_OVER: +_OVER: if (terrno != 0) { mError("stb:%s, failed to decode from raw:%p since %s", pStb->name, pRaw, terrstr()); taosMemoryFreeClear(pStb->pColumns); @@ -333,9 +333,9 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) { } static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSchema) { - if (*(col_id_t *)colId < ((SSchemaEx *)pSchema)->colId) { + if (*(col_id_t *)colId < ((SSchema *)pSchema)->colId) { return -1; - } else if (*(col_id_t *)colId > ((SSchemaEx *)pSchema)->colId) { + } else if (*(col_id_t *)colId > ((SSchema *)pSchema)->colId) { return 1; } return 0; @@ -360,49 +360,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.stbCfg.nTagCols = pStb->numOfTags; req.stbCfg.pTagSchema = pStb->pTags; req.stbCfg.nBSmaCols = pStb->numOfSmas; - req.stbCfg.pSchema = (SSchemaEx *)taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchemaEx)); + req.stbCfg.pSchema = (SSchema *)taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema)); if (req.stbCfg.pSchema == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - int bSmaStat = 0; // no column has bsma - if (pStb->numOfSmas == pStb->numOfColumns) { // assume pColumns > 0 - bSmaStat = 1; // all columns have bsma - } else if (pStb->numOfSmas != 0) { - bSmaStat = 2; // partial columns have bsma - TASSERT(pStb->pSmas != NULL); // TODO: remove the assert - } - - for (int32_t i = 0; i < req.stbCfg.nCols; ++i) { - SSchemaEx *pSchemaEx = req.stbCfg.pSchema + i; - SSchema *pSchema = pStb->pColumns + i; - pSchemaEx->type = pSchema->type; - pSchemaEx->sma = (bSmaStat == 1) ? TSDB_BSMA_TYPE_LATEST : TSDB_BSMA_TYPE_NONE; - pSchemaEx->colId = pSchema->colId; - pSchemaEx->bytes = pSchema->bytes; - memcpy(pSchemaEx->name, pSchema->name, TSDB_COL_NAME_LEN); - } - - if (bSmaStat == 2) { - if (pStb->pSmas == NULL) { - mError("stb:%s, sma options is empty", pStb->name); - taosMemoryFreeClear(req.stbCfg.pSchema); - terrno = TSDB_CODE_MND_INVALID_STB_OPTION; - return NULL; - } - for (int32_t i = 0; i < pStb->numOfSmas; ++i) { - SSchema *pSmaSchema = pStb->pSmas + i; - SSchemaEx *pColSchema = taosbsearch(&pSmaSchema->colId, req.stbCfg.pSchema, req.stbCfg.nCols, sizeof(SSchemaEx), - schemaExColIdCompare, TD_EQ); - if (pColSchema == NULL) { - terrno = TSDB_CODE_MND_INVALID_STB_OPTION; - taosMemoryFreeClear(req.stbCfg.pSchema); - mError("stb:%s, sma col:%s not found in columns", pStb->name, pSmaSchema->name); - return NULL; - } - pColSchema->sma = TSDB_BSMA_TYPE_LATEST; - } + memcpy(req.stbCfg.pSchema, pStb->pColumns, sizeof(SSchema) * pStb->numOfColumns); + for (int i = 0; i < pStb->numOfColumns; i++) { + req.stbCfg.pSchema[i].flags = SCHEMA_SMA_ON; } SRSmaParam *pRSmaParam = NULL; @@ -428,9 +394,9 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt *(pRSmaParam->pFuncIds + f) = pStb->aggregationMethod; } req.stbCfg.pRSmaParam = pRSmaParam; - } + } - int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead); + int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead); SMsgHead *pHead = taosMemoryMalloc(contLen); if (pHead == NULL) { if (pRSmaParam) { @@ -724,21 +690,21 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto CREATE_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbUndoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto CREATE_STB_OVER; + if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbUndoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -CREATE_STB_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -754,13 +720,13 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) { if (tDeserializeSMCreateStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to create", createReq.name); if (mndCheckCreateStbReq(&createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_STB_OVER; + goto _OVER; } pStb = mndAcquireStb(pMnode, createReq.name); @@ -768,40 +734,40 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) { if (createReq.igExists) { mDebug("stb:%s, already exist, ignore exist is set", createReq.name); code = 0; - goto CREATE_STB_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_STB_ALREADY_EXIST; - goto CREATE_STB_OVER; + goto _OVER; } } else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) { - goto CREATE_STB_OVER; + goto _OVER; } pTopicStb = mndAcquireStb(pMnode, createReq.name); if (pTopicStb != NULL) { terrno = TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC; - goto CREATE_STB_OVER; + goto _OVER; } pDb = mndAcquireDbByStb(pMnode, createReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - goto CREATE_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto CREATE_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto CREATE_STB_OVER; + goto _OVER; } code = mndCreateStb(pMnode, pReq, &createReq, pDb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -CREATE_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to create since %s", createReq.name, terrstr()); } @@ -1211,23 +1177,23 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAltertbReq *p break; } - if (code != 0) goto ALTER_STB_OVER; + if (code != 0) goto _OVER; code = -1; pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_ALTER_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto ALTER_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to alter stb:%s", pTrans->id, pAlter->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto ALTER_STB_OVER; + if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -ALTER_STB_OVER: +_OVER: mndTransDrop(pTrans); taosMemoryFreeClear(stbObj.pTags); taosMemoryFreeClear(stbObj.pColumns); @@ -1244,37 +1210,37 @@ static int32_t mndProcessMAlterStbReq(SNodeMsg *pReq) { if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto ALTER_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to alter", alterReq.name); - if (mndCheckAlterStbReq(&alterReq) != 0) goto ALTER_STB_OVER; + if (mndCheckAlterStbReq(&alterReq) != 0) goto _OVER; pDb = mndAcquireDbByStb(pMnode, alterReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_INVALID_DB; - goto ALTER_STB_OVER; + goto _OVER; } pStb = mndAcquireStb(pMnode, alterReq.name); if (pStb == NULL) { terrno = TSDB_CODE_MND_STB_NOT_EXIST; - goto ALTER_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto ALTER_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto ALTER_STB_OVER; + goto _OVER; } code = mndAlterStb(pMnode, pReq, &alterReq, pDb, pStb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -ALTER_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to alter since %s", alterReq.name, terrstr()); } @@ -1353,19 +1319,19 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * static int32_t mndDropStb(SMnode *pMnode, SNodeMsg *pReq, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_DROP_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto DROP_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto DROP_STB_OVER; - if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto DROP_STB_OVER; - if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto DROP_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto DROP_STB_OVER; + if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER; + if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; + if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -DROP_STB_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -1380,7 +1346,7 @@ static int32_t mndProcessMDropStbReq(SNodeMsg *pReq) { if (tDeserializeSMDropStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto DROP_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to drop", dropReq.name); @@ -1390,32 +1356,32 @@ static int32_t mndProcessMDropStbReq(SNodeMsg *pReq) { if (dropReq.igNotExists) { mDebug("stb:%s, not exist, ignore not exist is set", dropReq.name); code = 0; - goto DROP_STB_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_STB_NOT_EXIST; - goto DROP_STB_OVER; + goto _OVER; } } pDb = mndAcquireDbByStb(pMnode, dropReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - goto DROP_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto DROP_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto DROP_STB_OVER; + goto _OVER; } code = mndDropStb(pMnode, pReq, pDb, pStb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -DROP_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to drop since %s", dropReq.name, terrstr()); } @@ -1509,36 +1475,36 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { if (tDeserializeSTableInfoReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &infoReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto RETRIEVE_META_OVER; + goto _OVER; } if (0 == strcmp(infoReq.dbFName, TSDB_INFORMATION_SCHEMA_DB)) { mDebug("information_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } else { mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } int32_t rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); if (rspLen < 0) { terrno = TSDB_CODE_INVALID_MSG; - goto RETRIEVE_META_OVER; + goto _OVER; } void *pRsp = rpcMallocCont(rspLen); if (pRsp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - goto RETRIEVE_META_OVER; + goto _OVER; } tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp); @@ -1548,7 +1514,7 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { mDebug("stb:%s.%s, meta is retrieved", infoReq.dbFName, infoReq.tbName); -RETRIEVE_META_OVER: +_OVER: if (code != 0) { mError("stb:%s.%s, failed to retrieve meta since %s", infoReq.dbFName, infoReq.tbName, terrstr()); } @@ -1644,14 +1610,14 @@ static void mndExtractTableName(char *tableId, char *name) { } } -static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { +static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; SStbObj *pStb = NULL; int32_t cols = 0; - SDbObj* pDb = NULL; + SDbObj *pDb = NULL; if (strlen(pShow->db) > 0) { pDb = mndAcquireDb(pMnode, pShow->db); if (pDb == NULL) return terrno; @@ -1669,20 +1635,20 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo cols = 0; SName name = {0}; - char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; mndExtractTableName(pStb->name, &stbName[VARSTR_HEADER_SIZE]); varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE])); - SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) stbName, false); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)stbName, false); - char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pStb->db, T_NAME_ACCT|T_NAME_DB); + char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB); tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char*) db, false); + colDataAppend(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)&pStb->createdTime, false); @@ -1696,7 +1662,7 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)&pStb->updateTime, false); // number of tables - char* p = taosMemoryMalloc(pStb->commentLen + VARSTR_HEADER_SIZE); // check malloc failures + char *p = taosMemoryMalloc(pStb->commentLen + VARSTR_HEADER_SIZE); // check malloc failures if (p != NULL) { if (pStb->commentLen != 0) { STR_TO_VARSTR(p, pStb->comment); diff --git a/source/dnode/mnode/impl/test/func/func.cpp b/source/dnode/mnode/impl/test/func/func.cpp index 6b9c410738..22b0387d8b 100644 --- a/source/dnode/mnode/impl/test/func/func.cpp +++ b/source/dnode/mnode/impl/test/func/func.cpp @@ -21,10 +21,25 @@ class MndTestFunc : public ::testing::Test { public: void SetUp() override {} void TearDown() override {} + + void SetCode(SCreateFuncReq* pReq, const char* pCode); + void SetComment(SCreateFuncReq* pReq, const char* pComment); }; Testbase MndTestFunc::test; +void MndTestFunc::SetCode(SCreateFuncReq* pReq, const char* pCode) { + int32_t len = strlen(pCode); + pReq->pCode = (char*)taosMemoryCalloc(1, len + 1); + strcpy(pReq->pCode, pCode); +} + +void MndTestFunc::SetComment(SCreateFuncReq* pReq, const char* pComment) { + int32_t len = strlen(pComment); + pReq->pComment = (char*)taosMemoryCalloc(1, len + 1); + strcpy(pReq->pComment, pComment); +} + TEST_F(MndTestFunc, 01_Show_Func) { test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 0); @@ -38,6 +53,7 @@ TEST_F(MndTestFunc, 02_Create_Func) { int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -47,10 +63,12 @@ TEST_F(MndTestFunc, 02_Create_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); + SetCode(&createReq, "code1"); int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -60,11 +78,28 @@ TEST_F(MndTestFunc, 02_Create_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN + 1; + SetComment(&createReq, "comment1"); int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC_CODE); + } + + { + SCreateFuncReq createReq = {0}; + strcpy(createReq.name, "f1"); + SetCode(&createReq, "code1"); + SetComment(&createReq, ""); + + int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -74,11 +109,13 @@ TEST_F(MndTestFunc, 02_Create_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; + SetCode(&createReq, ""); + SetComment(&createReq, "comment1"); int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -88,43 +125,13 @@ TEST_F(MndTestFunc, 02_Create_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; - createReq.codeSize = TSDB_FUNC_CODE_LEN + 1; - - int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); - void* pReq = rpcMallocCont(contLen); - tSerializeSCreateFuncReq(pReq, contLen, &createReq); - - SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); - ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC_CODE); - } - - { - SCreateFuncReq createReq = {0}; - strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; - createReq.codeSize = TSDB_FUNC_CODE_LEN; - - int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); - void* pReq = rpcMallocCont(contLen); - tSerializeSCreateFuncReq(pReq, contLen, &createReq); - - SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); - ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC_CODE); - } - - { - SCreateFuncReq createReq = {0}; - strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; - createReq.codeSize = TSDB_FUNC_CODE_LEN; - createReq.pCode[0] = 'a'; + SetCode(&createReq, "code1"); + SetComment(&createReq, "comment1"); int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -134,14 +141,14 @@ TEST_F(MndTestFunc, 02_Create_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; - createReq.codeSize = TSDB_FUNC_CODE_LEN; - createReq.pCode[0] = 'a'; + SetCode(&createReq, "code1"); + SetComment(&createReq, "comment1"); createReq.bufSize = TSDB_FUNC_BUF_SIZE + 1; int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -151,9 +158,8 @@ TEST_F(MndTestFunc, 02_Create_Func) { for (int32_t i = 0; i < 3; ++i) { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f1"); - createReq.commentSize = TSDB_FUNC_COMMENT_LEN; - createReq.codeSize = TSDB_FUNC_CODE_LEN; - createReq.pCode[0] = 'a'; + SetCode(&createReq, "code1"); + SetComment(&createReq, "comment1"); createReq.bufSize = TSDB_FUNC_BUF_SIZE + 1; createReq.igExists = 0; if (i == 2) createReq.igExists = 1; @@ -163,16 +169,11 @@ TEST_F(MndTestFunc, 02_Create_Func) { createReq.outputLen = 12; createReq.bufSize = 4; createReq.signature = 5; - for (int32_t i = 0; i < createReq.commentSize - 1; ++i) { - createReq.pComment[i] = 'm'; - } - for (int32_t i = 0; i < createReq.codeSize - 1; ++i) { - createReq.pCode[i] = 'd'; - } int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -197,7 +198,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -217,20 +218,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { EXPECT_EQ(pFuncInfo->outputLen, 12); EXPECT_EQ(pFuncInfo->bufSize, 4); EXPECT_EQ(pFuncInfo->signature, 5); - EXPECT_EQ(pFuncInfo->commentSize, TSDB_FUNC_COMMENT_LEN); - EXPECT_EQ(pFuncInfo->codeSize, TSDB_FUNC_CODE_LEN); + EXPECT_STREQ("comment1", pFuncInfo->pComment); + EXPECT_STREQ("code1", pFuncInfo->pCode); - char comments[TSDB_FUNC_COMMENT_LEN] = {0}; - for (int32_t i = 0; i < TSDB_FUNC_COMMENT_LEN - 1; ++i) { - comments[i] = 'm'; - } - char codes[TSDB_FUNC_CODE_LEN] = {0}; - for (int32_t i = 0; i < TSDB_FUNC_CODE_LEN - 1; ++i) { - codes[i] = 'd'; - } - EXPECT_STREQ(comments, pFuncInfo->pComment); - EXPECT_STREQ(codes, pFuncInfo->pCode); - taosArrayDestroy(retrieveRsp.pFuncInfos); + tFreeSRetrieveFuncRsp(&retrieveRsp); } { @@ -241,7 +232,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -259,7 +250,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -275,7 +266,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -285,8 +276,6 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "f2"); - createReq.commentSize = 1024; - createReq.codeSize = 9527; createReq.igExists = 1; createReq.funcType = 2; createReq.scriptType = 3; @@ -294,16 +283,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { createReq.outputLen = 24; createReq.bufSize = 6; createReq.signature = 18; - for (int32_t i = 0; i < createReq.commentSize - 1; ++i) { - createReq.pComment[i] = 'p'; - } - for (int32_t i = 0; i < createReq.codeSize - 1; ++i) { - createReq.pCode[i] = 'q'; - } + SetCode(&createReq, "code2"); + SetComment(&createReq, "comment2"); int32_t contLen = tSerializeSCreateFuncReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); tSerializeSCreateFuncReq(pReq, contLen, &createReq); + tFreeSCreateFuncReq(&createReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -322,7 +308,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -342,21 +328,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { EXPECT_EQ(pFuncInfo->outputLen, 24); EXPECT_EQ(pFuncInfo->bufSize, 6); EXPECT_EQ(pFuncInfo->signature, 18); - EXPECT_EQ(pFuncInfo->commentSize, 1024); - EXPECT_EQ(pFuncInfo->codeSize, 9527); + EXPECT_EQ(pFuncInfo->commentSize, strlen("comment2") + 1); + EXPECT_EQ(pFuncInfo->codeSize, strlen("code2") + 1); - char comments[TSDB_FUNC_COMMENT_LEN] = {0}; - for (int32_t i = 0; i < 1024 - 1; ++i) { - comments[i] = 'p'; - } - char codes[TSDB_FUNC_CODE_LEN] = {0}; - for (int32_t i = 0; i < 9527 - 1; ++i) { - codes[i] = 'q'; - } + EXPECT_STREQ("comment2", pFuncInfo->pComment); + EXPECT_STREQ("code2", pFuncInfo->pCode); - EXPECT_STREQ(comments, pFuncInfo->pComment); - EXPECT_STREQ(codes, pFuncInfo->pCode); - taosArrayDestroy(retrieveRsp.pFuncInfos); + tFreeSRetrieveFuncRsp(&retrieveRsp); } { @@ -369,7 +347,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); @@ -389,20 +367,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { EXPECT_EQ(pFuncInfo->outputLen, 24); EXPECT_EQ(pFuncInfo->bufSize, 6); EXPECT_EQ(pFuncInfo->signature, 18); - EXPECT_EQ(pFuncInfo->commentSize, 1024); - EXPECT_EQ(pFuncInfo->codeSize, 9527); - - char comments[TSDB_FUNC_COMMENT_LEN] = {0}; - for (int32_t i = 0; i < 1024 - 1; ++i) { - comments[i] = 'p'; - } - char codes[TSDB_FUNC_CODE_LEN] = {0}; - for (int32_t i = 0; i < 9527 - 1; ++i) { - codes[i] = 'q'; - } - - EXPECT_STREQ(comments, pFuncInfo->pComment); - EXPECT_STREQ(codes, pFuncInfo->pCode); + EXPECT_EQ(pFuncInfo->commentSize, strlen("comment2") + 1); + EXPECT_EQ(pFuncInfo->codeSize, strlen("code2") + 1); + EXPECT_STREQ("comment2", pFuncInfo->pComment); + EXPECT_STREQ("code2", pFuncInfo->pCode); } { @@ -414,21 +382,11 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { EXPECT_EQ(pFuncInfo->outputLen, 12); EXPECT_EQ(pFuncInfo->bufSize, 4); EXPECT_EQ(pFuncInfo->signature, 5); - EXPECT_EQ(pFuncInfo->commentSize, TSDB_FUNC_COMMENT_LEN); - EXPECT_EQ(pFuncInfo->codeSize, TSDB_FUNC_CODE_LEN); - - char comments[TSDB_FUNC_COMMENT_LEN] = {0}; - for (int32_t i = 0; i < TSDB_FUNC_COMMENT_LEN - 1; ++i) { - comments[i] = 'm'; - } - char codes[TSDB_FUNC_CODE_LEN] = {0}; - for (int32_t i = 0; i < TSDB_FUNC_CODE_LEN - 1; ++i) { - codes[i] = 'd'; - } - EXPECT_STREQ(comments, pFuncInfo->pComment); - EXPECT_STREQ(codes, pFuncInfo->pCode); + EXPECT_STREQ("comment1", pFuncInfo->pComment); + EXPECT_STREQ("code1", pFuncInfo->pCode); } - taosArrayDestroy(retrieveRsp.pFuncInfos); + + tFreeSRetrieveFuncRsp(&retrieveRsp); } { @@ -441,7 +399,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq); - taosArrayDestroy(retrieveReq.pFuncNames); + tFreeSRetrieveFuncReq(&retrieveReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen); ASSERT_NE(pRsp, nullptr); diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index c0e458219c..5a6fdd1b40 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -18,12 +18,11 @@ target_sources( "src/vnd/vnodeSvr.c" # meta - # "src/meta/metaBDBImpl.c" + "src/meta/metaOpen.c" "src/meta/metaIdx.c" - "src/meta/metaMain.c" "src/meta/metaTable.c" - "src/meta/metaTbUid.c" "src/meta/metaTDBImpl.c" + # "src/meta/metaBDBImpl.c" # tsdb "src/tsdb/tsdbTDBImpl.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 303376dba4..86e876ecba 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -37,16 +37,14 @@ extern "C" { // vnode typedef struct SVnode SVnode; -typedef struct SMetaCfg SMetaCfg; // todo: remove typedef struct STsdbCfg STsdbCfg; // todo: remove -typedef struct STqCfg STqCfg; // todo: remove typedef struct SVnodeCfg SVnodeCfg; int vnodeInit(int nthreads); void vnodeCleanup(); int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs); -void vnodeDestroy(const char *path); -SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); +void vnodeDestroy(const char *path, STfs *pTfs); +SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb); void vnodeClose(SVnode *pVnode); void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs); int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); @@ -73,7 +71,6 @@ char *metaTbCursorNext(SMTbCursor *pTbCur); // tsdb typedef struct STsdb STsdb; -typedef struct SDataStatis SDataStatis; typedef struct STsdbQueryCond STsdbQueryCond; typedef void *tsdbReaderT; @@ -93,7 +90,7 @@ int32_t tsdbQuerySTableByTagCond(void *pMeta, uint64_t uid, TSKEY skey, con int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle); bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle); void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo); -int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SDataStatis **pBlockStatis); +int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg **pBlockStatis); SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList); void tsdbDestroyTableGroup(STableGroupInfo *pGroupList); int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo); @@ -134,14 +131,9 @@ struct STsdbCfg { SArray *retentions; }; -struct STqCfg { - int32_t reserved; -}; - struct SVnodeCfg { int32_t vgId; uint64_t dbId; - STfs *pTfs; uint64_t wsize; uint64_t ssize; uint64_t lsize; @@ -151,25 +143,12 @@ struct SVnodeCfg { int8_t streamMode; bool isWeak; STsdbCfg tsdbCfg; - SMetaCfg metaCfg; - STqCfg tqCfg; SWalCfg walCfg; - SMsgCb msgCb; uint32_t hashBegin; uint32_t hashEnd; int8_t hashMethod; }; -struct SDataStatis { - int16_t colId; - int16_t maxIndex; - int16_t minIndex; - int16_t numOfNull; - int64_t sum; - int64_t max; - int64_t min; -}; - struct STsdbQueryCond { STimeWindow twindow; int32_t order; // desc|asc order to iterate the data block diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index 94a1266f46..fb875a46e0 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -20,7 +20,6 @@ extern "C" { #endif -typedef struct SMetaCache SMetaCache; typedef struct SMetaIdx SMetaIdx; typedef struct SMetaDB SMetaDB; typedef struct SMCtbCursor SMCtbCursor; @@ -36,13 +35,22 @@ typedef struct SMSmaCursor SMSmaCursor; #define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +// metaOpen ================== +int metaOpen(SVnode* pVnode, SMeta** ppMeta); +int metaClose(SMeta* pMeta); + +// metaIdx ================== +int metaOpenIdx(SMeta* pMeta); +void metaCloseIdx(SMeta* pMeta); +int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions); +int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid); + +static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); } + #define META_SUPER_TABLE TD_SUPER_TABLE #define META_CHILD_TABLE TD_CHILD_TABLE #define META_NORMAL_TABLE TD_NORMAL_TABLE -SMeta* metaOpen(const char* path, const SMetaCfg* pMetaCfg, SMemAllocatorFactory* pMAF); -void metaClose(SMeta* pMeta); -void metaRemove(const char* path); int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg); int metaDropTable(SMeta* pMeta, tb_uid_t uid); int metaCommit(SMeta* pMeta); @@ -71,38 +79,15 @@ int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid); int metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg); int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid); -// SMetaCache -int metaOpenCache(SMeta* pMeta); -void metaCloseCache(SMeta* pMeta); - // SMetaIdx -int metaOpenIdx(SMeta* pMeta); -void metaCloseIdx(SMeta* pMeta); -int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions); -int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid); -// STbUidGnrt -typedef struct STbUidGenerator { - tb_uid_t nextUid; -} STbUidGenerator; - -// STableUidGenerator -int metaOpenUidGnrt(SMeta* pMeta); -void metaCloseUidGnrt(SMeta* pMeta); - -// tb_uid_t -#define IVLD_TB_UID 0 tb_uid_t metaGenerateUid(SMeta* pMeta); struct SMeta { - char* path; - SVnode* pVnode; - SMetaCfg options; - SMetaDB* pDB; - SMetaIdx* pIdx; - SMetaCache* pCache; - STbUidGenerator uidGnrt; - SMemAllocatorFactory* pmaf; + char* path; + SVnode* pVnode; + SMetaDB* pDB; + SMetaIdx* pIdx; }; #ifdef __cplusplus diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index ce81006661..ed33473b16 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -160,7 +160,6 @@ struct STQ { // the handle of meta kvstore bool writeTrigger; char* path; - STqCfg* tqConfig; STqMemRef tqMemRef; STqMetaStore* tqMeta; // STqPushMgr* tqPushMgr; @@ -251,8 +250,7 @@ int tqInit(); void tqCleanUp(); // open in each vnode -STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, STqCfg* tqConfig, - SMemAllocatorFactory* allocFac); +STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, SMemAllocatorFactory* allocFac); void tqClose(STQ*); // required by vnode int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index d0e005f990..ce9549af56 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -43,10 +43,8 @@ typedef struct STable { #define TABLE_TID(t) (t)->tid #define TABLE_UID(t) (t)->uid -STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta, - STfs *pTfs); +STsdb *tsdbOpen(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF); void tsdbClose(STsdb *); -void tsdbRemove(const char *path); int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp); int tsdbPrepareCommit(STsdb *pTsdb); int tsdbCommit(STsdb *pTsdb); @@ -167,16 +165,14 @@ struct STsdb { SRtn rtn; SMemAllocatorFactory *pmaf; STsdbFS *fs; - SMeta *pMeta; - STfs *pTfs; SSmaEnvs smaEnvs; }; #define REPO_ID(r) ((r)->vgId) #define REPO_CFG(r) (&(r)->config) #define REPO_FS(r) ((r)->fs) -#define REPO_META(r) ((r)->pMeta) -#define REPO_TFS(r) ((r)->pTfs) +#define REPO_META(r) ((r)->pVnode->pMeta) +#define REPO_TFS(r) ((r)->pVnode->pTfs) #define IS_REPO_LOCKED(r) ((r)->repoLocked) #define REPO_TSMA_NUM(r) ((r)->smaEnvs.nTSma) #define REPO_RSMA_NUM(r) ((r)->smaEnvs.nRSma) @@ -438,7 +434,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock); int tsdbEncodeSBlockIdx(void **buf, SBlockIdx *pIdx); void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx); -void tsdbGetBlockStatis(SReadH *pReadh, SDataStatis *pStatis, int numOfCols, SBlock *pBlock); +void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols, SBlock *pBlock); static FORCE_INLINE int tsdbMakeRoom(void **ppBuf, size_t size) { void *pBuf = *ppBuf; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index cb40900e81..6be6c07e30 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -44,6 +44,11 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg); int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo); int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo); +int vnodeBegin(SVnode* pVnode, int option); +int vnodeSyncCommit(SVnode* pVnode); +int vnodeAsyncCommit(SVnode* pVnode); + +#define vnodeShouldCommit vnodeBufPoolIsFull #if 1 // SVBufPool @@ -84,13 +89,8 @@ bool vmaIsFull(SVMemAllocator* pVMA); // vnodeCfg.h extern const SVnodeCfg vnodeCfgDefault; -int vnodeCheckCfg(const SVnodeCfg*); -void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc); +int vnodeCheckCfg(const SVnodeCfg*); -// For commit -#define vnodeShouldCommit vnodeBufPoolIsFull -int vnodeSyncCommit(SVnode* pVnode); -int vnodeAsyncCommit(SVnode* pVnode); #endif #ifdef __cplusplus diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index e95878b04e..0ff1408c91 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -52,6 +52,11 @@ typedef struct SVState SVState; typedef struct SVBufPool SVBufPool; typedef struct SQWorkerMgmt SQHandle; +#define VNODE_META_DIR "meta" +#define VNODE_TSDB_DIR "tsdb" +#define VNODE_TQ_DIR "tq" +#define VNODE_WAL_DIR "wal" + typedef struct { int8_t streamType; // sma or other int8_t dstType; @@ -80,10 +85,11 @@ struct SVnodeInfo { }; struct SVnode { - int32_t vgId; char* path; SVnodeCfg config; SVState state; + STfs* pTfs; + SMsgCb msgCb; SVBufPool* pBufPool; SMeta* pMeta; STsdb* pTsdb; @@ -92,10 +98,10 @@ struct SVnode { SSink* pSink; tsem_t canCommit; SQHandle* pQuery; - SMsgCb msgCb; - STfs* pTfs; }; +#define TD_VID(PVNODE) (PVNODE)->config.vgId + // sma void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); diff --git a/source/dnode/vnode/src/meta/metaMain.c b/source/dnode/vnode/src/meta/metaMain.c deleted file mode 100644 index dd60e56371..0000000000 --- a/source/dnode/vnode/src/meta/metaMain.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "tcoding.h" - -#include "vnodeInt.h" - -static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF); -static void metaFree(SMeta *pMeta); -static int metaOpenImpl(SMeta *pMeta); -static void metaCloseImpl(SMeta *pMeta); - -SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) { - SMeta *pMeta = NULL; - - // Allocate handle - pMeta = metaNew(path, pMetaCfg, pMAF); - if (pMeta == NULL) { - // TODO: handle error - return NULL; - } - - // Create META path (TODO) - taosMkDir(path); - - // Open meta - if (metaOpenImpl(pMeta) < 0) { - metaFree(pMeta); - return NULL; - } - - return pMeta; -} - -void metaClose(SMeta *pMeta) { - if (pMeta) { - metaCloseImpl(pMeta); - metaFree(pMeta); - } -} - -void metaRemove(const char *path) { taosRemoveDir(path); } - -/* ------------------------ STATIC METHODS ------------------------ */ -static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) { - SMeta *pMeta; - size_t psize = strlen(path); - - pMeta = (SMeta *)taosMemoryCalloc(1, sizeof(*pMeta)); - if (pMeta == NULL) { - return NULL; - } - - pMeta->path = strdup(path); - if (pMeta->path == NULL) { - metaFree(pMeta); - return NULL; - } - - return pMeta; -}; - -static void metaFree(SMeta *pMeta) { - if (pMeta) { - taosMemoryFreeClear(pMeta->path); - taosMemoryFree(pMeta); - } -} - -static int metaOpenImpl(SMeta *pMeta) { - // Open meta db - if (metaOpenDB(pMeta) < 0) { - // TODO: handle error - metaCloseImpl(pMeta); - return -1; - } - - // Open meta index - if (metaOpenIdx(pMeta) < 0) { - // TODO: handle error - metaCloseImpl(pMeta); - return -1; - } - - // Open meta table uid generator - if (metaOpenUidGnrt(pMeta) < 0) { - // TODO: handle error - metaCloseImpl(pMeta); - return -1; - } - - return 0; -} - -static void metaCloseImpl(SMeta *pMeta) { - metaCloseUidGnrt(pMeta); - metaCloseIdx(pMeta); - metaCloseDB(pMeta); -} \ No newline at end of file diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c new file mode 100644 index 0000000000..4419420e59 --- /dev/null +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "vnodeInt.h" + +int metaOpen(SVnode *pVnode, SMeta **ppMeta) { + SMeta *pMeta = NULL; + int slen; + + *ppMeta = NULL; + + // create handle + slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3; + if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + pMeta->path = (char *)&pMeta[1]; + sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, + VNODE_META_DIR); + pMeta->pVnode = pVnode; + + // create path if not created yet + taosMkDir(pMeta->path); + + // open meta + if (metaOpenDB(pMeta) < 0) { + goto _err; + } + + if (metaOpenIdx(pMeta) < 0) { + goto _err; + } + + *ppMeta = pMeta; + return 0; + +_err: + if (pMeta->pIdx) metaCloseIdx(pMeta); + if (pMeta->pDB) metaCloseDB(pMeta); + taosMemoryFree(pMeta); + return -1; +} + +int metaClose(SMeta *pMeta) { + if (pMeta) { + metaCloseIdx(pMeta); + metaCloseDB(pMeta); + taosMemoryFree(pMeta); + } + + return 0; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/meta/metaTDBImpl.c b/source/dnode/vnode/src/meta/metaTDBImpl.c index 9b9f54b5ba..9fd11222bf 100644 --- a/source/dnode/vnode/src/meta/metaTDBImpl.c +++ b/source/dnode/vnode/src/meta/metaTDBImpl.c @@ -299,10 +299,10 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) { if (pTbCfg->type == META_SUPER_TABLE) { schemaWrapper.nCols = pTbCfg->stbCfg.nCols; - schemaWrapper.pSchemaEx = pTbCfg->stbCfg.pSchema; + schemaWrapper.pSchema = pTbCfg->stbCfg.pSchema; } else { schemaWrapper.nCols = pTbCfg->ntbCfg.nCols; - schemaWrapper.pSchemaEx = pTbCfg->ntbCfg.pSchema; + schemaWrapper.pSchema = pTbCfg->ntbCfg.pSchema; } pVal = pBuf = buf; metaEncodeSchemaEx(&pBuf, &schemaWrapper); @@ -464,7 +464,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) { tb_uid_t quid; SSchemaWrapper *pSW; STSchemaBuilder sb; - SSchemaEx *pSchema; + SSchema *pSchema; STSchema *pTSchema; STbCfg *pTbCfg; @@ -482,8 +482,8 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) { tdInitTSchemaBuilder(&sb, 0); for (int i = 0; i < pSW->nCols; i++) { - pSchema = pSW->pSchemaEx + i; - tdAddColToSchema(&sb, pSchema->type, pSchema->sma, pSchema->colId, pSchema->bytes); + pSchema = pSW->pSchema + i; + tdAddColToSchema(&sb, pSchema->type, pSchema->flags, pSchema->colId, pSchema->bytes); } pTSchema = tdGetSchemaFromBuilder(&sb); tdDestroyTSchemaBuilder(&sb); @@ -939,7 +939,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) { for (int i = 0; i < pSW->nCols; i++) { pSchema = pSW->pSchema + i; tlen += taosEncodeFixedI8(buf, pSchema->type); - tlen += taosEncodeFixedI8(buf, pSchema->index); + tlen += taosEncodeFixedI8(buf, pSchema->flags); tlen += taosEncodeFixedI16(buf, pSchema->colId); tlen += taosEncodeFixedI32(buf, pSchema->bytes); tlen += taosEncodeString(buf, pSchema->name); @@ -966,14 +966,14 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) { } static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW) { - int tlen = 0; - SSchemaEx *pSchema; + int tlen = 0; + SSchema *pSchema; tlen += taosEncodeFixedU32(buf, pSW->nCols); for (int i = 0; i < pSW->nCols; ++i) { - pSchema = pSW->pSchemaEx + i; + pSchema = pSW->pSchema + i; tlen += taosEncodeFixedI8(buf, pSchema->type); - tlen += taosEncodeFixedI8(buf, pSchema->sma); + tlen += taosEncodeFixedI8(buf, pSchema->flags); tlen += taosEncodeFixedI16(buf, pSchema->colId); tlen += taosEncodeFixedI32(buf, pSchema->bytes); tlen += taosEncodeString(buf, pSchema->name); @@ -985,11 +985,11 @@ static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW) { static void *metaDecodeSchemaEx(void *buf, SSchemaWrapper *pSW, bool isGetEx) { buf = taosDecodeFixedU32(buf, &pSW->nCols); if (isGetEx) { - pSW->pSchemaEx = (SSchemaEx *)taosMemoryMalloc(sizeof(SSchemaEx) * pSW->nCols); + pSW->pSchema = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pSW->nCols); for (int i = 0; i < pSW->nCols; i++) { - SSchemaEx *pSchema = pSW->pSchemaEx + i; + SSchema *pSchema = pSW->pSchema + i; buf = taosDecodeFixedI8(buf, &pSchema->type); - buf = taosDecodeFixedI8(buf, &pSchema->sma); + buf = taosDecodeFixedI8(buf, &pSchema->flags); buf = taosDecodeFixedI16(buf, &pSchema->colId); buf = taosDecodeFixedI32(buf, &pSchema->bytes); buf = taosDecodeStringTo(buf, pSchema->name); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index bfcc5dd2bb..0aa6023eaf 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -19,15 +19,13 @@ int32_t tqInit() { return tqPushMgrInit(); } void tqCleanUp() { tqPushMgrCleanUp(); } -STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig, - SMemAllocatorFactory* allocFac) { +STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMemAllocatorFactory* allocFac) { STQ* pTq = taosMemoryMalloc(sizeof(STQ)); if (pTq == NULL) { terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; return NULL; } pTq->path = strdup(path); - pTq->tqConfig = tqConfig; pTq->pVnode = pVnode; pTq->pWal = pWal; pTq->pVnodeMeta = pVnodeMeta; @@ -267,7 +265,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch, - pTq->pVnode->vgId, pReq->currentOffset, fetchOffset); + TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset); SMqPollRsp rsp = { /*.consumerId = consumerId,*/ @@ -277,7 +275,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId); if (pConsumer == NULL) { - vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, pTq->pVnode->vgId); + vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode)); pMsg->pCont = NULL; pMsg->contLen = 0; pMsg->code = -1; @@ -303,7 +301,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } if (pTopic == NULL) { vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic, - pTq->pVnode->vgId); + TD_VID(pTq->pVnode)); pMsg->pCont = NULL; pMsg->contLen = 0; pMsg->code = -1; @@ -312,7 +310,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch, - pTq->pVnode->vgId); + TD_VID(pTq->pVnode)); rsp.reqOffset = pReq->currentOffset; rsp.skipLogNum = 0; @@ -323,7 +321,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { consumerEpoch = atomic_load_32(&pConsumer->epoch); if (consumerEpoch > reqEpoch) { vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d", - consumerId, pReq->epoch, pTq->pVnode->vgId, fetchOffset, consumerEpoch, reqEpoch); + consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch); break; } SWalReadHead* pHead; @@ -332,11 +330,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { // if data inserted during waiting, launch query and // response to user vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch, - pTq->pVnode->vgId, fetchOffset); + TD_VID(pTq->pVnode), fetchOffset); break; } vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, - pTq->pVnode->vgId, fetchOffset, pHead->msgType); + TD_VID(pTq->pVnode), fetchOffset, pHead->msgType); /*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/ /*pHead = pTopic->pReadhandle->pHead;*/ if (pHead->msgType == TDMT_VND_SUBMIT) { @@ -361,7 +359,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { if (taosArrayGetSize(pRes) == 0) { vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId, - pReq->epoch, pTq->pVnode->vgId, fetchOffset); + pReq->epoch, TD_VID(pTq->pVnode), fetchOffset); fetchOffset++; rsp.skipLogNum++; taosArrayDestroy(pRes); @@ -390,7 +388,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { pMsg->pCont = buf; pMsg->contLen = tlen; pMsg->code = 0; - vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", pTq->pVnode->vgId, fetchOffset, + vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset, pHead->msgType, consumerId, pReq->epoch); tmsgSendRsp(pMsg); taosMemoryFree(pHead); @@ -422,7 +420,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { pMsg->contLen = tlen; pMsg->code = 0; tmsgSendRsp(pMsg); - vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", pTq->pVnode->vgId, fetchOffset, consumerId, + vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId, pReq->epoch); /*}*/ @@ -446,14 +444,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch, - pTq->pVnode->vgId, pReq->currentOffset, fetchOffset); + TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset); SMqPollRspV2 rspV2 = {0}; rspV2.dataLen = 0; STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId); if (pConsumer == NULL) { - vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, pTq->pVnode->vgId); + vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode)); pMsg->pCont = NULL; pMsg->contLen = 0; pMsg->code = -1; @@ -479,7 +477,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } if (pTopic == NULL) { vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic, - pTq->pVnode->vgId); + TD_VID(pTq->pVnode)); pMsg->pCont = NULL; pMsg->contLen = 0; pMsg->code = -1; @@ -488,7 +486,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch, - pTq->pVnode->vgId); + TD_VID(pTq->pVnode)); rspV2.reqOffset = pReq->currentOffset; rspV2.skipLogNum = 0; @@ -499,7 +497,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { consumerEpoch = atomic_load_32(&pConsumer->epoch); if (consumerEpoch > reqEpoch) { vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d", - consumerId, pReq->epoch, pTq->pVnode->vgId, fetchOffset, consumerEpoch, reqEpoch); + consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch); break; } SWalReadHead* pHead; @@ -508,11 +506,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { // if data inserted during waiting, launch query and // response to user vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch, - pTq->pVnode->vgId, fetchOffset); + TD_VID(pTq->pVnode), fetchOffset); break; } vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, - pTq->pVnode->vgId, fetchOffset, pHead->msgType); + TD_VID(pTq->pVnode), fetchOffset, pHead->msgType); /*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/ /*pHead = pTopic->pReadhandle->pHead;*/ if (pHead->msgType == TDMT_VND_SUBMIT) { @@ -537,7 +535,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { if (taosArrayGetSize(pRes) == 0) { vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId, - pReq->epoch, pTq->pVnode->vgId, fetchOffset); + pReq->epoch, TD_VID(pTq->pVnode), fetchOffset); fetchOffset++; rspV2.skipLogNum++; taosArrayDestroy(pRes); @@ -597,7 +595,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { pMsg->pCont = buf; pMsg->contLen = msgLen; pMsg->code = 0; - vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", pTq->pVnode->vgId, fetchOffset, + vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset, pHead->msgType, consumerId, pReq->epoch); tmsgSendRsp(pMsg); taosMemoryFree(pHead); @@ -631,7 +629,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { pMsg->contLen = tlen; pMsg->code = 0; tmsgSendRsp(pMsg); - vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", pTq->pVnode->vgId, fetchOffset, consumerId, + vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId, pReq->epoch); /*}*/ @@ -742,7 +740,7 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle); ASSERT(pTopic->buffer.output[i].task); } - vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, pTq->pVnode->vgId); + vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, TD_VID(pTq->pVnode)); taosArrayPush(pConsumer->topics, pTopic); if (create) { tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index a1edb7cd9c..09616a8969 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -100,7 +100,7 @@ int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) { level = tsdbGetFidLevel(pSet->fid, pRtn); - if (tfsAllocDisk(pRepo->pTfs, level, &did) < 0) { + if (tfsAllocDisk(pRepo->pVnode->pTfs, level, &did) < 0) { terrno = TSDB_CODE_TDB_NO_AVAIL_DISK; return -1; } @@ -427,7 +427,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) { pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable)); pCommitIter->pTable->uid = pTbData->uid; pCommitIter->pTable->tid = pTbData->uid; - pCommitIter->pTable->pSchema = metaGetTbTSchema(pRepo->pMeta, pTbData->uid, 0); + pCommitIter->pTable->pSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0); } return 0; @@ -459,7 +459,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid STsdb *pRepo = TSDB_COMMIT_REPO(pCommith); SDFileSet *pWSet = TSDB_COMMIT_WRITE_FSET(pCommith); - if (tfsAllocDisk(pRepo->pTfs, tsdbGetFidLevel(fid, &(pCommith->rtn)), &did) < 0) { + if (tfsAllocDisk(REPO_TFS(pRepo), tsdbGetFidLevel(fid, &(pCommith->rtn)), &did) < 0) { terrno = TSDB_CODE_TDB_NO_AVAIL_DISK; return -1; } @@ -1201,6 +1201,23 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) { } } +/** + * @brief Write SDataCols to data file. + * + * @param pRepo + * @param pTable + * @param pDFile + * @param pDFileAggr + * @param pDataCols The pDataCols would be generated from mem/imem directly with 2 bits bitmap or from tsdbRead + * interface with 1 bit bitmap. + * @param pBlock + * @param isLast + * @param isSuper + * @param ppBuf + * @param ppCBuf + * @param ppExBuf + * @return int + */ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDFileAggr, SDataCols *pDataCols, SBlock *pBlock, bool isLast, bool isSuper, void **ppBuf, void **ppCBuf, void **ppExBuf) { STsdbCfg *pCfg = REPO_CFG(pRepo); @@ -1244,14 +1261,15 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF pBlockCol->type = pDataCol->type; pAggrBlkCol->colId = pDataCol->colId; - if (tDataTypes[pDataCol->type].statisFunc) { + if (isSuper && pColumn->sma && tDataTypes[pDataCol->type].statisFunc) { #if 0 (*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max), &(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex), &(pBlockCol->numOfNull)); #endif - (*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pAggrBlkCol->min), &(pAggrBlkCol->max), - &(pAggrBlkCol->sum), &(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex), + (*tDataTypes[pDataCol->type].statisFunc)(pDataCols->bitmapMode, pDataCol->pBitmap, pDataCol->pData, rowsToWrite, + &(pAggrBlkCol->min), &(pAggrBlkCol->max), &(pAggrBlkCol->sum), + &(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex), &(pAggrBlkCol->numOfNull)); if (pAggrBlkCol->numOfNull == 0) { @@ -1259,13 +1277,16 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF } else { TD_SET_COL_ROWS_MISC(pBlockCol); } + } else if (tdIsBitmapBlkNorm(pDataCol->pBitmap, rowsToWrite, pDataCols->bitmapMode)) { + // check if all rows normal + TD_SET_COL_ROWS_NORM(pBlockCol); } else { TD_SET_COL_ROWS_MISC(pBlockCol); } ++nColsNotAllNull; - if (pColumn->sma) { + if (isSuper && pColumn->sma) { ++nColsOfBlockSma; } } @@ -1277,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF uint32_t toffset = 0; int32_t tsize = (int32_t)tsdbBlockStatisSize(nColsNotAllNull, SBlockVerLatest); int32_t lsize = tsize; - uint32_t tsizeAggr = (uint32_t)tsdbBlockAggrSize(nColsNotAllNull, SBlockVerLatest); + uint32_t tsizeAggr = (uint32_t)tsdbBlockAggrSize(nColsOfBlockSma, SBlockVerLatest); int32_t keyLen = 0; int32_t nBitmaps = (int32_t)TD_BITMAP_BYTES(rowsToWrite); int32_t sBitmaps = isSuper ? (int32_t)TD_BITMAP_BYTES_I(rowsToWrite) : nBitmaps; diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index 866c02cbb3..0012a50ccf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -644,7 +644,7 @@ static int tsdbComparFidFSet(const void *arg1, const void *arg2) { } static void tsdbGetTxnFname(STsdb *pRepo, TSDB_TXN_FILE_T ftype, char fname[]) { - snprintf(fname, TSDB_FILENAME_LEN, "%s/vnode/vnode%d/tsdb/%s", tfsGetPrimaryPath(pRepo->pTfs), pRepo->vgId, + snprintf(fname, TSDB_FILENAME_LEN, "%s/vnode/vnode%d/tsdb/%s", tfsGetPrimaryPath(REPO_TFS(pRepo)), pRepo->vgId, tsdbTxnFname[ftype]); } @@ -912,7 +912,7 @@ static int tsdbScanRootDir(STsdb *pRepo) { const STfsFile *pf; tsdbGetRootDir(REPO_ID(pRepo), rootDir); - STfsDir *tdir = tfsOpendir(pRepo->pTfs, rootDir); + STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), rootDir); if (tdir == NULL) { tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), rootDir, tstrerror(terrno)); return -1; @@ -946,7 +946,7 @@ static int tsdbScanDataDir(STsdb *pRepo) { const STfsFile *pf; tsdbGetDataDir(REPO_ID(pRepo), dataDir); - STfsDir *tdir = tfsOpendir(pRepo->pTfs, dataDir); + STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), dataDir); if (tdir == NULL) { tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), dataDir, tstrerror(terrno)); return -1; @@ -1128,7 +1128,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) { return -1; } - tdir = tfsOpendir(pRepo->pTfs, dataDir); + tdir = tfsOpendir(REPO_TFS(pRepo), dataDir); if (tdir == NULL) { tsdbError("vgId:%d failed to restore DFileSet while open directory %s since %s", REPO_ID(pRepo), dataDir, tstrerror(terrno)); diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 8e5a6afc4d..2fbe819476 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -311,7 +311,7 @@ void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t pDFile->info.fver = tsdbGetDFSVersion(ftype); tsdbGetFilename(pRepo->vgId, fid, ver, ftype, fname); - tfsInitFile(pRepo->pTfs, &(pDFile->f), did, fname); + tfsInitFile(REPO_TFS(pRepo), &(pDFile->f), did, fname); } void tsdbInitDFileEx(SDFile *pDFile, SDFile *pODFile) { @@ -330,7 +330,7 @@ int tsdbEncodeSDFile(void **buf, SDFile *pDFile) { void *tsdbDecodeSDFile(STsdb *pRepo, void *buf, SDFile *pDFile) { buf = tsdbDecodeDFInfo(buf, &(pDFile->info)); - buf = tfsDecodeFile(pRepo->pTfs, buf, &(pDFile->f)); + buf = tfsDecodeFile(REPO_TFS(pRepo), buf, &(pDFile->f)); TSDB_FILE_SET_CLOSED(pDFile); return buf; @@ -365,7 +365,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T if (errno == ENOENT) { // Try to create directory recursively char *s = strdup(TSDB_FILE_REL_NAME(pDFile)); - if (tfsMkdirRecurAt(pRepo->pTfs, taosDirName(s), TSDB_FILE_DID(pDFile)) < 0) { + if (tfsMkdirRecurAt(REPO_TFS(pRepo), taosDirName(s), TSDB_FILE_DID(pDFile)) < 0) { taosMemoryFreeClear(s); return -1; } @@ -443,7 +443,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) { } static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) { - SDFile df; + SDFile df; tsdbInitDFileEx(&df, pDFile); diff --git a/source/dnode/vnode/src/tsdb/tsdbMain.c b/source/dnode/vnode/src/tsdb/tsdbMain.c index 8543cde046..dd8723366d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMain.c +++ b/source/dnode/vnode/src/tsdb/tsdbMain.c @@ -15,14 +15,12 @@ #include "vnodeInt.h" -static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, - SMeta *pMeta, STfs *pTfs); +static STsdb *tsdbNew(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF); static void tsdbFree(STsdb *pTsdb); static int tsdbOpenImpl(STsdb *pTsdb); static void tsdbCloseImpl(STsdb *pTsdb); -STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta, - STfs *pTfs) { +STsdb *tsdbOpen(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF) { STsdb *pTsdb = NULL; // Set default TSDB Options @@ -37,7 +35,7 @@ STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAl } // Create the handle - pTsdb = tsdbNew(path, vgId, pTsdbCfg, pMAF, pMeta, pTfs); + pTsdb = tsdbNew(path, pVnode, pTsdbCfg, pMAF); if (pTsdb == NULL) { // TODO: handle error return NULL; @@ -61,11 +59,8 @@ void tsdbClose(STsdb *pTsdb) { } } -void tsdbRemove(const char *path) { taosRemoveDir(path); } - /* ------------------------ STATIC METHODS ------------------------ */ -static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, - SMeta *pMeta, STfs *pTfs) { +static STsdb *tsdbNew(const char *path, SVnode *pVnode, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF) { STsdb *pTsdb = NULL; pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb)); @@ -75,11 +70,10 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, } pTsdb->path = strdup(path); - pTsdb->vgId = vgId; + pTsdb->vgId = TD_VID(pVnode); + pTsdb->pVnode = pVnode; tsdbOptionsCopy(&(pTsdb->config), pTsdbCfg); pTsdb->pmaf = pMAF; - pTsdb->pMeta = pMeta; - pTsdb->pTfs = pTfs; pTsdb->fs = tsdbNewFS(pTsdbCfg); return pTsdb; @@ -156,7 +150,7 @@ int tsdbUnlockRepo(STsdb *pTsdb) { #define IS_VALID_PRECISION(precision) \ (((precision) >= TSDB_TIME_PRECISION_MILLI) && ((precision) <= TSDB_TIME_PRECISION_NANO)) -#define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP +#define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP #define IS_VALID_COMPRESSION(compression) (((compression) >= NO_COMPRESSION) && ((compression) <= TWO_STAGE_COMP)) static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 1314ef7d1e..ab933f840a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -99,10 +99,10 @@ typedef struct SIOCostSummary { typedef struct STsdbReadHandle { STsdb* pTsdb; - SQueryFilePos cur; // current position + SQueryFilePos cur; // current position int16_t order; - STimeWindow window; // the primary query time window that applies to all queries - SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time + STimeWindow window; // the primary query time window that applies to all queries + SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time int32_t numOfBlocks; SArray* pColumns; // column list, SColumnInfoData array list bool locateStart; @@ -377,7 +377,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond, if (pCond->numOfCols > 0) { // allocate buffer in order to load data blocks from file - pReadHandle->statis = taosMemoryCalloc(pCond->numOfCols, sizeof(SDataStatis)); + pReadHandle->statis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg)); if (pReadHandle->statis == NULL) { goto _end; } @@ -477,7 +477,7 @@ void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond* pCond) { } // allocate buffer in order to load data blocks from file - memset(pTsdbReadHandle->statis, 0, sizeof(SDataStatis)); + memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg)); tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo); tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo); @@ -505,7 +505,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, STsdbQueryCond* pC } // allocate buffer in order to load data blocks from file - memset(pTsdbReadHandle->statis, 0, sizeof(SDataStatis)); + memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg)); tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo); tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo); @@ -986,7 +986,7 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in pCheckInfo->numOfBlocks = 0; STable table = {.uid = pCheckInfo->tableId, .tid = pCheckInfo->tableId}; - table.pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); + table.pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 0); if (tsdbSetReadTable(&pTsdbReadHandle->rhelper, &table) != TSDB_CODE_SUCCESS) { code = terrno; @@ -1091,7 +1091,7 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl int32_t slotIndex) { int64_t st = taosGetTimestampUs(); - STSchema* pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); + STSchema* pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 0); int32_t code = tdInitDataCols(pTsdbReadHandle->pDataCols, pSchema); if (code != TSDB_CODE_SUCCESS) { tsdbError("%p failed to malloc buf for pDataCols, %s", pTsdbReadHandle, pTsdbReadHandle->idStr); @@ -1483,7 +1483,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit int32_t numOfColsOfRow1 = 0; if (pSchema1 == NULL) { - pSchema1 = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, uid, TD_ROW_SVER(row1)); + pSchema1 = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), uid, TD_ROW_SVER(row1)); } if (isRow1DataRow) { @@ -1496,7 +1496,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit if (row2) { isRow2DataRow = TD_IS_TP_ROW(row2); if (pSchema2 == NULL) { - pSchema2 = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, uid, TD_ROW_SVER(row2)); + pSchema2 = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), uid, TD_ROW_SVER(row2)); } if (isRow2DataRow) { numOfColsOfRow2 = schemaNCols(pSchema2); @@ -2514,7 +2514,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int win->ekey = key; if (rv != TD_ROW_SVER(row)) { - pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); + pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 0); rv = TD_ROW_SVER(row); } mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, numOfRows, row, NULL, numOfCols, pCheckInfo->tableId, pSchema, @@ -3222,7 +3222,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa /* * return null for mixed data block, if not a complete file data block, the statistics value will always return NULL */ -int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStatis** pBlockStatis) { +int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDataAgg** pBlockStatis) { STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle; SQueryFilePos* c = &pHandle->cur; @@ -3252,7 +3252,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati int16_t* colIds = pHandle->defaultLoadColumn->pData; size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle); - memset(pHandle->statis, 0, numOfCols * sizeof(SDataStatis)); + memset(pHandle->statis, 0, numOfCols * sizeof(SColumnDataAgg)); for (int32_t i = 0; i < numOfCols; ++i) { pHandle->statis[i].colId = colIds[i]; } @@ -3260,7 +3260,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati tsdbGetBlockStatis(&pHandle->rhelper, pHandle->statis, (int)numOfCols, pBlockInfo->compBlock); // always load the first primary timestamp column data - SDataStatis* pPrimaryColStatis = &pHandle->statis[0]; + SColumnDataAgg* pPrimaryColStatis = &pHandle->statis[0]; assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID); pPrimaryColStatis->numOfNull = 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index 187ec54949..b15271a51a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -433,7 +433,7 @@ void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx) { return buf; } -void tsdbGetBlockStatis(SReadH *pReadh, SDataStatis *pStatis, int numOfCols, SBlock *pBlock) { +void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols, SBlock *pBlock) { #ifdef TD_REFACTOR_3 SBlockData *pBlockData = pReadh->pBlkData; diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index b98fe8936a..4b1c213cdd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -260,7 +260,7 @@ static void poolFree(void *arg, void *ptr) { int32_t tsdbInitSma(STsdb *pTsdb) { // tSma - int32_t numOfTSma = taosArrayGetSize(metaGetSmaTbUids(pTsdb->pMeta, false)); + int32_t numOfTSma = taosArrayGetSize(metaGetSmaTbUids(REPO_META(pTsdb), false)); if (numOfTSma > 0) { atomic_store_16(&REPO_TSMA_NUM(pTsdb), (int16_t)numOfTSma); } @@ -348,7 +348,7 @@ static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did) } char aname[TSDB_FILENAME_LEN] = {0}; - tfsAbsoluteName(pTsdb->pTfs, did, path, aname); + tfsAbsoluteName(REPO_TFS(pTsdb), did, path, aname); if (tsdbOpenDBEnv(&pEnv->dbEnv, aname) != TSDB_CODE_SUCCESS) { tsdbFreeSmaEnv(pEnv); return NULL; @@ -519,14 +519,14 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { char rname[TSDB_FILENAME_LEN] = {0}; SDiskID did = {0}; - tfsAllocDisk(pTsdb->pTfs, TFS_PRIMARY_LEVEL, &did); + tfsAllocDisk(REPO_TFS(pTsdb), TFS_PRIMARY_LEVEL, &did); if (did.level < 0 || did.id < 0) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } tsdbGetSmaDir(REPO_ID(pTsdb), smaType, rname); - if (tfsMkdirRecurAt(pTsdb->pTfs, rname, did) != TSDB_CODE_SUCCESS) { + if (tfsMkdirRecurAt(REPO_TFS(pTsdb), rname, did) != TSDB_CODE_SUCCESS) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } @@ -557,7 +557,7 @@ static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t } // cache smaMeta - STSma *pSma = metaGetSmaInfoByIndex(pTsdb->pMeta, indexUid, true); + STSma *pSma = metaGetSmaInfoByIndex(REPO_META(pTsdb), indexUid, true); if (pSma == NULL) { terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META; taosHashCleanup(pItem->expiredWindows); @@ -613,7 +613,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers return TSDB_CODE_SUCCESS; } - if (!pTsdb->pMeta) { + if (!REPO_META(pTsdb)) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } @@ -1583,7 +1583,7 @@ int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg) { // record current timezone of server side vCreateSmaReq.tSma.timezoneInt = tsTimezone; - if (metaCreateTSma(pTsdb->pMeta, &vCreateSmaReq) < 0) { + if (metaCreateTSma(REPO_META(pTsdb), &vCreateSmaReq) < 0) { // TODO: handle error tdDestroyTSma(&vCreateSmaReq.tSma); return -1; @@ -1610,7 +1610,7 @@ int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg) { // } // - if (metaDropTSma(pTsdb->pMeta, vDropSmaReq.indexUid) < 0) { + if (metaDropTSma(REPO_META(pTsdb), vDropSmaReq.indexUid) < 0) { // TODO: handle error return -1; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 34b983c20c..a5596dc998 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -23,11 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) { return 0; } -#if 1 //====================================================================== -void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { - memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); -} - int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { uint32_t hashValue = 0; @@ -47,5 +42,3 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { return TSDB_CODE_SUCCESS; } - -#endif \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index fa249d3ba1..3ece3c054e 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -108,7 +108,7 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) { goto _err; } - pData = taosMemoryMalloc(size); + pData = taosMemoryMalloc(size + 1); if (pData == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -119,6 +119,8 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) { goto _err; } + pData[size] = '\0'; + taosCloseFile(&pFile); // decode info @@ -202,6 +204,16 @@ static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1; return 0; } @@ -229,6 +241,16 @@ static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1; + if (tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1; + if (tjsonGetNumberValue(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1; + if (tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1; return 0; } @@ -286,7 +308,7 @@ _err: static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) { SJson *pJson = NULL; - pJson = tjsonCreateObject(); + pJson = tjsonParse(pData); if (pJson == NULL) { return -1; } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 241c26ab1c..9e4aa714e2 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -15,11 +15,6 @@ #include "vnodeInt.h" -static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg); -static void vnodeFree(SVnode *pVnode); -static int vnodeOpenImpl(SVnode *pVnode); -static void vnodeCloseImpl(SVnode *pVnode); - int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { SVnodeInfo info = {0}; char dir[TSDB_FILENAME_LEN]; @@ -51,141 +46,116 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { return 0; } -SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { - SVnode *pVnode = NULL; +void vnodeDestroy(const char *path, STfs *pTfs) { tfsRmdir(pTfs, path); } - // Set default options - SVnodeCfg cfg = vnodeCfgDefault; - if (pVnodeCfg != NULL) { - cfg.vgId = pVnodeCfg->vgId; - cfg.msgCb = pVnodeCfg->msgCb; - cfg.pTfs = pVnodeCfg->pTfs; - cfg.dbId = pVnodeCfg->dbId; - cfg.hashBegin = pVnodeCfg->hashBegin; - cfg.hashEnd = pVnodeCfg->hashEnd; - cfg.hashMethod = pVnodeCfg->hashMethod; - } +SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { + SVnode *pVnode = NULL; + SVnodeInfo info = {0}; + char dir[TSDB_FILENAME_LEN]; + char tdir[TSDB_FILENAME_LEN * 2]; + int ret; - // Validate options - if (vnodeCheckCfg(&cfg) < 0) { - // TODO + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + + // load vnode info + ret = vnodeLoadInfo(dir, &info); + if (ret < 0) { + vError("failed to open vnode from %s since %s", path, tstrerror(terrno)); return NULL; } - // Create the handle - pVnode = vnodeNew(path, &cfg); + // create handle + pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1); if (pVnode == NULL) { - // TODO: handle error + terrno = TSDB_CODE_OUT_OF_MEMORY; + vError("vgId: %d failed to open vnode since %s", info.config.vgId, tstrerror(terrno)); return NULL; } - taosMkDir(path); + pVnode->path = (char *)&pVnode[1]; + strcpy(pVnode->path, path); + pVnode->config = info.config; + pVnode->state.committed = info.state.committed; + pVnode->state.processed = pVnode->state.applied = pVnode->state.committed; + pVnode->pTfs = pTfs; + pVnode->msgCb = msgCb; - // Open the vnode - if (vnodeOpenImpl(pVnode) < 0) { - // TODO: handle error - return NULL; + tsem_init(&(pVnode->canCommit), 0, 1); + + // open buffer pool + if (vnodeOpenBufPool(pVnode) < 0) { + vError("vgId: %d failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; } + // open meta + if (metaOpen(pVnode, &pVnode->pMeta) < 0) { + vError("vgId: %d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + + // open tsdb + sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TSDB_DIR); + pVnode->pTsdb = tsdbOpen(tdir, pVnode, &(pVnode->config.tsdbCfg), vBufPoolGetMAF(pVnode)); + if (pVnode->pTsdb == NULL) { + vError("vgId: %d failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + + // open wal + sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR); + pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg)); + if (pVnode->pWal == NULL) { + vError("vgId: %d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + + // open tq + sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR); + pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal, pVnode->pMeta, vBufPoolGetMAF(pVnode)); + if (pVnode->pTq == NULL) { + vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + + // open query + if (vnodeQueryOpen(pVnode)) { + vError("vgId: %d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + +#if 0 + if (vnodeBegin() < 0) { + goto _err; + } +#endif + return pVnode; + +_err: + 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->pMeta) metaClose(pVnode->pMeta); + tsem_destroy(&(pVnode->canCommit)); + taosMemoryFree(pVnode); + return NULL; } void vnodeClose(SVnode *pVnode) { if (pVnode) { - vnodeCloseImpl(pVnode); - vnodeFree(pVnode); - } -} - -void vnodeDestroy(const char *path) { taosRemoveDir(path); } - -/* ------------------------ STATIC METHODS ------------------------ */ -static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg) { - SVnode *pVnode = NULL; - - pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode)); - if (pVnode == NULL) { - // TODO - return NULL; - } - - pVnode->vgId = pVnodeCfg->vgId; - pVnode->msgCb = pVnodeCfg->msgCb; - pVnode->pTfs = pVnodeCfg->pTfs; - pVnode->path = strdup(path); - vnodeOptionsCopy(&(pVnode->config), pVnodeCfg); - - tsem_init(&(pVnode->canCommit), 0, 1); - - return pVnode; -} - -static void vnodeFree(SVnode *pVnode) { - if (pVnode) { + // commit (TODO: use option to control) + vnodeSyncCommit(pVnode); + // close vnode + vnodeQueryClose(pVnode); + walClose(pVnode->pWal); + tqClose(pVnode->pTq); + tsdbClose(pVnode->pTsdb); + metaClose(pVnode->pMeta); + vnodeCloseBufPool(pVnode); + // destroy handle tsem_destroy(&(pVnode->canCommit)); - taosMemoryFreeClear(pVnode->path); taosMemoryFree(pVnode); } } - -static int vnodeOpenImpl(SVnode *pVnode) { - char dir[TSDB_FILENAME_LEN]; - - if (vnodeOpenBufPool(pVnode) < 0) { - // TODO: handle error - return -1; - } - - // Open meta - sprintf(dir, "%s/meta", pVnode->path); - pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg), vBufPoolGetMAF(pVnode)); - if (pVnode->pMeta == NULL) { - // TODO: handle error - return -1; - } - - // Open tsdb - sprintf(dir, "%s/tsdb", pVnode->path); - pVnode->pTsdb = - tsdbOpen(dir, pVnode->vgId, &(pVnode->config.tsdbCfg), vBufPoolGetMAF(pVnode), pVnode->pMeta, pVnode->pTfs); - if (pVnode->pTsdb == NULL) { - // TODO: handle error - return -1; - } - - // Open WAL - sprintf(dir, "%s/wal", pVnode->path); - pVnode->pWal = walOpen(dir, &(pVnode->config.walCfg)); - if (pVnode->pWal == NULL) { - // TODO: handle error - return -1; - } - - // Open TQ - sprintf(dir, "%s/tq", pVnode->path); - pVnode->pTq = tqOpen(dir, pVnode, pVnode->pWal, pVnode->pMeta, &(pVnode->config.tqCfg), vBufPoolGetMAF(pVnode)); - if (pVnode->pTq == NULL) { - // TODO: handle error - return -1; - } - - // Open Query - if (vnodeQueryOpen(pVnode)) { - return -1; - } - - // TODO - return 0; -} - -static void vnodeCloseImpl(SVnode *pVnode) { - vnodeSyncCommit(pVnode); - if (pVnode) { - vnodeCloseBufPool(pVnode); - metaClose(pVnode->pMeta); - tsdbClose(pVnode->pTsdb); - tqClose(pVnode->pTq); - walClose(pVnode->pWal); - vnodeQueryClose(pVnode); - } -} diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 75079d50b2..4202c02a0c 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -16,7 +16,7 @@ #include "vnodeInt.h" int vnodeQueryOpen(SVnode *pVnode) { - return qWorkerInit(NODE_TYPE_VNODE, pVnode->vgId, NULL, (void **)&pVnode->pQuery, &pVnode->msgCb); + return qWorkerInit(NODE_TYPE_VNODE, TD_VID(pVnode), NULL, (void **)&pVnode->pQuery, &pVnode->msgCb); } void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); } @@ -101,7 +101,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { metaRsp.numOfColumns = nCols; metaRsp.tableType = pTbCfg->type; metaRsp.tuid = uid; - metaRsp.vgId = pVnode->vgId; + metaRsp.vgId = TD_VID(pVnode); memcpy(metaRsp.pSchemas, pSW->pSchema, sizeof(SSchema) * pSW->nCols); if (nTagCols) { @@ -151,7 +151,7 @@ _exit: } int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { - pLoad->vgId = pVnode->vgId; + pLoad->vgId = TD_VID(pVnode); pLoad->role = TAOS_SYNC_STATE_LEADER; pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); pLoad->numOfTimeSeries = 400; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 87cef53042..288241eb66 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -36,7 +36,7 @@ void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs) { if (walWrite(pVnode->pWal, ver, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) { // TODO: handle error /*ASSERT(false);*/ - vError("vnode:%d write wal error since %s", pVnode->vgId, terrstr()); + vError("vnode:%d write wal error since %s", TD_VID(pVnode), terrstr()); } } @@ -73,12 +73,12 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { case TDMT_VND_ALTER_STB: return vnodeProcessAlterStbReq(pVnode, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))); case TDMT_VND_DROP_STB: - vTrace("vgId:%d, process drop stb req", pVnode->vgId); + vTrace("vgId:%d, process drop stb req", TD_VID(pVnode)); break; case TDMT_VND_DROP_TABLE: break; case TDMT_VND_SUBMIT: - /*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/ + /*printf("vnode %d write data %ld\n", TD_VID(pVnode), ver);*/ if (pVnode->config.streamMode == 0) { *pRsp = taosMemoryCalloc(1, sizeof(SRpcMsg)); (*pRsp)->handle = pMsg->handle; @@ -245,7 +245,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) { // TODO: handle error - vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name); + vError("vgId:%d, failed to create table: %s", TD_VID(pVnode), pCreateTbReq->name); } // TODO: to encapsule a free API taosMemoryFree(pCreateTbReq->name); @@ -268,7 +268,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR } } - vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray)); + vTrace("vgId:%d process create %" PRIzu " tables", TD_VID(pVnode), taosArrayGetSize(vCreateTbBatchReq.pArray)); taosArrayDestroy(vCreateTbBatchReq.pArray); if (vCreateTbBatchRsp.rspList) { int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp); @@ -289,7 +289,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) { SVCreateTbReq vAlterTbReq = {0}; - vTrace("vgId:%d, process alter stb req", pVnode->vgId); + vTrace("vgId:%d, process alter stb req", TD_VID(pVnode)); tDeserializeSVCreateTbReq(pReq, &vAlterTbReq); // TODO: to encapsule a free API taosMemoryFree(vAlterTbReq.stbCfg.pSchema); diff --git a/source/libs/catalog/test/CMakeLists.txt b/source/libs/catalog/test/CMakeLists.txt index 3ffb420b4b..d74eef7855 100644 --- a/source/libs/catalog/test/CMakeLists.txt +++ b/source/libs/catalog/test/CMakeLists.txt @@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(catalogTest ${SOURCE_LIST}) TARGET_LINK_LIBRARIES( catalogTest - PUBLIC os util common catalog transport gtest qcom taos + PUBLIC os util common catalog transport gtest qcom taos_static ) TARGET_INCLUDE_DIRECTORIES( diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index e08e9cf276..4853bb4eb3 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -316,6 +316,9 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t return TSDB_CODE_SUCCESS; } +static uint8_t getIntervalPrecision(SIntervalPhysiNode* pIntNode) { + return ((SColumnNode*)pIntNode->window.pTspk)->node.resType.precision; +} int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { int32_t tlen = 0; @@ -658,10 +661,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - - EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, pIntNode->precision), - pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(pIntNode->precision), - INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, pIntNode->precision), pIntNode->slidingUnit); + uint8_t precision = getIntervalPrecision(pIntNode); + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision), + pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision), + INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision), pIntNode->slidingUnit); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 1f3c003dfb..7c931c860c 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -72,7 +72,8 @@ typedef struct SResultRowInfo { SResultRowPosition *pPosition; int32_t size; // number of result set int32_t capacity; // max capacity - int32_t curPos; // current active result row index of pResult list +// int32_t curPos; // current active result row index of pResult list + SResultRowPosition cur; } SResultRowInfo; struct STaskAttr; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 51dfeed7ae..5ef1754913 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -81,11 +81,11 @@ typedef struct SResultInfo { // TODO refactor } SResultInfo; typedef struct STableQueryInfo { - TSKEY lastKey; // last check ts - uint64_t uid; // table uid - int32_t groupIndex; // group id in table list - // SVariant tag; - SResultRowInfo resInfo; // result info + TSKEY lastKey; // last check ts, todo remove it later + SResultRowPosition pos; // current active time window +// int32_t groupIndex; // group id in table list +// SVariant tag; +// SResultRowInfo resInfo; // result info } STableQueryInfo; typedef enum { @@ -133,7 +133,8 @@ typedef struct STaskCostInfo { uint32_t totalBlocks; uint32_t loadBlocks; uint32_t loadBlockStatis; - uint32_t discardBlocks; + uint32_t skipBlocks; + uint32_t filterOutBlocks; uint64_t elapsedTime; uint64_t firstStageMergeTime; uint64_t winInfoSize; @@ -219,14 +220,9 @@ typedef struct SExecTaskInfo { } SExecTaskInfo; typedef struct STaskRuntimeEnv { - - jmp_buf env; STaskAttr* pQueryAttr; uint32_t status; // query status - void* qinfo; uint8_t scanFlag; // denotes reversed scan of data or not - void* pTsdbReadHandle; - bool enableGroupData; SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file SHashObj* pResultRowHashTable; // quick locate the window object for each result SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not @@ -234,12 +230,10 @@ typedef struct STaskRuntimeEnv { char* keyBuf; // window key buffer // The window result objects pool, all the resultRow Objects are allocated and managed by this object. char** prevRow; - SArray* prevResult; // intermediate result, SArray STSBuf* pTsBuf; // timestamp filter list STSCursor cur; char* tagVal; // tag value of current data block - struct SScalarFunctionSupport* scalarSup; STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure struct SOperatorInfo* proot; SGroupResInfo groupResInfo; @@ -265,12 +259,12 @@ typedef struct SOperatorInfo { char* name; // name, used to show the query execution plan void* info; // extension attribution SExprInfo* pExpr; - STaskRuntimeEnv* pRuntimeEnv; // todo remove it SExecTaskInfo* pTaskInfo; SOperatorCostInfo cost; SResultInfo resultInfo; struct SOperatorInfo** pDownstream; // downstram pointer list int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator + // todo extract struct __optr_open_fn_t _openFn; // DO NOT invoke this function directly __optr_fn_t getNextFn; __optr_fn_t getStreamResFn; // execute the aggregate in the stream model. @@ -289,7 +283,7 @@ typedef struct { typedef enum { EX_SOURCE_DATA_NOT_READY = 0x1, - EX_SOURCE_DATA_READY = 0x2, + EX_SOURCE_DATA_READY = 0x2, EX_SOURCE_DATA_EXHAUSTED = 0x3, } EX_SOURCE_STATUS; @@ -346,8 +340,10 @@ typedef struct STableScanInfo { int64_t elapsedTime; int32_t prevGroupId; // previous table group id - int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan + int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan int32_t dataBlockLoadFlag; + double sampleRatio; // data block sample ratio + SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. } STableScanInfo; typedef struct STagScanInfo { @@ -429,13 +425,17 @@ typedef struct STableIntervalOperatorInfo { } STableIntervalOperatorInfo; typedef struct SAggOperatorInfo { - SOptrBasicInfo binfo; - SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file - SAggSupporter aggSup; - STableQueryInfo* current; - uint32_t groupId; - SGroupResInfo groupResInfo; - STableQueryInfo* pTableQueryInfo; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + STableQueryInfo *current; + uint64_t groupId; + SGroupResInfo groupResInfo; + STableQueryInfo *pTableQueryInfo; + + SExprInfo *pScalarExprInfo; + int32_t numOfScalarExpr; // the number of scalar expression before the aggregate function can be applied + SqlFunctionCtx *pScalarCtx; // scalar function requried sql function struct. + int32_t *rowCellInfoOffset; // offset value for each row result cell info } SAggOperatorInfo; typedef struct SProjectOperatorInfo { @@ -582,7 +582,7 @@ typedef struct SSortOperatorInfo { typedef struct STagFilterOperatorInfo { SOptrBasicInfo binfo; } STagFilterOperatorInfo; - + typedef struct SJoinOperatorInfo { SSDataBlock *pRes; int32_t joinType; @@ -594,10 +594,7 @@ typedef struct SJoinOperatorInfo { SSDataBlock *pRight; int32_t rightPos; SColumnInfo rightCol; - SNode *pOnCondition; -// SJoinStatus *status; -// int32_t numOfUpstream; // SRspResultInfo resultInfo; } SJoinOperatorInfo; @@ -618,6 +615,8 @@ void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput); int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData, int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total, SArray* pColList); +void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow* win); + void doSetOperatorCompleted(SOperatorInfo* pOperator); void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset); @@ -625,10 +624,10 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime, - int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, - SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); -SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); + int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, + SInterval* pInterval, double ratio, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo, + int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SExecTaskInfo* pTaskInfo); SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pIndexMap, SExecTaskInfo* pTaskInfo); @@ -669,15 +668,13 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, - SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput); #endif void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList); -void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order); +void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, bool createDummyCol); void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput); void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 1377b2f729..98b72cf4c2 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -52,11 +52,11 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) { } int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) { - pResultRowInfo->size = 0; - pResultRowInfo->curPos = -1; - pResultRowInfo->capacity = size; + pResultRowInfo->size = 0; + pResultRowInfo->capacity = size; + pResultRowInfo->cur.pageId = -1; + pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition)); - if (pResultRowInfo->pPosition == NULL) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } @@ -114,7 +114,6 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) { assert(pResultRowInfo->size >= 0 && pResultRowInfo->capacity >= pResultRowInfo->size); for (int32_t i = 0; i < pResultRowInfo->size; ++i) { -// ASSERT(0); // SResultRow* pRow = pResultRowInfo->pResult[i]; // if (pRow->closed) { // continue; @@ -378,7 +377,7 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv, SGroupResInfo* pGroupResInfo, SArray *pTableList, int32_t* rowCellInfoOffset) { bool ascQuery = true; - +#if 0 int32_t code = TSDB_CODE_SUCCESS; int32_t *posList = NULL; @@ -402,16 +401,16 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv int32_t numOfTables = 0; for (int32_t i = 0; i < size; ++i) { STableQueryInfo *item = taosArrayGetP(pTableList, i); - if (item->resInfo.size > 0) { - pTableQueryInfoList[numOfTables++] = item; - } +// if (item->resInfo.size > 0) { +// pTableQueryInfoList[numOfTables++] = item; +// } } // there is no data in current group // no need to merge results since only one table in each group - if (numOfTables == 0) { - goto _end; - } +// if (numOfTables == 0) { +// goto _end; +// } int32_t order = TSDB_ORDER_ASC; SCompSupporter cs = {pTableQueryInfoList, posList, order}; @@ -498,6 +497,7 @@ int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, STaskRuntimeEnv* pRun // int64_t elapsedTime = taosGetTimestampUs() - st; // qDebug("QInfo:%"PRIu64" merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "us", GET_TASKID(pRuntimeEnv), // pGroupResInfo->currentGroup, pGroupResInfo->totalGroup, elapsedTime); +#endif return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 3e2f95a27c..ed2454faae 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -186,10 +186,9 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type, int16_t bytes); static bool functionNeedToExecute(SqlFunctionCtx* pCtx); -static void setBlockStatisInfo(SqlFunctionCtx* pCtx, SSDataBlock* pSDataBlock, SColumn* pColumn); +static void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pSDataBlock); static void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo); -static bool hasMainOutput(STaskAttr* pQueryAttr); static SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int32_t* numOfFilterCols); @@ -237,13 +236,10 @@ void operatorDummyCloseFn(void* param, int32_t numOfCols) {} static int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, int32_t* rowCellOffset); static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst, - int64_t keyLast, STimeWindow* win); static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo); static void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable); -static void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, - SExecTaskInfo* pTaskInfo); +static void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo); SArray* getOrderCheckColumns(STaskAttr* pQuery); @@ -325,8 +321,7 @@ static bool isSelectivityWithTagsQuery(SqlFunctionCtx* pCtx, int32_t numOfOutput } static bool hasNull(SColumn* pColumn, SColumnDataAgg* pStatis) { - if (TSDB_COL_IS_TAG(pColumn->flag) || TSDB_COL_IS_UD_COL(pColumn->flag) || - pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + if (TSDB_COL_IS_TAG(pColumn->flag) || TSDB_COL_IS_UD_COL(pColumn->flag) || pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { return false; } @@ -439,11 +434,11 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, return pResultRow; } -static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t tid, - char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId, +static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t uid, + char* pData, int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) { bool existInCurrentResusltRowInfo = false; - SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, tableGroupId); + SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId); SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); @@ -460,17 +455,14 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR if (p1 != NULL) { if (pResultRowInfo->size == 0) { existInCurrentResusltRowInfo = false; // this time window created by other timestamp that does not belongs to current table. - assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - // ASSERT(0); SResultRowPosition* p = &pResultRowInfo->pPosition[0]; existInCurrentResusltRowInfo = (p->pageId == p1->pageId && p->offset == p1->offset); } else { // check if current pResultRowInfo contains the existInCurrentResusltRowInfo pResultRow - SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); + SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, uid, pResultRowInfo); int64_t* index = taosHashGet(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); if (index != NULL) { // TODO check the scan order for current opened time window -// pResultRowInfo->curPos = (int32_t)*index; existInCurrentResusltRowInfo = true; } else { existInCurrentResusltRowInfo = false; @@ -487,35 +479,33 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR SResultRow* pResult = NULL; if (!existInCurrentResusltRowInfo) { // 1. close current opened time window - if (pResultRowInfo->curPos != -1) { // todo extract function - SResultRowPosition* pos = &pResultRowInfo->pPosition[pResultRowInfo->curPos]; - SFilePage* pPage = getBufPage(pResultBuf, pos->pageId); - SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); + if (pResultRowInfo->cur.pageId != -1) { // todo extract function + SResultRowPosition pos = pResultRowInfo->cur; + SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); + SResultRow* pRow = (SResultRow*)((char*)pPage + pos.offset); closeResultRow(pRow); releaseBufPage(pResultBuf, pPage); } prepareResultListBuffer(pResultRowInfo, pTaskInfo->env); if (p1 == NULL) { - pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); + pResult = getNewResultRow_rv(pResultBuf, groupId, pSup->resultRowSize); initResultRow(pResult); // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition)); - SResultRowCell cell = {.groupId = tableGroupId, .pos = pos}; + SResultRowCell cell = {.groupId = groupId, .pos = pos}; taosArrayPush(pSup->pResultRowArrayList, &cell); } else { pResult = getResultRowByPos(pResultBuf, p1); } // 2. set the new time window to be the new active time window - pResultRowInfo->curPos = pResultRowInfo->size; pResultRowInfo->pPosition[pResultRowInfo->size++] = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; - - int64_t index = pResultRowInfo->curPos; - SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); - taosHashPut(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &index, POINTER_BYTES); + pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; + SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, uid, pResultRowInfo); + taosHashPut(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &pResultRowInfo->cur, POINTER_BYTES); } else { pResult = getResultRowByPos(pResultBuf, p1); } @@ -553,11 +543,11 @@ static STimeWindow getActiveTimeWindow(SDiskbasedBuf * pBuf, SResultRowInfo* pRe int32_t precision, STimeWindow* win) { STimeWindow w = {0}; - if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value + if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true); w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; } else { - w = getResultRow(pBuf, pResultRowInfo, pResultRowInfo->curPos)->win; + w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win; } if (w.skey > ts || w.ekey < ts) { @@ -791,17 +781,17 @@ static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey } #endif } - -static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey, - bool ascQuery, bool interp) { - if ((lastKey > pWin->ekey && ascQuery) || (lastKey < pWin->ekey && (!ascQuery))) { - closeAllResultRows(pResultRowInfo); - pResultRowInfo->curPos = pResultRowInfo->size - 1; - } else { - int32_t step = ascQuery ? 1 : -1; - doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, interp); - } -} +// +//static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey, +// bool ascQuery, bool interp) { +// if ((lastKey > pWin->ekey && ascQuery) || (lastKey < pWin->ekey && (!ascQuery))) { +// closeAllResultRows(pResultRowInfo); +// pResultRowInfo->curPos = pResultRowInfo->size - 1; +// } else { +// int32_t step = ascQuery ? 1 : -1; +// doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, interp); +// } +//} static int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item, @@ -1041,43 +1031,84 @@ static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols, int32_t rows, return ts; } -static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order); +static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, bool createDummyCol); -static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, - int32_t order) { +static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) { for (int32_t i = 0; i < pOperator->numOfOutput; ++i) { pCtx[i].order = order; pCtx[i].size = pBlock->info.rows; - pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag; - - setBlockStatisInfo(&pCtx[i], pBlock, NULL /*&pOperator->pExpr[i].base.colInfo*/); + setBlockStatisInfo(&pCtx[i], &pOperator->pExpr[i], pBlock); } } -void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) { - if (pBlock->pDataBlock != NULL) { - doSetInputDataBlock(pOperator, pCtx, pBlock, order); - } else { +void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, bool createDummyCol) { + if (pBlock->pBlockAgg != NULL) { doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order); + } else { + doSetInputDataBlock(pOperator, pCtx, pBlock, order, createDummyCol); } } -static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) { +static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type, int32_t paramIndex, int32_t numOfRows) { + SColumnInfoData* pColInfo = NULL; + if (pInput->pData[paramIndex] == NULL) { + pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData)); + if (pColInfo == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + // Set the correct column info (data type and bytes) + pColInfo->info.type = type; + pColInfo->info.bytes = tDataTypes[type].bytes; + + pInput->pData[paramIndex] = pColInfo; + } + + ASSERT(!IS_VAR_DATA_TYPE(type)); + colInfoDataEnsureCapacity(pColInfo, numOfRows); + + if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_UBIGINT) { + int64_t v = pFuncParam->param.i; + for(int32_t i = 0; i < numOfRows; ++i) { + colDataAppendInt64(pColInfo, i, &v); + } + } else if (type == TSDB_DATA_TYPE_DOUBLE) { + double v = pFuncParam->param.d; + for(int32_t i = 0; i < numOfRows; ++i) { + colDataAppendDouble(pColInfo, i, &v); + } + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, bool createDummyCol) { + int32_t code = TSDB_CODE_SUCCESS; + for (int32_t i = 0; i < pOperator->numOfOutput; ++i) { pCtx[i].order = order; pCtx[i].size = pBlock->info.rows; pCtx[i].currentStage = MAIN_SCAN; + SInputColumnInfoData* pInput = &pCtx[i].input; + SExprInfo* pOneExpr = &pOperator->pExpr[i]; for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { SFunctParam *pFuncParam = &pOneExpr->base.pParam[j]; if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { int32_t slotId = pFuncParam->pCol->slotId; - pCtx[i].input.pData[j] = taosArrayGet(pBlock->pDataBlock, slotId); - pCtx[i].input.totalRows = pBlock->info.rows; - pCtx[i].input.numOfRows = pBlock->info.rows; - pCtx[i].input.startRowIndex = 0; - ASSERT(pCtx[i].input.pData[j] != NULL); + pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId); + pInput->totalRows = pBlock->info.rows; + pInput->numOfRows = pBlock->info.rows; + pInput->startRowIndex = 0; + ASSERT(pInput->pData[j] != NULL); + } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { + if (createDummyCol) { + code = doCreateConstantValColumnInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } } } @@ -1097,13 +1128,6 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, // } // } - // in case of the block distribution query, the inputBytes is not a constant value. - //pCtx[i].input.pData[0] = taosArrayGet(pBlock->pDataBlock, slotId); - //pCtx[i].input.totalRows = pBlock->info.rows; - //pCtx[i].input.numOfRows = pBlock->info.rows; - //pCtx[i].input.startRowIndex = 0; - - // uint32_t status = aAggs[pCtx[i].functionId].status; // if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) { // SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0); @@ -1127,6 +1151,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, // } // } } + + return code; } static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunctionCtx* pCtx) { @@ -1216,7 +1242,6 @@ void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type) { - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; SExprInfo* pExpr = pOperator->pExpr; SqlFunctionCtx* pCtx = pInfo->pCtx; @@ -1236,7 +1261,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, double v1 = 0, v2 = 0, v = 0; if (prevRowIndex == -1) { - GET_TYPED_DATA(v1, double, pColInfo->info.type, (char*)pRuntimeEnv->prevRow[index]); +// GET_TYPED_DATA(v1, double, pColInfo->info.type, (char*)pRuntimeEnv->prevRow[index]); } else { GET_TYPED_DATA(v1, double, pColInfo->info.type, (char*)pColInfo->pData + prevRowIndex * pColInfo->info.bytes); } @@ -1253,7 +1278,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) { if (prevRowIndex == -1) { - pCtx[k].start.ptr = (char*)pRuntimeEnv->prevRow[index]; +// pCtx[k].start.ptr = (char*)pRuntimeEnv->prevRow[index]; } else { pCtx[k].start.ptr = (char*)pColInfo->pData + prevRowIndex * pColInfo->info.bytes; } @@ -1401,7 +1426,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe int32_t step = 1; bool ascScan = true; - int32_t prevIndex = pResultRowInfo->curPos; +// int32_t prevIndex = pResultRowInfo->curPos; TSKEY* tsCols = NULL; if (pSDataBlock->pDataBlock != NULL) { @@ -1436,7 +1461,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); // prev time window not interpolation yet. - int32_t curIndex = pResultRowInfo->curPos; +// int32_t curIndex = pResultRowInfo->curPos; #if 0 if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) { @@ -1523,86 +1548,6 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe // updateResultRowInfoActiveIndex(pResultRowInfo, &pInfo->win, pRuntimeEnv->current->lastKey, true, false); } -static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, - int32_t tableGroupId) { - STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*)pOperatorInfo->info; - - STaskRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv; - int32_t numOfOutput = pOperatorInfo->numOfOutput; - - int32_t step = 1;//GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); - bool ascQuery = true; - - TSKEY* tsCols = NULL; - if (pSDataBlock->pDataBlock != NULL) { - SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, 0); - tsCols = (int64_t*)pColDataInfo->pData; - assert(tsCols[0] == pSDataBlock->info.window.skey && - tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); - } - - int32_t startPos = ascQuery ? 0 : (pSDataBlock->info.rows - 1); - TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascQuery); - - STimeWindow win = {0};//getCurrentActiveTimeWindow(pResultRowInfo, ts, pQueryAttr); - bool masterScan = IS_MAIN_SCAN(pRuntimeEnv); - - SResultRow* pResult = NULL; - int32_t forwardStep = 0; - int32_t ret = 0; - STimeWindow preWin = win; - - while (1) { - // null data, failed to allocate more memory buffer -// ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, -// tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset); - if (ret != TSDB_CODE_SUCCESS) { - longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - TSKEY ekey = 0;//reviseWindowEkey(pQueryAttr, &win); - // forwardStep = getNumOfRowsInTimeWindow(pRuntimeEnv, &pSDataBlock->info, tsCols, startPos, ekey, - // binarySearchForKey, true); - - // window start(end) key interpolation - // doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, - // forwardStep); doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, ascQuery ? &win : &preWin, startPos, - // forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput); - preWin = win; - - int32_t prevEndPos = (forwardStep - 1) * step + startPos; - // startPos = getNextQualifiedWindow(pQueryAttr, &win, &pSDataBlock->info, tsCols, binarySearchForKey, - // prevEndPos); - if (startPos < 0) { -// if ((ascQuery && win.skey <= pQueryAttr->window.ekey) || ((!ascQuery) && win.ekey >= pQueryAttr->window.ekey)) { -// int32_t code = -// setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, -// tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset); -// if (code != TSDB_CODE_SUCCESS || pResult == NULL) { -// longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); -// } -// -// startPos = pSDataBlock->info.rows - 1; - - // window start(end) key interpolation - // doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, - // forwardStep); doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, ascQuery ? &win : &preWin, startPos, - // forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput); -// } - - break; - } - setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); - } - -// if (pQueryAttr->timeWindowInterpo) { -// int32_t rowIndex = ascQuery ? (pSDataBlock->info.rows - 1) : 0; - // saveDataBlockLastRow(pRuntimeEnv, &pSDataBlock->info, pSDataBlock->pDataBlock, rowIndex); -// } - - // updateResultRowInfoActiveIndex(pResultRowInfo, pQueryAttr, pRuntimeEnv->current->lastKey); -} - static void doKeepTuple(SWindowRowsSup* pRowSup, int64_t ts) { pRowSup->win.ekey = ts; pRowSup->prevTs = ts; @@ -1746,27 +1691,91 @@ static bool functionNeedToExecute(SqlFunctionCtx* pCtx) { return true; } -void setBlockStatisInfo(SqlFunctionCtx* pCtx, SSDataBlock* pSDataBlock, SColumn* pColumn) { - SColumnDataAgg* pAgg = NULL; +static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type, int32_t paramIndex, int32_t numOfRows) { + if (pInput->pData[paramIndex] == NULL) { + pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData)); + if (pInput->pData[paramIndex] == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - if (pSDataBlock->pBlockAgg != NULL && TSDB_COL_IS_NORMAL_COL(pColumn->flag)) { - pAgg = &pSDataBlock->pBlockAgg[pCtx->columnIndex]; - - pCtx->agg = *pAgg; - pCtx->isAggSet = true; - assert(pCtx->agg.numOfNull <= pSDataBlock->info.rows); - } else { - pCtx->isAggSet = false; + // Set the correct column info (data type and bytes) + pInput->pData[paramIndex]->info.type = type; + pInput->pData[paramIndex]->info.bytes = tDataTypes[type].bytes; } - pCtx->hasNull = hasNull(pColumn, pAgg); + SColumnDataAgg* da = NULL; + if (pInput->pColumnDataAgg[paramIndex] == NULL) { + da = taosMemoryCalloc(1, sizeof(SColumnDataAgg)); + pInput->pColumnDataAgg[paramIndex] = da; + if (da == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } else { + da = pInput->pColumnDataAgg[paramIndex]; + } + + ASSERT(!IS_VAR_DATA_TYPE(type)); + + if (type == TSDB_DATA_TYPE_BIGINT) { + int64_t v = pFuncParam->param.i; + *da = (SColumnDataAgg) {.numOfNull = 0, .min = v, .max = v, .maxIndex = 0, .minIndex = 0, .sum = v * numOfRows}; + } else if (type == TSDB_DATA_TYPE_DOUBLE) { + double v = pFuncParam->param.d; + *da = (SColumnDataAgg) {.numOfNull = 0, .maxIndex = 0, .minIndex = 0}; + + *(double*) &da->min = v; + *(double*) &da->max = v; + *(double*) &da->sum = v * numOfRows; + } else if (type == TSDB_DATA_TYPE_BOOL) { // todo validate this data type + bool v = pFuncParam->param.i; + + *da = (SColumnDataAgg) {.numOfNull = 0, .maxIndex = 0, .minIndex = 0}; + *(bool*) &da->min = 0; + *(bool*) &da->max = v; + *(bool*) &da->sum = v * numOfRows; + } else if (type == TSDB_DATA_TYPE_TIMESTAMP) { + // do nothing + } else { + ASSERT(0); + } + + return TSDB_CODE_SUCCESS; +} + +void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pBlock) { + int32_t numOfRows = pBlock->info.rows; + + SInputColumnInfoData* pInput = &pCtx->input; + pInput->numOfRows = numOfRows; + pInput->totalRows = numOfRows; + + if (pBlock->pBlockAgg != NULL) { + pInput->colDataAggIsSet = true; + + for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) { + SFunctParam* pFuncParam = &pExprInfo->base.pParam[j]; + + if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { + int32_t slotId = pFuncParam->pCol->slotId; + pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId]; + + // Here we set the column info data since the data type for each column data is required, but + // the data in the corresponding SColumnInfoData will not be used. + pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId); + } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { + doCreateConstantValColumnAggInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows); + } + } + } else { + pInput->colDataAggIsSet = false; + } // set the statistics data for primary time stamp column - if (pCtx->functionId == FUNCTION_SPREAD && pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - pCtx->isAggSet = true; - pCtx->agg.min = pSDataBlock->info.window.skey; - pCtx->agg.max = pSDataBlock->info.window.ekey; - } + // if (pCtx->functionId == FUNCTION_SPREAD && pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + // pCtx->isAggSet = true; + // pCtx->agg.min = pBlock->info.window.skey; + // pCtx->agg.max = pBlock->info.window.ekey; + // } } // set the output buffer for the selectivity + tag query @@ -2231,33 +2240,6 @@ static bool overlapWithTimeWindow(STaskAttr* pQueryAttr, SDataBlockInfo* pBlockI return false; } -static int32_t doTSJoinFilter(STaskRuntimeEnv* pRuntimeEnv, TSKEY key, bool ascQuery) { - STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf); - -#if defined(_DEBUG_VIEW) - printf("elem in comp ts file:%" PRId64 ", key:%" PRId64 ", tag:%" PRIu64 - ", query order:%d, ts order:%d, traverse:%d, index:%d\n", - elem.ts, key, elem.tag.i, pQueryAttr->order.order, pRuntimeEnv->pTsBuf->tsOrder, - pRuntimeEnv->pTsBuf->cur.order, pRuntimeEnv->pTsBuf->cur.tsIndex); -#endif - - if (ascQuery) { - if (key < elem.ts) { - return TS_JOIN_TS_NOT_EQUALS; - } else if (key > elem.ts) { - longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_INCONSISTAN); - } - } else { - if (key > elem.ts) { - return TS_JOIN_TS_NOT_EQUALS; - } else if (key < elem.ts) { - longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_INCONSISTAN); - } - } - - return TS_JOIN_TS_EQUAL; -} - void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p) { int32_t len = 0; int32_t start = 0; @@ -2307,54 +2289,6 @@ void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p) { } } -void filterColRowsInDataBlock(STaskRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock, bool ascQuery) { - int32_t numOfRows = pBlock->info.rows; - - int8_t* p = NULL; - bool all = true; - - if (pRuntimeEnv->pTsBuf != NULL) { - SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, 0); - p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - - TSKEY* k = (TSKEY*)pColInfoData->pData; - for (int32_t i = 0; i < numOfRows; ++i) { - int32_t offset = ascQuery ? i : (numOfRows - i - 1); - int32_t ret = doTSJoinFilter(pRuntimeEnv, k[offset], ascQuery); - if (ret == TS_JOIN_TAG_NOT_EQUALS) { - break; - } else if (ret == TS_JOIN_TS_NOT_EQUALS) { - all = false; - continue; - } else { - assert(ret == TS_JOIN_TS_EQUAL); - p[offset] = true; - } - - if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { - break; - } - } - - // save the cursor status - // pRuntimeEnv->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); - } else { - // all = filterExecute(pRuntimeEnv->pQueryAttr->pFilters, numOfRows, &p, pBlock->pBlockAgg, - // pRuntimeEnv->pQueryAttr->numOfCols); - } - - if (!all) { - if (p) { - doCompactSDataBlock(pBlock, numOfRows, p); - } else { - pBlock->info.rows = 0; - pBlock->pBlockAgg = NULL; // clean the block statistics info - } - } - - taosMemoryFreeClear(p); -} - static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t numOfTags, int16_t colId); static void doSetTagValueInParam(void* pTable, int32_t tagColId, SVariant* tag, int16_t type, int16_t bytes); @@ -2447,7 +2381,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) { //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); - pCost->discardBlocks += 1; + pCost->skipBlocks += 1; } else if ((*status) == BLK_DATA_SMA_LOAD) { // this function never returns error? pCost->loadBlockStatis += 1; @@ -2487,7 +2421,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc // load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockAgg[i].min), // (char*)&(pBlock->pBlockAgg[i].max)); if (!load) { // current block has been discard due to filter applied - pCost->discardBlocks += 1; + pCost->skipBlocks += 1; //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, // pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); (*status) = BLK_DATA_FILTEROUT; @@ -2499,7 +2433,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc // current block has been discard due to filter applied // if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockAgg, pTableScanInfo->pCtx, pBlockInfo->rows)) { -// pCost->discardBlocks += 1; +// pCost->skipBlocks += 1; // qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); // (*status) = BLK_DATA_FILTEROUT; @@ -2725,12 +2659,12 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo* pTableQueryInfo) // pTableQueryInfo->cur.vgroupIndex = -1; // set the index to be the end slot of result rows array - SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo; - if (pResultRowInfo->size > 0) { - pResultRowInfo->curPos = pResultRowInfo->size - 1; - } else { - pResultRowInfo->curPos = -1; - } +// SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo; +// if (pResultRowInfo->size > 0) { +// pResultRowInfo->curPos = pResultRowInfo->size - 1; +// } else { +// pResultRowInfo->curPos = -1; +// } } void initResultRow(SResultRow* pResultRow) { @@ -2889,7 +2823,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo; - if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) { + if (!isRowEntryInitialized(pResInfo)) { continue; } @@ -2943,18 +2877,6 @@ void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbased } } -static bool hasMainOutput(STaskAttr* pQueryAttr) { - for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { - int32_t functionId = getExprFunctionId(&pQueryAttr->pExpr1[i]); - - if (functionId != FUNCTION_TS && functionId != FUNCTION_TAG && functionId != FUNCTION_TAGPRJ) { - return true; - } - } - - return false; -} - STableQueryInfo* createTableQueryInfo(void* buf, bool groupbyColumn, STimeWindow win) { STableQueryInfo* pTableQueryInfo = buf; pTableQueryInfo->lastKey = win.skey; @@ -2962,10 +2884,10 @@ STableQueryInfo* createTableQueryInfo(void* buf, bool groupbyColumn, STimeWindow // set more initial size of interval/groupby query // if (/*QUERY_IS_INTERVAL_QUERY(pQueryAttr) || */groupbyColumn) { int32_t initialSize = 128; - int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize); - if (code != TSDB_CODE_SUCCESS) { - return NULL; - } +// int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize); +// if (code != TSDB_CODE_SUCCESS) { +// return NULL; +// } // } else { // in other aggregate query, do not initialize the windowResInfo // } @@ -2978,7 +2900,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo) { } // taosVariantDestroy(&pTableQueryInfo->tag); - cleanupResultRowInfo(&pTableQueryInfo->resInfo); +// cleanupResultRowInfo(&pTableQueryInfo->resInfo); } void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) { @@ -2994,8 +2916,12 @@ void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, continue; } - if (!pResInfo->initialized && pCtx[i].functionId != -1) { - pCtx[i].fpSet.init(&pCtx[i], pResInfo); + if (!pResInfo->initialized) { + if (pCtx[i].functionId != -1) { + pCtx[i].fpSet.init(&pCtx[i], pResInfo); + } else { + pResInfo->initialized = true; + } } } } @@ -3053,18 +2979,17 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { blockDataUpdateTsWindow(pBlock); } -void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, SExecTaskInfo* pTaskInfo) { +void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo) { // for simple group by query without interval, all the tables belong to one group result. int64_t uid = 0; - int64_t tid = 0; SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx; int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset; SResultRow* pResultRow = - doSetResultOutBufByKey_rv(pAggInfo->pResultBuf, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), - true, uid, pTaskInfo, false, &pAggInfo->aggSup); + doSetResultOutBufByKey_rv(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId, sizeof(groupId), + true, groupId, pTaskInfo, false, &pAggInfo->aggSup); assert(pResultRow != NULL); /* @@ -3072,7 +2997,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i * all group belong to one result set, and each group result has different group id so set the id to be one */ if (pResultRow->pageId == -1) { - int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize); + int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, groupId, pAggInfo->binfo.pRes->info.rowSize); if (ret != TSDB_CODE_SUCCESS) { return; } @@ -3081,18 +3006,15 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset); } -void setExecutionContext(int32_t numOfOutput, int32_t tableGroupId, TSKEY nextKey, SExecTaskInfo* pTaskInfo, - STableQueryInfo* pTableQueryInfo, SAggOperatorInfo* pAggInfo) { - // lastKey needs to be updated - pTableQueryInfo->lastKey = nextKey; - if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == tableGroupId) { +void setExecutionContext(int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo, SAggOperatorInfo* pAggInfo) { + if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == groupId) { return; } - doSetTableGroupOutputBuf(pAggInfo, numOfOutput, tableGroupId, pTaskInfo); + doSetTableGroupOutputBuf(pAggInfo, numOfOutput, groupId, pTaskInfo); // record the current active group id - pAggInfo->groupId = tableGroupId; + pAggInfo->groupId = groupId; } void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable) { @@ -3122,48 +3044,6 @@ void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprI // } } -int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, STableQueryInfo* pTableQueryInfo) { - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - - assert(pRuntimeEnv->pTsBuf != NULL); -#if 0 - // both the master and supplement scan needs to set the correct ts comp start position - if (pTableQueryInfo->cur.vgroupIndex == -1) { - taosVariantAssign(&pTableQueryInfo->tag, pTag); - - STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTsBuf, pQueryAttr->vgId, &pTableQueryInfo->tag); - - // failed to find data with the specified tag value and vnodeId - if (!tsBufIsValidElem(&elem)) { - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { - //qError("QInfo:0x%"PRIx64" failed to find tag:%s in ts_comp", GET_TASKID(pRuntimeEnv), pTag->pz); - } else { - //qError("QInfo:0x%"PRIx64" failed to find tag:%" PRId64 " in ts_comp", GET_TASKID(pRuntimeEnv), pTag->i); - } - - return -1; - } - - // Keep the cursor info of current table - pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { - //qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_TASKID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); - } else { - //qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_TASKID(pRuntimeEnv), pTag->i, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); - } - - } else { - tsBufSetCursor(pRuntimeEnv->pTsBuf, &pTableQueryInfo->cur); - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { - //qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_TASKID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); - } else { - //qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_TASKID(pRuntimeEnv), pTag->i, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); - } - } -#endif - return 0; -} - /* * There are two cases to handle: * @@ -3173,17 +3053,14 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S * merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there * is a previous result generated or not. */ -void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) { - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; - SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo; +void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) { +// SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo; +// if (pResultRowInfo->curPos != -1) { +// return; +// } - if (pResultRowInfo->curPos != -1) { - return; - } - - // pTableQueryInfo->win.skey = key; - STimeWindow win = {.skey = key, .ekey = pQueryAttr->window.ekey}; +// pTableQueryInfo->win.skey = key; +// STimeWindow win = {.skey = key, .ekey = pQRange->ekey}; /** * In handling the both ascending and descending order super table query, we need to find the first qualified @@ -3191,10 +3068,10 @@ void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) { * In ascending query, the key is the first qualified timestamp. However, in the descending order query, additional * operations involve. */ - STimeWindow w = TSWINDOW_INITIALIZER; - - TSKEY sk = TMIN(win.skey, win.ekey); - TSKEY ek = TMAX(win.skey, win.ekey); +// STimeWindow w = TSWINDOW_INITIALIZER; +// +// TSKEY sk = TMIN(win.skey, win.ekey); +// TSKEY ek = TMAX(win.skey, win.ekey); // getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w); // if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) { @@ -3337,19 +3214,15 @@ int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock return pOutput->info.rows; } -void publishOperatorProfEvent(SOperatorInfo* operatorInfo, EQueryProfEventType eventType) { +void publishOperatorProfEvent(SOperatorInfo* pOperator, EQueryProfEventType eventType) { SQueryProfEvent event = {0}; event.eventType = eventType; event.eventTime = taosGetTimestampUs(); - event.operatorType = operatorInfo->operatorType; - - if (operatorInfo->pRuntimeEnv) { - // SQInfo* pQInfo = operatorInfo->pRuntimeEnv->qinfo; - // if (pQInfo->summary.queryProfEvents) { - // taosArrayPush(pQInfo->summary.queryProfEvents, &event); - // } - } + event.operatorType = pOperator->operatorType; +// if (pQInfo->summary.queryProfEvents) { +// taosArrayPush(pQInfo->summary.queryProfEvents, &event); +// } } void publishQueryAbortEvent(SExecTaskInfo* pTaskInfo, int32_t code) { @@ -3795,19 +3668,6 @@ static STableIdInfo createTableIdInfo(STableQueryInfo* pTableQueryInfo) { // } // } -static void doCloseAllTimeWindow(STaskRuntimeEnv* pRuntimeEnv) { - size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pRuntimeEnv); - for (int32_t i = 0; i < numOfGroup; ++i) { - SArray* group = GET_TABLEGROUP(pRuntimeEnv, i); - - size_t num = taosArrayGetSize(group); - for (int32_t j = 0; j < num; ++j) { - STableQueryInfo* item = taosArrayGetP(group, j); - closeAllResultRows(&item->resInfo); - } - } -} - int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) { SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param; if (code == TSDB_CODE_SUCCESS) { @@ -4614,7 +4474,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) { break; } - setInputDataBlock(pOperator, pInfo->binfo.pCtx, pDataBlock, TSDB_ORDER_ASC); + setInputDataBlock(pOperator, pInfo->binfo.pCtx, pDataBlock, TSDB_ORDER_ASC, true); // updateOutputBuf(&pInfo->binfo, &pAggInfo->bufCapacity, pBlock->info.rows * pAggInfo->resultRowFactor, // pOperator->pRuntimeEnv, true); doMergeImpl(pOperator, pOperator->numOfOutput, pDataBlock); @@ -4859,7 +4719,9 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { return TSDB_CODE_SUCCESS; } + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SAggOperatorInfo* pAggInfo = pOperator->info; + SOptrBasicInfo* pInfo = &pAggInfo->binfo; int32_t order = TSDB_ORDER_ASC; @@ -4878,8 +4740,14 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { // setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfOutput); // } + // there is an scalar expression that needs to be calculated before apply the group aggregation. + if (pAggInfo->pScalarExprInfo != NULL) { + projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx, pAggInfo->numOfScalarExpr, NULL); + } + // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); + setExecutionContext(pOperator->numOfOutput, pBlock->info.groupId, pTaskInfo, pAggInfo); + setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order, true); doAggregateImpl(pOperator, 0, pInfo->pCtx); #if 0 // test for encode/decode result info @@ -4898,8 +4766,11 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { #endif } - finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput); + closeAllResultRows(&pAggInfo->binfo.resultRowInfo); + finalizeMultiTupleQueryResult(pAggInfo->binfo.pCtx, pOperator->numOfOutput, pAggInfo->aggSup.pResultBuf, + &pAggInfo->binfo.resultRowInfo, pAggInfo->binfo.rowCellInfoOffset); + initGroupResInfo(&pAggInfo->groupResInfo, &pAggInfo->binfo.resultRowInfo); OPTR_SET_OPENED(pOperator); return TSDB_CODE_SUCCESS; } @@ -4918,9 +4789,13 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator, bool* newgroup) return NULL; } - getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, pInfo->pRes); - doSetOperatorCompleted(pOperator); + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + toSDatablock(pInfo->pRes, pOperator->resultInfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->aggSup.pResultBuf, pInfo->rowCellInfoOffset); + if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { + doSetOperatorCompleted(pOperator); + } + doSetOperatorCompleted(pOperator); return (blockDataGetNumOfRows(pInfo->pRes) != 0) ? pInfo->pRes : NULL; } @@ -4936,7 +4811,7 @@ void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi int32_t offset = sizeof(int32_t); // prepare memory - SResultRowPosition* pos = &pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.curPos]; + SResultRowPosition* pos = &pInfo->resultRowInfo.cur; void* pPage = getBufPage(pSup->pResultBuf, pos->pageId); SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); setBufPageDirty(pPage, true); @@ -5023,8 +4898,9 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi initResultRow(resultRow); prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env); - pInfo->resultRowInfo.curPos = pInfo->resultRowInfo.size; +// pInfo->resultRowInfo.cur = pInfo->resultRowInfo.size; pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; + pInfo->resultRowInfo.cur = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; } if (offset != length) { @@ -5033,74 +4909,6 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi return true; } -static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgroup) { - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - SAggOperatorInfo* pAggInfo = pOperator->info; - SOptrBasicInfo* pInfo = &pAggInfo->binfo; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - - if (pOperator->status == OP_RES_TO_RETURN) { - toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset); - if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; - } - - return pInfo->pRes; - } - - // table scan order - int32_t order = TSDB_ORDER_ASC; - SOperatorInfo* downstream = pOperator->pDownstream[0]; - - while (1) { - publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); - SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); - publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); - - if (pBlock == NULL) { - break; - } - - // setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput); - // if (downstream->operatorType == OP_TableScan) { - // STableScanInfo* pScanInfo = downstream->info; - // order = getTableScanOrder(pScanInfo); - // } - - // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); - - TSKEY key = 0; - if (order == TSDB_ORDER_ASC) { - key = pBlock->info.window.ekey; - TSKEY_MAX_ADD(key, 1); - } else { - key = pBlock->info.window.skey; - TSKEY_MIN_SUB(key, -1); - } - - setExecutionContext(pOperator->numOfOutput, pAggInfo->current->groupIndex, key, pTaskInfo, pAggInfo->current, - pAggInfo); - doAggregateImpl(pOperator, 0, pInfo->pCtx); - } - - pOperator->status = OP_RES_TO_RETURN; - closeAllResultRows(&pInfo->resultRowInfo); - updateNumOfRowsInResultRows(pInfo->pCtx, pOperator->numOfOutput, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset); - - initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo); - toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset); - - if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { - doSetOperatorCompleted(pOperator); - } - - return pInfo->pRes; -} - static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) { SProjectOperatorInfo* pProjectInfo = pOperator->info; SOptrBasicInfo* pInfo = &pProjectInfo->binfo; @@ -5165,7 +4973,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) // } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC); + setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC, false); blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows); projectApplyFunctions(pOperator->pExpr, pInfo->pRes, pBlock, pInfo->pCtx, pOperator->numOfOutput, pProjectInfo->pPseudoColInfo); @@ -5232,6 +5040,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { return TSDB_CODE_SUCCESS; } + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableIntervalOperatorInfo* pInfo = pOperator->info; int32_t order = TSDB_ORDER_ASC; @@ -5250,7 +5059,10 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { // setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput); // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); + setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, true); + STableQueryInfo* pTableQueryInfo = pInfo->pCurrent; + + setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); #if 0 // test for encode/decode result info @@ -5288,21 +5100,22 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { return pOperator->getStreamResFn(pOperator, newgroup); + } else { + pTaskInfo->code = pOperator->_openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + return NULL; + } + + blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); + toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, + pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); + + if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { + doSetOperatorCompleted(pOperator); + } + + return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } - - pTaskInfo->code = pOperator->_openFn(pOperator); - if (pTaskInfo->code != TSDB_CODE_SUCCESS) { - return NULL; - } - - blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); - toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); - - if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { - doSetOperatorCompleted(pOperator); - } - - return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { @@ -5341,7 +5154,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup // setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput); // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); + setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, true); pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); } @@ -5386,8 +5199,8 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { // setTagValue(pOperator, pRuntimeEnv->current->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput); // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pSliceInfo->binfo.pCtx, pBlock, order); - hashAllIntervalAgg(pOperator, &pSliceInfo->binfo.resultRowInfo, pBlock, 0); + setInputDataBlock(pOperator, pSliceInfo->binfo.pCtx, pBlock, order, true); +// hashAllIntervalAgg(pOperator, &pSliceInfo->binfo.resultRowInfo, pBlock, 0); } // restore the value @@ -5411,68 +5224,16 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup return NULL; } - STableIntervalOperatorInfo* pIntervalInfo = pOperator->info; - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + STableIntervalOperatorInfo* pInfo = pOperator->info; if (pOperator->status == OP_RES_TO_RETURN) { int64_t st = taosGetTimestampUs(); - - // copyToSDataBlock(NULL, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset); - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) { + if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } - return pIntervalInfo->binfo.pRes; - } - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - SOperatorInfo* downstream = pOperator->pDownstream[0]; - - while (1) { - publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); - SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); - publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); - - if (pBlock == NULL) { - break; - } - - // the pDataBlock are always the same one, no need to call this again - STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; - - // setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput); - setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC); - setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey); - - hashIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex); - } - - pOperator->status = OP_RES_TO_RETURN; - doCloseAllTimeWindow(pRuntimeEnv); - setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - - // copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset); - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; - } - - return pIntervalInfo->binfo.pRes; -} - -static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) { - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - STableIntervalOperatorInfo* pIntervalInfo = pOperator->info; - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; - - if (pOperator->status == OP_RES_TO_RETURN) { - // copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset); - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; - } - - return pIntervalInfo->binfo.pRes; + return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } SOperatorInfo* downstream = pOperator->pDownstream[0]; @@ -5487,27 +5248,30 @@ static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgr } // the pDataBlock are always the same one, no need to call this again - STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; - // setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput); -// setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order); - setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey); + setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC, true); + STableQueryInfo* pTableQueryInfo = pInfo->pCurrent; - hashAllIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex); + setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window); +// hashIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pBlock->info.groupId); } - pOperator->status = OP_RES_TO_RETURN; -// pQueryAttr->order.order = order; // TODO : restore the order - doCloseAllTimeWindow(pRuntimeEnv); - setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + closeAllResultRows(&pInfo->binfo.resultRowInfo); + finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, + &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); - int64_t st = taosGetTimestampUs(); - // copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset); - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo); + OPTR_SET_OPENED(pOperator); + + blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); + toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, + pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); + + if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { + doSetOperatorCompleted(pOperator); } - return pIntervalInfo->binfo.pRes; + return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorInfo* pInfo, SSDataBlock* pBlock) { @@ -5613,7 +5377,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator, bool* newgroup) { break; } - setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order); + setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, true); doStateWindowAggImpl(pOperator, pInfo, pBlock); } @@ -5661,7 +5425,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator, bool* newgroup) } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order); + setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order, true); doSessionWindowAggImpl(pOperator, pInfo, pBlock); } @@ -5872,9 +5636,9 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf STableKeyInfo* pk = taosArrayGet(pa, j); STableQueryInfo* pTQueryInfo = &pTableQueryInfo[index++]; - pTQueryInfo->uid = pk->uid; +// pTQueryInfo->uid = pk->uid; pTQueryInfo->lastKey = pk->lastKey; - pTQueryInfo->groupIndex = i; +// pTQueryInfo->groupIndex = i; } } @@ -5884,15 +5648,14 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf } SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, - const STableGroupInfo* pTableGroupInfo) { + SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo, + int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); int32_t numOfRows = 1; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, keyBufSize, pTaskInfo->id.str); @@ -5901,7 +5664,18 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* goto _error; } - setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo); + pOperator->resultInfo.capacity = 4096; + pOperator->resultInfo.threshold = 4096 * 0.75; + + int32_t numOfGroup = 10; // todo replaced with true value + pInfo->groupId = INT32_MIN; + initResultRowInfo(&pInfo->binfo.resultRowInfo, numOfGroup); + + pInfo->pScalarExprInfo = pScalarExprInfo; + pInfo->numOfScalarExpr = numOfScalarExpr; + if (pInfo->pScalarExprInfo != NULL) { + pInfo->pScalarCtx = createSqlFunctionCtx(pScalarExprInfo, numOfCols, &pInfo->rowCellInfoOffset); + } pOperator->name = "TableAggregate"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG; @@ -5910,11 +5684,11 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->info = pInfo; pOperator->pExpr = pExprInfo; pOperator->numOfOutput = numOfCols; - pOperator->pTaskInfo = pTaskInfo; pOperator->_openFn = doOpenAggregateOptr; pOperator->getNextFn = getAggregateResult; pOperator->closeFn = destroyAggOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; pOperator->decodeResultRow = aggDecodeResultRow; @@ -6005,46 +5779,6 @@ void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) { tsem_destroy(&pExInfo->ready); } -SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, - const STableGroupInfo* pTableGroupInfo) { - SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); - - int32_t numOfRows = 1; - size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - int32_t code = - initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str); - pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); - if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { - goto _error; - } - - size_t tableGroup = taosArrayGetSize(pTableGroupInfo->pGroupList); - initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)tableGroup); - - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - pOperator->name = "MultiTableAggregate"; - // pOperator->operatorType = OP_MultiTableAggregate; - pOperator->blockingOptr = true; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->pExpr = pExprInfo; - pOperator->numOfOutput = numOfCols; - pOperator->pTaskInfo = pTaskInfo; - - pOperator->getNextFn = doMultiTableAggregate; - pOperator->closeFn = destroyAggOperatorInfo; - code = appendDownstream(pOperator, &downstream, 1); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - return pOperator; - -_error: - return NULL; -} - static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) { SArray* pList = taosArrayInit(4, sizeof(int32_t)); for(int32_t i = 0; i < numOfCols; ++i) { @@ -6276,52 +6010,6 @@ _error: return NULL; } -SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, - SExprInfo* pExpr, int32_t numOfOutput) { - STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); - - initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); - - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - pOperator->name = "MultiTableTimeIntervalOperator"; - // pOperator->operatorType = OP_MultiTableTimeInterval; - pOperator->blockingOptr = true; - pOperator->status = OP_NOT_OPENED; - pOperator->pExpr = pExpr; - pOperator->numOfOutput = numOfOutput; - pOperator->info = pInfo; - - pOperator->getNextFn = doSTableIntervalAgg; - pOperator->closeFn = destroyBasicOperatorInfo; - - int32_t code = appendDownstream(pOperator, &downstream, 1); - return pOperator; -} - -SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, - SExprInfo* pExpr, int32_t numOfOutput) { - STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); - - initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); - - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - pOperator->name = "AllMultiTableTimeIntervalOperator"; - // pOperator->operatorType = OP_AllMultiTableTimeInterval; - pOperator->blockingOptr = true; - - pOperator->status = OP_NOT_OPENED; - pOperator->pExpr = pExpr; - pOperator->numOfOutput = numOfOutput; - pOperator->info = pInfo; - - pOperator->getNextFn = doAllSTableIntervalAgg; - pOperator->closeFn = destroyBasicOperatorInfo; - - int32_t code = appendDownstream(pOperator, &downstream, 1); - - return pOperator; -} - static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, int64_t* fillVal, STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) { struct SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, (int64_t*)fillVal); @@ -6628,8 +6316,9 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->pExpr->_function.num = 1; pExp->pExpr->_function.functionId = -1; + int32_t type = nodeType(pTargetNode->pExpr); // it is a project query, or group by column - if (nodeType(pTargetNode->pExpr) == QUERY_NODE_COLUMN) { + if (type == QUERY_NODE_COLUMN) { pExp->pExpr->nodeType = QUERY_NODE_COLUMN; SColumnNode* pColNode = (SColumnNode*)pTargetNode->pExpr; @@ -6640,7 +6329,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pColNode->colName); pExp->base.pParam[0].pCol = createColumn(pColNode->dataBlockId, pColNode->slotId, pType); pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; - } else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_VALUE) { + } else if (type == QUERY_NODE_VALUE) { pExp->pExpr->nodeType = QUERY_NODE_VALUE; SValueNode* pValNode = (SValueNode*)pTargetNode->pExpr; @@ -6651,7 +6340,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pValNode->node.aliasName); pExp->base.pParam[0].type = FUNC_PARAM_TYPE_VALUE; valueNodeToVariant(pValNode, &pExp->base.pParam[0].param); - } else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_FUNCTION) { + } else if (type == QUERY_NODE_FUNCTION) { pExp->pExpr->nodeType = QUERY_NODE_FUNCTION; SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr; @@ -6662,14 +6351,13 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->pExpr->_function.pFunctNode = pFuncNode; strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName, tListLen(pExp->pExpr->_function.functionName)); - // TODO: value parameter needs to be handled int32_t numOfParam = LIST_LENGTH(pFuncNode->pParameterList); pExp->base.pParam = taosMemoryCalloc(numOfParam, sizeof(SFunctParam)); pExp->base.numOfParams = numOfParam; for (int32_t j = 0; j < numOfParam; ++j) { - SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j); + SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j); if (p1->type == QUERY_NODE_COLUMN) { SColumnNode* pcn = (SColumnNode*) p1; @@ -6678,9 +6366,10 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* } else if (p1->type == QUERY_NODE_VALUE) { SValueNode* pvn = (SValueNode*)p1; pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE; + valueNodeToVariant(pvn, &pExp->base.pParam[j].param); } } - } else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_OPERATOR) { + } else if (type == QUERY_NODE_OPERATOR) { pExp->pExpr->nodeType = QUERY_NODE_OPERATOR; SOperatorNode* pNode = (SOperatorNode*)pTargetNode->pExpr; @@ -6689,11 +6378,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* SDataType* pType = &pNode->node.resType; pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pNode->node.aliasName); - pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr; - -// pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; -// pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); } else { ASSERT(0); } @@ -6733,8 +6418,9 @@ static SArray* extractPartitionColInfo(SNodeList* pNodeList); SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) { + int32_t type = nodeType(pPhyNode); + if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { - int32_t type = nodeType(pPhyNode); if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) { SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode; @@ -6748,8 +6434,16 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); - return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, pScanPhyNode->count, - pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo); + SInterval interval = { + .interval = pTableScanNode->interval, + .sliding = pTableScanNode->sliding, + .intervalUnit = pTableScanNode->intervalUnit, + .slidingUnit = pTableScanNode->slidingUnit, + .offset = pTableScanNode->offset, + }; + + return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, + pScanPhyNode->count, pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, &interval, pTableScanNode->ratio, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc); @@ -6784,7 +6478,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } int32_t num = 0; - int32_t type = nodeType(pPhyNode); size_t size = LIST_LENGTH(pPhyNode->pChildren); SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES); @@ -6807,17 +6500,17 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); - SExprInfo* pScalarExprInfo = NULL; int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = NULL; + if (pAggNode->pExprs != NULL) { + pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); + } + if (pAggNode->pGroupKeys != NULL) { SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys); - if (pAggNode->pExprs != NULL) { - pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); - } - pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); } else { - pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); + pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo, pTableGroupInfo); } } else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; @@ -6831,7 +6524,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .intervalUnit = pIntervalPhyNode->intervalUnit, .slidingUnit = pIntervalPhyNode->slidingUnit, .offset = pIntervalPhyNode->offset, - .precision = pIntervalPhyNode->precision + .precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision }; int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId; @@ -6870,16 +6563,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); } else { ASSERT(0); - } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { - size_t size = taosArrayGetSize(pPhyNode->pChildren); - assert(size == 1); - - for (int32_t i = 0; i < size; ++i) { - SPhysiNode* pChildNode = taosArrayGetP(pPhyNode->pChildren, i); - SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); - return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo); - } - }*/ + } taosMemoryFree(ops); return pOptr; @@ -7480,7 +7164,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf pOperator->name = "JoinOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN; - pOperator->blockingOptr = true; + pOperator->blockingOptr = false; pOperator->status = OP_NOT_OPENED; pOperator->pExpr = pExprInfo; pOperator->numOfOutput = numOfCols; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index cd79d719da..8739371dd9 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -284,9 +284,9 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); + setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, true); - // there is an scalar expression that needs to be calculated before apply the group aggregation. + // there is an scalar expression that needs to be calculated right before apply the group aggregation. if (pInfo->pScalarExprInfo != NULL) { projectApplyFunctions(pInfo->pScalarExprInfo, pBlock, pBlock, pInfo->pScalarFuncCtx, pInfo->numOfScalarExpr, NULL); } @@ -343,7 +343,6 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pInfo->numOfScalarExpr = numOfScalarExpr; pInfo->pScalarFuncCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); - int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/executor/src/indexoperator.c b/source/libs/executor/src/indexoperator.c index b5b9cdb740..34b04c04de 100644 --- a/source/libs/executor/src/indexoperator.c +++ b/source/libs/executor/src/indexoperator.c @@ -22,38 +22,275 @@ typedef struct SIFCtx { SHashObj *pRes; /* element is SScalarParam */ } SIFCtx; +#define SIF_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define SIF_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define SIF_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ + } while (0) + typedef struct SIFParam { SArray * result; SHashObj *pFilter; } SIFParam; + +typedef int32_t (*sif_func_t)(SNode *left, SNode *rigth, SIFParam *output); // construct tag filter operator later -static void destroyTagFilterOperatorInfo(void *param) { - STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; -} +static void destroyTagFilterOperatorInfo(void *param) { STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; } static void sifFreeParam(SIFParam *param) { if (param == NULL) return; taosArrayDestroy(param->result); } -int32_t sifInitOperParams(SIFParam *params, SOperatorNode *node, SIFCtx *ctx) { +static int32_t sifGetOperParamNum(EOperatorType ty) { + if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty || OP_TYPE_IS_FALSE == ty || + OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty || OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) { + return 1; + } + return 2; +} +static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) { + switch (nodeType(node)) { + case QUERY_NODE_VALUE: { + SValueNode *vn = (SValueNode *)node; + + break; + } + case QUERY_NODE_COLUMN: { + SColumnNode *cn = (SColumnNode *)node; + + break; + } + case QUERY_NODE_NODE_LIST: { + SNodeListNode *nl = (SNodeListNode *)node; + if (LIST_LENGTH(nl->pNodeList) <= 0) { + qError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList)); + SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) { + taosHashCleanup(param->pFilter); + qError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param)); + SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + break; + } + case QUERY_NODE_FUNCTION: + case QUERY_NODE_OPERATOR: + case QUERY_NODE_LOGIC_CONDITION: { + SIFParam *res = (SIFParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES); + if (NULL == res) { + qError("no result for node, type:%d, node:%p", nodeType(node), node); + SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + *param = *res; + break; + } + default: + break; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx *ctx) { int32_t code = 0; - return code; + int32_t nParam = sifGetOperParamNum(node->opType); + if (NULL == node->pLeft || (nParam == 2 && NULL == node->pRight)) { + qError("invalid operation node, left: %p, rigth: %p", node->pLeft, node->pRight); + SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); + if (NULL == paramList) { + SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx)); + if (nParam > 1) { + SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx)); + } + *params = paramList; + return TSDB_CODE_SUCCESS; +_return: + taosMemoryFree(paramList); + SIF_RET(code); +} +static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx *ctx) { + int32_t code = 0; + SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam)); + if (tParams == NULL) { + qError("failed to calloc, nodeList: %p", nodeList); + SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + SListCell *cell = nodeList->pHead; + for (int32_t i = 0; i < nodeList->length; i++) { + if (NULL == cell || NULL == cell->pNode) { + SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + SIF_ERR_JRET(sifInitParam(cell->pNode, &tParams[i], ctx)); + cell = cell->pNext; + } + *params = tParams; + return TSDB_CODE_SUCCESS; + +_return: + taosMemoryFree(tParams); + SIF_RET(code); } static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) { qError("index-filter not support buildin function"); + return TSDB_CODE_QRY_INVALID_INPUT; +} + +static int32_t sifLessThanFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later return TSDB_CODE_SUCCESS; } +static int32_t sifLessEqualFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifGreaterThanFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifGreaterEqualFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} + +static int32_t sifEqualFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifNotEqualFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifInFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifNotInFunc(SNode *left, SNode *right, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifLikeFunc(SNode *left, SNode *right, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifNotLikeFunc(SNode *left, SNode *right, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} + +static int32_t sifMatchFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifNotMatchFunc(SNode *left, SNode *rigth, SIFParam *output) { + // impl later + return TSDB_CODE_SUCCESS; +} +static int32_t sifDefaultFunc(SNode *left, SNode *rigth, SIFParam *output) { + // add more except + return TSDB_CODE_QRY_INVALID_INPUT; +} + +static sif_func_t sifGetOperFn(int32_t funcId) { + // impl later + switch (funcId) { + case OP_TYPE_GREATER_THAN: + return sifGreaterThanFunc; + case OP_TYPE_GREATER_EQUAL: + return sifGreaterEqualFunc; + case OP_TYPE_LOWER_THAN: + return sifLessThanFunc; + case OP_TYPE_LOWER_EQUAL: + return sifLessEqualFunc; + case OP_TYPE_EQUAL: + return sifEqualFunc; + case OP_TYPE_NOT_EQUAL: + return sifNotEqualFunc; + case OP_TYPE_IN: + return sifInFunc; + case OP_TYPE_NOT_IN: + return sifNotInFunc; + case OP_TYPE_LIKE: + return sifLikeFunc; + case OP_TYPE_NOT_LIKE: + return sifNotLikeFunc; + case OP_TYPE_MATCH: + return sifMatchFunc; + case OP_TYPE_NMATCH: + return sifNotMatchFunc; + default: + return sifDefaultFunc; + } + return sifDefaultFunc; +} static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { + int32_t code = 0; SIFParam *params = NULL; + SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx)); - return TSDB_CODE_SUCCESS; + int32_t nParam = sifGetOperParamNum(node->opType); + if (nParam <= 1) { + SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + sif_func_t operFn = sifGetOperFn(node->opType); + + return operFn(node->pLeft, node->pRight, output); +_return: + taosMemoryFree(params); + SIF_RET(code); } -static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) { return TSDB_CODE_SUCCESS; } +static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) { + if (NULL == node->pParameterList || node->pParameterList->length <= 0) { + qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0); + return TSDB_CODE_QRY_INVALID_INPUT; + } + + int32_t code; + SIFParam *params = NULL; + SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx)); + + for (int32_t m = 0; m < node->pParameterList->length; m++) { + // add impl later + if (node->condType == LOGIC_COND_TYPE_AND) { + taosArrayAddAll(output->result, params[m].result); + } else if (node->condType == LOGIC_COND_TYPE_OR) { + taosArrayAddAll(output->result, params[m].result); + } else if (node->condType == LOGIC_COND_TYPE_NOT) { + taosArrayAddAll(output->result, params[m].result); + } + } +_return: + taosMemoryFree(params); + SIF_RET(code); +} static EDealRes sifWalkFunction(SNode *pNode, void *context) { - // impl later SFunctionNode *node = (SFunctionNode *)pNode; SIFParam output = {0}; @@ -104,8 +341,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) { } EDealRes sifCalcWalker(SNode *node, void *context) { - if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || - QUERY_NODE_COLUMN == nodeType(node)) { + if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || QUERY_NODE_COLUMN == nodeType(node)) { return DEAL_RES_CONTINUE; } SIFCtx *ctx = (SIFCtx *)context; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 3de9d9020e..b3050006b7 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -13,11 +13,13 @@ * along with this program. If not, see . */ -#include "tglobal.h" +#include #include "filter.h" #include "function.h" +#include "functionMgt.h" #include "os.h" #include "querynodes.h" +#include "tglobal.h" #include "tname.h" #include "vnode.h" @@ -64,6 +66,111 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) { #endif } +// relocated the column data according to the slotId +static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) { + int32_t numOfCols = pBlock->info.numOfCols; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* p = taosArrayGet(pCols, i); + SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i); + if (!pmInfo->output) { + continue; + } + + ASSERT(pmInfo->colId == p->info.colId); + taosArraySet(pBlock->pDataBlock, pmInfo->targetSlotId, p); + } +} + +static void getNextTimeWindow(SInterval* pInterval, STimeWindow* tw, int32_t order) { + int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order); + if (pInterval->intervalUnit != 'n' && pInterval->intervalUnit != 'y') { + tw->skey += pInterval->sliding * factor; + tw->ekey = tw->skey + pInterval->interval - 1; + return; + } + + int64_t key = tw->skey, interval = pInterval->interval; + //convert key to second + key = convertTimePrecision(key, pInterval->precision, TSDB_TIME_PRECISION_MILLI) / 1000; + + if (pInterval->intervalUnit == 'y') { + interval *= 12; + } + + struct tm tm; + time_t t = (time_t)key; + taosLocalTime(&t, &tm); + + int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); + tm.tm_year = mon / 12; + tm.tm_mon = mon % 12; + tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision); + + mon = (int)(mon + interval); + tm.tm_year = mon / 12; + tm.tm_mon = mon % 12; + tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision); + + tw->ekey -= 1; +} + +static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockInfo) { + STimeWindow w = {0}; + + // 0 by default, which means it is not a interval operator of the upstream operator. + if (pInterval->interval == 0) { + return false; + } + + // todo handle the time range case + TSKEY sk = INT64_MIN; + TSKEY ek = INT64_MAX; +// TSKEY sk = MIN(pQueryAttr->window.skey, pQueryAttr->window.ekey); +// TSKEY ek = MAX(pQueryAttr->window.skey, pQueryAttr->window.ekey); + + if (true) { + getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey, sk, ek, &w); + assert(w.ekey >= pBlockInfo->window.skey); + + if (w.ekey < pBlockInfo->window.ekey) { + return true; + } + + while(1) { // todo handle the desc order scan case + getNextTimeWindow(pInterval, &w, TSDB_ORDER_ASC); + if (w.skey > pBlockInfo->window.ekey) { + break; + } + + assert(w.ekey > pBlockInfo->window.ekey); + if (w.skey <= pBlockInfo->window.ekey && w.skey > pBlockInfo->window.skey) { + return true; + } + } + } else { +// getAlignQueryTimeWindow(pQueryAttr, pBlockInfo->window.ekey, sk, ek, &w); +// assert(w.skey <= pBlockInfo->window.ekey); +// +// if (w.skey > pBlockInfo->window.skey) { +// return true; +// } +// +// while(1) { +// getNextTimeWindow(pQueryAttr, &w); +// if (w.ekey < pBlockInfo->window.skey) { +// break; +// } +// +// assert(w.skey < pBlockInfo->window.skey); +// if (w.ekey < pBlockInfo->window.ekey && w.ekey >= pBlockInfo->window.skey) { +// return true; +// } +// } + } + + return false; +} + int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableScanInfo* pInfo = pOperator->info; @@ -71,31 +178,81 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, STaskCostInfo* pCost = &pTaskInfo->cost; pCost->totalBlocks += 1; - pCost->loadBlocks += 1; - pCost->totalRows += pBlock->info.rows; - pCost->totalCheckedRows += pBlock->info.rows; *status = pInfo->dataBlockLoadFlag; + if (pTableScanInfo->pFilterNode != NULL || overlapWithTimeWindow(&pTableScanInfo->interval, &pBlock->info)) { + (*status) = FUNC_DATA_REQUIRED_DATA_LOAD; + } + + SDataBlockInfo* pBlockInfo = &pBlock->info; + taosMemoryFreeClear(pBlock->pBlockAgg); + + if (*status == FUNC_DATA_REQUIRED_FILTEROUT) { + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, + pBlockInfo->window.ekey, pBlockInfo->rows); + pCost->filterOutBlocks += 1; + return TSDB_CODE_SUCCESS; + } else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { + qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, + pBlockInfo->window.ekey, pBlockInfo->rows); + pCost->skipBlocks += 1; + return TSDB_CODE_SUCCESS; + } else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) { + pCost->loadBlockStatis += 1; + + SColumnDataAgg* pColAgg = NULL; + tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->dataReader, &pColAgg); + + if (pColAgg != NULL) { + int32_t numOfCols = pBlock->info.numOfCols; + + // todo create this buffer during creating operator + pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg)); + for (int32_t i = 0; i < numOfCols; ++i) { + SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i); + if (!pColMatchInfo->output) { + continue; + } + pBlock->pBlockAgg[pColMatchInfo->targetSlotId] = pColAgg[i]; + } + + return TSDB_CODE_SUCCESS; + } else { // failed to load the block sma data, data block statistics does not exist, load data block instead + *status = FUNC_DATA_REQUIRED_DATA_LOAD; + } + } + + ASSERT (*status == FUNC_DATA_REQUIRED_DATA_LOAD); + + // todo filter data block according to the block sma data firstly +#if 0 + if (!doFilterByBlockStatistics(pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) { + pCost->filterOutBlocks += 1; + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, + pBlockInfo->window.ekey, pBlockInfo->rows); + (*status) = FUNC_DATA_REQUIRED_FILTEROUT; + return TSDB_CODE_SUCCESS; + } +#endif + + pCost->totalCheckedRows += pBlock->info.rows; + pCost->loadBlocks += 1; SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); if (pCols == NULL) { return terrno; } - int32_t numOfCols = pBlock->info.numOfCols; - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* p = taosArrayGet(pCols, i); - SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i); - if (!pColMatchInfo->output) { - continue; - } - - ASSERT(pColMatchInfo->colId == p->info.colId); - taosArraySet(pBlock->pDataBlock, pColMatchInfo->targetSlotId, p); - } + relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols); doFilter(pTableScanInfo->pFilterNode, pBlock); + if (pBlock->info.rows == 0) { + pCost->filterOutBlocks += 1; + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, + pBlockInfo->window.ekey, pBlockInfo->rows); + } + return TSDB_CODE_SUCCESS; } @@ -114,7 +271,6 @@ static void setupEnvForReverseScan(STableScanInfo* pTableScanInfo, SqlFunctionCt static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { STableScanInfo* pTableScanInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSDataBlock* pBlock = pTableScanInfo->pResBlock; STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo; @@ -141,15 +297,15 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { // } // this function never returns error? - uint32_t status = BLK_DATA_DATA_LOAD; + uint32_t status = 0; int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { longjmp(pOperator->pTaskInfo->env, code); } - // current block is ignored according to filter result by block statistics data, continue load the next block - if (status == BLK_DATA_FILTEROUT || pBlock->info.rows == 0) { + // current block is filter out according to filter condition, continue load the next block + if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) { continue; } @@ -192,9 +348,9 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); pTableScanInfo->scanFlag = REPEAT_SCAN; - if (pResultRowInfo->size > 0) { - pResultRowInfo->curPos = 0; - } +// if (pResultRowInfo->size > 0) { +// pResultRowInfo->curPos = 0; +// } qDebug("%s start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey); @@ -211,7 +367,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey); if (pResultRowInfo->size > 0) { - pResultRowInfo->curPos = pResultRowInfo->size - 1; +// pResultRowInfo->curPos = pResultRowInfo->size - 1; } p = doTableScanImpl(pOperator, newgroup); @@ -222,7 +378,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, - SNode* pCondition, SExecTaskInfo* pTaskInfo) { + SNode* pCondition, SInterval* pInterval, double sampleRatio, SExecTaskInfo* pTaskInfo) { assert(repeatTime > 0); STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); @@ -235,6 +391,8 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, return NULL; } + pInfo->interval = *pInterval; + pInfo->sampleRatio = sampleRatio; pInfo->dataBlockLoadFlag= dataLoadFlag; pInfo->pResBlock = pResBlock; pInfo->pFilterNode = pCondition; diff --git a/source/libs/executor/test/CMakeLists.txt b/source/libs/executor/test/CMakeLists.txt index b07ff89d90..b1f379585b 100644 --- a/source/libs/executor/test/CMakeLists.txt +++ b/source/libs/executor/test/CMakeLists.txt @@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(executorTest ${SOURCE_LIST}) TARGET_LINK_LIBRARIES( executorTest - PRIVATE os util common transport gtest taos qcom executor function planner scalar nodes + PRIVATE os util common transport gtest taos_static qcom executor function planner scalar nodes ) TARGET_INCLUDE_DIRECTORIES( diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 09c468b610..11c89f1568 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -30,6 +30,7 @@ EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWind bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t countFunction(SqlFunctionCtx *pCtx); +EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t sumFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index bba5145812..78dec26be5 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -138,6 +138,12 @@ static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in return TSDB_CODE_SUCCESS; } +static int32_t translateTimezone(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // pseudo column do not need to check parameters + pFunc->node.resType = (SDataType){.bytes = TD_TIMEZONE_LEN, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (2 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -231,33 +237,45 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return TSDB_CODE_SUCCESS; } -static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, int32_t primaryParaNo) { +static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, bool hasSep) { int32_t paraNum = LIST_LENGTH(pFunc->pParameterList); if (paraNum < minParaNum || paraNum > maxParaNum) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - uint8_t resultType = TSDB_DATA_TYPE_NCHAR; + uint8_t resultType = TSDB_DATA_TYPE_BINARY; int32_t resultBytes = 0; int32_t sepBytes = 0; - for (int32_t i = 0; i < LIST_LENGTH(pFunc->pParameterList); ++i) { + + /* For concat/concat_ws function, if params have NCHAR type, promote the final result to NCHAR */ + for (int32_t i = 0; i < paraNum; ++i) { SNode* pPara = nodesListGetNode(pFunc->pParameterList, i); uint8_t paraType = ((SExprNode*)pPara)->resType.type; - int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes; if (!IS_VAR_DATA_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - if (i < primaryParaNo) { - sepBytes = paraBytes; - continue; + if (TSDB_DATA_TYPE_NCHAR == paraType) { + resultType = paraType; } - if (TSDB_DATA_TYPE_BINARY == paraType) { - resultType = TSDB_DATA_TYPE_BINARY; - } - resultBytes += paraBytes; } - if (sepBytes > 0) { - resultBytes += sepBytes * (paraNum - 2); + + for (int32_t i = 0; i < paraNum; ++i) { + SNode* pPara = nodesListGetNode(pFunc->pParameterList, i); + uint8_t paraType = ((SExprNode*)pPara)->resType.type; + int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes; + int32_t factor = 1; + if (TSDB_DATA_TYPE_NCHAR == resultType && TSDB_DATA_TYPE_VARCHAR == paraType) { + factor *= TSDB_NCHAR_SIZE; + } + resultBytes += paraBytes * factor; + + if (i == 0) { + sepBytes = paraBytes * factor; + } + } + + if (hasSep) { + resultBytes += sepBytes * (paraNum - 3); } pFunc->node.resType = (SDataType) { .bytes = resultBytes, .type = resultType }; @@ -265,11 +283,11 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t } static int32_t translateConcat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { - return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, 0); + return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, false); } static int32_t translateConcatWs(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { - return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, 1); + return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, true); } static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { @@ -312,7 +330,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_VAR_DATA_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -340,7 +358,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; - if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || !IS_INTEGER_TYPE(para2Type)) { + if ((!IS_VAR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || !IS_INTEGER_TYPE(para2Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -354,12 +372,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; - if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || - (!IS_VAR_DATA_TYPE(para2Type) && TSDB_DATA_TYPE_TIMESTAMP != para2Type)) { - return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + for (int32_t i = 0; i < 2; ++i) { + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type; + if (!IS_VAR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } } + if (3 == paraNum) { if (!IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); @@ -399,8 +418,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "sum", .type = FUNCTION_TYPE_SUM, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateSum, + .dataRequiredFunc = statisDataRequired, .getEnvFunc = getSumFuncEnv, .initFunc = functionSetup, .processFunc = sumFunction, @@ -409,8 +429,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "min", .type = FUNCTION_TYPE_MIN, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateInOutNum, + .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minFunctionSetup, .processFunc = minFunction, @@ -419,8 +440,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "max", .type = FUNCTION_TYPE_MAX, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateInOutNum, + .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -816,6 +838,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = todayFunction, .finalizeFunc = NULL }, + { + .name = "timezone", + .type = FUNCTION_TYPE_TIMEZONE, + .classification = FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateTimezone, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = timezoneFunction, + .finalizeFunc = NULL + }, { .name = "_rowts", .type = FUNCTION_TYPE_ROWTS, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 71e8bcc842..0d7e984ae7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -183,6 +183,10 @@ bool getSumFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } +EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow){ + return FUNC_DATA_REQUIRED_STATIS_LOAD; +} + bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; @@ -357,20 +361,15 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) { index = pInput->pColumnDataAgg[0]->maxIndex; } - TSKEY key = TSKEY_INITIAL_VAL; - if (pCtx->ptsList != NULL) { - // the index is the original position, not the relative position - key = pCtx->ptsList[index]; - } + // the index is the original position, not the relative position + TSKEY key = (pCtx->ptsList != NULL)? pCtx->ptsList[index]:TSKEY_INITIAL_VAL; if (IS_SIGNED_NUMERIC_TYPE(type)) { + int64_t prev = 0; + GET_TYPED_DATA(prev, int64_t, type, buf); + int64_t val = GET_INT64_VAL(tval); - -#if defined(_DEBUG_VIEW) - qDebug("max value updated according to pre-cal:%d", *data); -#endif - - if ((*(int64_t*)buf < val) ^ isMinFunc) { + if ((prev < val) ^ isMinFunc) { *(int64_t*) buf = val; for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) { SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i]; @@ -383,14 +382,28 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) { } } } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + uint64_t prev = 0; + GET_TYPED_DATA(prev, uint64_t, type, buf); + uint64_t val = GET_UINT64_VAL(tval); - UPDATE_DATA(pCtx, *(uint64_t*)buf, val, numOfElems, isMinFunc, key); + if ((prev < val) ^ isMinFunc) { + *(uint64_t*) buf = val; + for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) { + SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i]; + if (__ctx->functionId == FUNCTION_TS_DUMMY) { // TODO refactor + __ctx->tag.i = key; + __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; + } + + __ctx->fpSet.process(__ctx); + } + } } else if (type == TSDB_DATA_TYPE_DOUBLE) { double val = GET_DOUBLE_VAL(tval); - UPDATE_DATA(pCtx, *(double*)buf, val, numOfElems, isMinFunc, key); + UPDATE_DATA(pCtx, *(double*) buf, val, numOfElems, isMinFunc, key); } else if (type == TSDB_DATA_TYPE_FLOAT) { double val = GET_DOUBLE_VAL(tval); - UPDATE_DATA(pCtx, *(float*)buf, (float)val, numOfElems, isMinFunc, key); + UPDATE_DATA(pCtx, *(float*) buf, val, numOfElems, isMinFunc, key); } return numOfElems; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 2c8a938a5a..7eb472dad8 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -748,6 +748,11 @@ static const char* jkTableScanPhysiPlanEndKey = "EndKey"; static const char* jkTableScanPhysiPlanRatio = "Ratio"; static const char* jkTableScanPhysiPlanDataRequired = "DataRequired"; static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs"; +static const char* jkTableScanPhysiPlanInterval = "Interval"; +static const char* jkTableScanPhysiPlanOffset = "Offset"; +static const char* jkTableScanPhysiPlanSliding = "Sliding"; +static const char* jkTableScanPhysiPlanIntervalUnit = "intervalUnit"; +static const char* jkTableScanPhysiPlanSlidingUnit = "slidingUnit"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -771,6 +776,21 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkTableScanPhysiPlanDynamicScanFuncs, pNode->pDynamicScanFuncs); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanInterval, pNode->interval); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanOffset, pNode->offset); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSliding, pNode->sliding); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit); + } return code; } @@ -797,6 +817,21 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit); + } return code; } @@ -1159,7 +1194,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding"; static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit"; static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit"; static const char* jkIntervalPhysiPlanFill = "Fill"; -static const char* jkIntervalPhysiPlanPrecision = "Precision"; static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj; @@ -1183,9 +1217,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision); - } return code; } @@ -1212,9 +1243,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision); - } return code; } diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 99a08923bb..e74ecfd0f4 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -14,6 +14,7 @@ */ #include "querynodes.h" +#include "plannodes.h" typedef enum ETraversalOrder { TRAVERSAL_PREORDER = 1, @@ -21,9 +22,14 @@ typedef enum ETraversalOrder { TRAVERSAL_POSTORDER, } ETraversalOrder; -static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext); +typedef EDealRes (*FNodeDispatcher)(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext); -static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { +static EDealRes walkExpr(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext); +static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext); +static EDealRes walkPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext); +static EDealRes walkPhysiPlans(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext); + +static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext, FNodeDispatcher dispatcher) { if (NULL == pNode) { return DEAL_RES_CONTINUE; } @@ -37,94 +43,7 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker } } - switch (nodeType(pNode)) { - case QUERY_NODE_COLUMN: - case QUERY_NODE_VALUE: - case QUERY_NODE_LIMIT: - // these node types with no subnodes - break; - case QUERY_NODE_OPERATOR: { - SOperatorNode* pOpNode = (SOperatorNode*)pNode; - res = walkNode(pOpNode->pLeft, order, walker, pContext); - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pOpNode->pRight, order, walker, pContext); - } - break; - } - case QUERY_NODE_LOGIC_CONDITION: - res = walkList(((SLogicConditionNode*)pNode)->pParameterList, order, walker, pContext); - break; - case QUERY_NODE_FUNCTION: - res = walkList(((SFunctionNode*)pNode)->pParameterList, order, walker, pContext); - break; - case QUERY_NODE_REAL_TABLE: - case QUERY_NODE_TEMP_TABLE: - break; // todo - case QUERY_NODE_JOIN_TABLE: { - SJoinTableNode* pJoinTableNode = (SJoinTableNode*)pNode; - res = walkNode(pJoinTableNode->pLeft, order, walker, pContext); - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pJoinTableNode->pRight, order, walker, pContext); - } - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pJoinTableNode->pOnCond, order, walker, pContext); - } - break; - } - case QUERY_NODE_GROUPING_SET: - res = walkList(((SGroupingSetNode*)pNode)->pParameterList, order, walker, pContext); - break; - case QUERY_NODE_ORDER_BY_EXPR: - res = walkNode(((SOrderByExprNode*)pNode)->pExpr, order, walker, pContext); - break; - case QUERY_NODE_STATE_WINDOW: { - SStateWindowNode* pState = (SStateWindowNode*)pNode; - res = walkNode(pState->pExpr, order, walker, pContext); - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pState->pCol, order, walker, pContext); - } - break; - } - case QUERY_NODE_SESSION_WINDOW: { - SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; - res = walkNode(pSession->pCol, order, walker, pContext); - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pSession->pGap, order, walker, pContext); - } - break; - } - case QUERY_NODE_INTERVAL_WINDOW: { - SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; - res = walkNode(pInterval->pInterval, order, walker, pContext); - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pInterval->pOffset, order, walker, pContext); - } - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pInterval->pSliding, order, walker, pContext); - } - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pInterval->pFill, order, walker, pContext); - } - if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = walkNode(pInterval->pCol, order, walker, pContext); - } - break; - } - case QUERY_NODE_NODE_LIST: - res = walkList(((SNodeListNode*)pNode)->pNodeList, order, walker, pContext); - break; - case QUERY_NODE_FILL: - res = walkNode(((SFillNode*)pNode)->pValues, order, walker, pContext); - break; - case QUERY_NODE_RAW_EXPR: - res = walkNode(((SRawExprNode*)pNode)->pNode, order, walker, pContext); - break; - case QUERY_NODE_TARGET: - res = walkNode(((STargetNode*)pNode)->pExpr, order, walker, pContext); - break; - default: - break; - } + res = dispatcher(pNode, order, walker, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res && TRAVERSAL_POSTORDER == order) { res = walker(pNode, pContext); @@ -133,10 +52,109 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker return res; } -static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext) { +static EDealRes dispatchExpr(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = DEAL_RES_CONTINUE; + + switch (nodeType(pNode)) { + case QUERY_NODE_COLUMN: + case QUERY_NODE_VALUE: + case QUERY_NODE_LIMIT: + // these node types with no subnodes + break; + case QUERY_NODE_OPERATOR: { + SOperatorNode* pOpNode = (SOperatorNode*)pNode; + res = walkExpr(pOpNode->pLeft, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pOpNode->pRight, order, walker, pContext); + } + break; + } + case QUERY_NODE_LOGIC_CONDITION: + res = walkExprs(((SLogicConditionNode*)pNode)->pParameterList, order, walker, pContext); + break; + case QUERY_NODE_FUNCTION: + res = walkExprs(((SFunctionNode*)pNode)->pParameterList, order, walker, pContext); + break; + case QUERY_NODE_REAL_TABLE: + case QUERY_NODE_TEMP_TABLE: + break; // todo + case QUERY_NODE_JOIN_TABLE: { + SJoinTableNode* pJoinTableNode = (SJoinTableNode*)pNode; + res = walkExpr(pJoinTableNode->pLeft, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pJoinTableNode->pRight, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pJoinTableNode->pOnCond, order, walker, pContext); + } + break; + } + case QUERY_NODE_GROUPING_SET: + res = walkExprs(((SGroupingSetNode*)pNode)->pParameterList, order, walker, pContext); + break; + case QUERY_NODE_ORDER_BY_EXPR: + res = walkExpr(((SOrderByExprNode*)pNode)->pExpr, order, walker, pContext); + break; + case QUERY_NODE_STATE_WINDOW: { + SStateWindowNode* pState = (SStateWindowNode*)pNode; + res = walkExpr(pState->pExpr, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pState->pCol, order, walker, pContext); + } + break; + } + case QUERY_NODE_SESSION_WINDOW: { + SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; + res = walkExpr((SNode*)pSession->pCol, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr((SNode*)pSession->pGap, order, walker, pContext); + } + break; + } + case QUERY_NODE_INTERVAL_WINDOW: { + SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; + res = walkExpr(pInterval->pInterval, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pInterval->pOffset, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pInterval->pSliding, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pInterval->pFill, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pInterval->pCol, order, walker, pContext); + } + break; + } + case QUERY_NODE_NODE_LIST: + res = walkExprs(((SNodeListNode*)pNode)->pNodeList, order, walker, pContext); + break; + case QUERY_NODE_FILL: + res = walkExpr(((SFillNode*)pNode)->pValues, order, walker, pContext); + break; + case QUERY_NODE_RAW_EXPR: + res = walkExpr(((SRawExprNode*)pNode)->pNode, order, walker, pContext); + break; + case QUERY_NODE_TARGET: + res = walkExpr(((STargetNode*)pNode)->pExpr, order, walker, pContext); + break; + default: + break; + } + + return res; +} + +static EDealRes walkExpr(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { + return walkNode(pNode, order, walker, pContext, dispatchExpr); +} + +static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext) { SNode* node; FOREACH(node, pNodeList) { - EDealRes res = walkNode(node, order, walker, pContext); + EDealRes res = walkExpr(node, order, walker, pContext); if (DEAL_RES_ERROR == res || DEAL_RES_END == res) { return res; } @@ -145,24 +163,24 @@ static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalke } void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext) { - (void)walkNode(pNode, TRAVERSAL_PREORDER, walker, pContext); + (void)walkExpr(pNode, TRAVERSAL_PREORDER, walker, pContext); } void nodesWalkExprs(SNodeList* pNodeList, FNodeWalker walker, void* pContext) { - (void)walkList(pNodeList, TRAVERSAL_PREORDER, walker, pContext); + (void)walkExprs(pNodeList, TRAVERSAL_PREORDER, walker, pContext); } void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext) { - (void)walkNode(pNode, TRAVERSAL_POSTORDER, walker, pContext); + (void)walkExpr(pNode, TRAVERSAL_POSTORDER, walker, pContext); } void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext) { - (void)walkList(pList, TRAVERSAL_POSTORDER, walker, pContext); + (void)walkExprs(pList, TRAVERSAL_POSTORDER, walker, pContext); } -static EDealRes rewriteList(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext); +static EDealRes rewriteExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext); -static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) { +static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) { if (NULL == pRawNode || NULL == *pRawNode) { return DEAL_RES_CONTINUE; } @@ -185,82 +203,82 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit break; case QUERY_NODE_OPERATOR: { SOperatorNode* pOpNode = (SOperatorNode*)pNode; - res = rewriteNode(&(pOpNode->pLeft), order, rewriter, pContext); + res = rewriteExpr(&(pOpNode->pLeft), order, rewriter, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pOpNode->pRight), order, rewriter, pContext); + res = rewriteExpr(&(pOpNode->pRight), order, rewriter, pContext); } break; } case QUERY_NODE_LOGIC_CONDITION: - res = rewriteList(((SLogicConditionNode*)pNode)->pParameterList, order, rewriter, pContext); + res = rewriteExprs(((SLogicConditionNode*)pNode)->pParameterList, order, rewriter, pContext); break; case QUERY_NODE_FUNCTION: - res = rewriteList(((SFunctionNode*)pNode)->pParameterList, order, rewriter, pContext); + res = rewriteExprs(((SFunctionNode*)pNode)->pParameterList, order, rewriter, pContext); break; case QUERY_NODE_REAL_TABLE: case QUERY_NODE_TEMP_TABLE: break; // todo case QUERY_NODE_JOIN_TABLE: { SJoinTableNode* pJoinTableNode = (SJoinTableNode*)pNode; - res = rewriteNode(&(pJoinTableNode->pLeft), order, rewriter, pContext); + res = rewriteExpr(&(pJoinTableNode->pLeft), order, rewriter, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pJoinTableNode->pRight), order, rewriter, pContext); + res = rewriteExpr(&(pJoinTableNode->pRight), order, rewriter, pContext); } if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pJoinTableNode->pOnCond), order, rewriter, pContext); + res = rewriteExpr(&(pJoinTableNode->pOnCond), order, rewriter, pContext); } break; } case QUERY_NODE_GROUPING_SET: - res = rewriteList(((SGroupingSetNode*)pNode)->pParameterList, order, rewriter, pContext); + res = rewriteExprs(((SGroupingSetNode*)pNode)->pParameterList, order, rewriter, pContext); break; case QUERY_NODE_ORDER_BY_EXPR: - res = rewriteNode(&(((SOrderByExprNode*)pNode)->pExpr), order, rewriter, pContext); + res = rewriteExpr(&(((SOrderByExprNode*)pNode)->pExpr), order, rewriter, pContext); break; case QUERY_NODE_STATE_WINDOW: { SStateWindowNode* pState = (SStateWindowNode*)pNode; - res = rewriteNode(&pState->pExpr, order, rewriter, pContext); + res = rewriteExpr(&pState->pExpr, order, rewriter, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&pState->pCol, order, rewriter, pContext); + res = rewriteExpr(&pState->pCol, order, rewriter, pContext); } break; } case QUERY_NODE_SESSION_WINDOW: { SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; - res = rewriteNode(&pSession->pCol, order, rewriter, pContext); + res = rewriteExpr((SNode**)&pSession->pCol, order, rewriter, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&pSession->pGap, order, rewriter, pContext); + res = rewriteExpr((SNode**)&pSession->pGap, order, rewriter, pContext); } break; } case QUERY_NODE_INTERVAL_WINDOW: { SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; - res = rewriteNode(&(pInterval->pInterval), order, rewriter, pContext); + res = rewriteExpr(&(pInterval->pInterval), order, rewriter, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pInterval->pOffset), order, rewriter, pContext); + res = rewriteExpr(&(pInterval->pOffset), order, rewriter, pContext); } if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pInterval->pSliding), order, rewriter, pContext); + res = rewriteExpr(&(pInterval->pSliding), order, rewriter, pContext); } if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pInterval->pFill), order, rewriter, pContext); + res = rewriteExpr(&(pInterval->pFill), order, rewriter, pContext); } if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { - res = rewriteNode(&(pInterval->pCol), order, rewriter, pContext); + res = rewriteExpr(&(pInterval->pCol), order, rewriter, pContext); } break; } case QUERY_NODE_NODE_LIST: - res = rewriteList(((SNodeListNode*)pNode)->pNodeList, order, rewriter, pContext); + res = rewriteExprs(((SNodeListNode*)pNode)->pNodeList, order, rewriter, pContext); break; case QUERY_NODE_FILL: - res = rewriteNode(&(((SFillNode*)pNode)->pValues), order, rewriter, pContext); + res = rewriteExpr(&(((SFillNode*)pNode)->pValues), order, rewriter, pContext); break; case QUERY_NODE_RAW_EXPR: - res = rewriteNode(&(((SRawExprNode*)pNode)->pNode), order, rewriter, pContext); + res = rewriteExpr(&(((SRawExprNode*)pNode)->pNode), order, rewriter, pContext); break; case QUERY_NODE_TARGET: - res = rewriteNode(&(((STargetNode*)pNode)->pExpr), order, rewriter, pContext); + res = rewriteExpr(&(((STargetNode*)pNode)->pExpr), order, rewriter, pContext); break; default: break; @@ -273,10 +291,10 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit return res; } -static EDealRes rewriteList(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) { +static EDealRes rewriteExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) { SNode** pNode; FOREACH_FOR_REWRITE(pNode, pNodeList) { - EDealRes res = rewriteNode(pNode, order, rewriter, pContext); + EDealRes res = rewriteExpr(pNode, order, rewriter, pContext); if (DEAL_RES_ERROR == res || DEAL_RES_END == res) { return res; } @@ -285,19 +303,19 @@ static EDealRes rewriteList(SNodeList* pNodeList, ETraversalOrder order, FNodeRe } void nodesRewriteExpr(SNode** pNode, FNodeRewriter rewriter, void* pContext) { - (void)rewriteNode(pNode, TRAVERSAL_PREORDER, rewriter, pContext); + (void)rewriteExpr(pNode, TRAVERSAL_PREORDER, rewriter, pContext); } void nodesRewriteExprs(SNodeList* pList, FNodeRewriter rewriter, void* pContext) { - (void)rewriteList(pList, TRAVERSAL_PREORDER, rewriter, pContext); + (void)rewriteExprs(pList, TRAVERSAL_PREORDER, rewriter, pContext); } void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext) { - (void)rewriteNode(pNode, TRAVERSAL_POSTORDER, rewriter, pContext); + (void)rewriteExpr(pNode, TRAVERSAL_POSTORDER, rewriter, pContext); } void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext) { - (void)rewriteList(pList, TRAVERSAL_POSTORDER, rewriter, pContext); + (void)rewriteExprs(pList, TRAVERSAL_POSTORDER, rewriter, pContext); } void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext) { @@ -357,3 +375,206 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit return; } + +static EDealRes walkPhysiNode(SPhysiNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = walkPhysiPlan((SNode*)pNode->pOutputDataBlockDesc, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan(pNode->pConditions, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pNode->pChildren, order, walker, pContext); + } + return res; +} + +static EDealRes walkScanPhysi(SScanPhysiNode* pScan, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = walkPhysiNode((SPhysiNode*)pScan, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pScan->pScanCols, order, walker, pContext); + } + return res; +} + +static EDealRes walkTableScanPhysi(STableScanPhysiNode* pScan, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = walkScanPhysi((SScanPhysiNode*)pScan, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pScan->pDynamicScanFuncs, order, walker, pContext); + } + return res; +} + +static EDealRes walkWindowPhysi(SWinodwPhysiNode* pWindow, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = walkPhysiNode((SPhysiNode*)pWindow, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pWindow->pExprs, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pWindow->pFuncs, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan(pWindow->pTspk, order, walker, pContext); + } + return res; +} + +static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { + EDealRes res = DEAL_RES_CONTINUE; + + switch (nodeType(pNode)) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: + res = walkScanPhysi((SScanPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: + res = walkTableScanPhysi((STableScanPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + res = walkTableScanPhysi((STableScanPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: + res = walkScanPhysi((SScanPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: + res = walkScanPhysi((SScanPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_PROJECT: { + SProjectPhysiNode* pProject = (SProjectPhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pProject->pProjections, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_JOIN: { + SJoinPhysiNode* pJoin = (SJoinPhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan(pJoin->pOnConditions, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pJoin->pTargets, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_AGG: { + SAggPhysiNode* pAgg = (SAggPhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pAgg->pExprs, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pAgg->pGroupKeys, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pAgg->pAggFuncs, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: { + SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pExchange->pSrcEndPoints, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SORT: { + SSortPhysiNode* pSort = (SSortPhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pSort->pExprs, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pSort->pSortKeys, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pSort->pTargets, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: { + SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)pNode; + res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan((SNode*)pInterval->pFill, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: + res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW: { + SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)pNode; + res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan(pState->pStateKey, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { + SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pPart->pExprs, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pPart->pPartitionKeys, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pPart->pTargets, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: + res = walkPhysiPlan((SNode*)(((SDataSinkNode*)pNode)->pInputDataBlockDesc), order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_PLAN_INSERT: + res = walkPhysiPlan((SNode*)(((SDataSinkNode*)pNode)->pInputDataBlockDesc), order, walker, pContext); + break; + case QUERY_NODE_PHYSICAL_SUBPLAN: { + SSubplan* pSubplan = (SSubplan*)pNode; + res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlans(pSubplan->pChildren, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan((SNode*)pSubplan->pNode, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkPhysiPlan((SNode*)pSubplan->pDataSink, order, walker, pContext); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN: { + SQueryPlan* pPlan = (SQueryPlan*)pNode; + if (NULL != pPlan->pSubplans) { + // only need to walk the top-level subplans, because they will recurse to all the subplans below + walkPhysiPlan(nodesListGetNode(pPlan->pSubplans, 0), order, walker, pContext); + } + break; + } + default: + res = dispatchExpr(pNode, order, walker, pContext); + break; + } + + return res; +} + +static EDealRes walkPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext) { + return walkNode(pNode, order, walker, pContext, dispatchPhysiPlan); +} + +static EDealRes walkPhysiPlans(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext) { + SNode* node; + FOREACH(node, pNodeList) { + EDealRes res = walkPhysiPlan(node, order, walker, pContext); + if (DEAL_RES_ERROR == res || DEAL_RES_END == res) { + return res; + } + } + return DEAL_RES_CONTINUE; +} + +void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext) { + (void)walkPhysiPlan(pNode, TRAVERSAL_PREORDER, walker, pContext); +} diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 758f9d5d6f..d4457a056e 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1226,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: - pVal->pz = pNode->datum.p + VARSTR_HEADER_SIZE; + pVal->pz = pNode->datum.p; break; case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index ebd07669c3..85f9b3399c 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -32,6 +32,7 @@ typedef struct SAstCreateContext { bool notSupport; bool valid; SNode* pRootNode; + int16_t placeholderNo; } SAstCreateContext; typedef enum EDatabaseOptionType { @@ -86,14 +87,14 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt); -SNode* createPlaceholderValueNode(SAstCreateContext* pCxt); +SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias); SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2); SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight); SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList); -SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName); +SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName); SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt); SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList); SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index bd7c5d16b1..33b525cf3a 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -465,8 +465,8 @@ literal(A) ::= NK_STRING(B). literal(A) ::= NK_BOOL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B)); } literal(A) ::= TIMESTAMP(B) NK_STRING(C). { A = createRawExprNodeExt(pCxt, &B, &C, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &C)); } literal(A) ::= duration_literal(B). { A = B; } -literal(A) ::= NULL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } -literal(A) ::= NK_QUESTION(B). { A = createRawExprNode(pCxt, &B, createPlaceholderValueNode(pCxt)); } +literal(A) ::= NULL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B)); } +literal(A) ::= NK_QUESTION(B). { A = createRawExprNode(pCxt, &B, createPlaceholderValueNode(pCxt, &B)); } duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); } @@ -603,12 +603,13 @@ pseudo_column(A) ::= WDURATION(B). function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); } -function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); } +function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNodeNoArg(pCxt, &B)); } %type noarg_func { SToken } %destructor noarg_func { } noarg_func(A) ::= NOW(B). { A = B; } noarg_func(A) ::= TODAY(B). { A = B; } +noarg_func(A) ::= TIMEZONE(B). { A = B; } %type star_func { SToken } %destructor star_func { } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index f2b8b73a87..0bc28beef9 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -44,6 +44,7 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) { pCxt->notSupport = false; pCxt->valid = true; pCxt->pRootNode = NULL; + pCxt->placeholderNo = 1; } static void trimEscape(SToken* pName) { @@ -258,13 +259,12 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) { SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); - if (NULL != pLiteral) { - val->literal = strndup(pLiteral->z, pLiteral->n); - if (TK_NK_ID != pLiteral->type && (IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) { - trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n); - } - CHECK_OUT_OF_MEM(val->literal); + val->literal = strndup(pLiteral->z, pLiteral->n); + if (TK_NK_ID != pLiteral->type && TK_TIMEZONE != pLiteral->type && + (IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) { + trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n); } + CHECK_OUT_OF_MEM(val->literal); val->node.resType.type = dataType; val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { @@ -305,10 +305,12 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { return (SNode*)val; } -SNode* createPlaceholderValueNode(SAstCreateContext* pCxt) { +SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) { SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); - // todo + val->literal = strndup(pLiteral->z, pLiteral->n); + CHECK_OUT_OF_MEM(val->literal); + val->placeholderNo = pCxt->placeholderNo++; return (SNode*)val; } @@ -367,7 +369,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod return (SNode*)func; } -SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) { +SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName) { SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); CHECK_OUT_OF_MEM(func); char buf[64] = {0}; @@ -386,11 +388,11 @@ SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncNam dataType = TSDB_DATA_TYPE_BIGINT; break; } - //case TK_TIMEZONE: { - // strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr)); - // dataType = TSDB_DATA_TYPE_BINARY; - // break; - //} + case TK_TIMEZONE: { + strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr)); + dataType = TSDB_DATA_TYPE_BINARY; + break; + } } SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf}; @@ -499,8 +501,8 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap) { SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW); CHECK_OUT_OF_MEM(session); - session->pCol = pCol; - session->pGap = pGap; + session->pCol = (SColumnNode*)pCol; + session->pGap = (SValueNode*)pGap; return (SNode*)session; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 76af6b7ac7..2eeff04ea2 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -50,7 +50,6 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { Parse(pParser, 0, t0, &cxt); goto abort_parse; } - case TK_NK_QUESTION: case TK_NK_ILLEGAL: { snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unrecognized token: \"%s\"", t0.z); cxt.valid = false; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index af2b831b93..2a191b7bf2 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -175,6 +175,7 @@ static SKeyword keywordTable[] = { {"TAGS", TK_TAGS}, {"TBNAME", TK_TBNAME}, {"TIMESTAMP", TK_TIMESTAMP}, + {"TIMEZONE", TK_TIMEZONE}, {"TINYINT", TK_TINYINT}, {"TODAY", TK_TODAY}, {"TOPIC", TK_TOPIC}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 324f9c17d2..a7e7e01948 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -19,6 +19,7 @@ #include "cmdnodes.h" #include "functionMgt.h" #include "parUtil.h" +#include "tglobal.h" #include "ttime.h" #define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : getBigintFromValueNode((SValueNode*)(pVal))) @@ -227,6 +228,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p strcpy(pCol->node.aliasName, pColSchema->name); } pCol->tableId = pTable->pMeta->uid; + pCol->tableType = pTable->pMeta->tableType; pCol->colId = pColSchema->colId; pCol->colType = isTag ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN; pCol->node.resType.type = pColSchema->type; @@ -364,23 +366,46 @@ static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) } static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { - // count(*)/first(*)/last(*) + // count(*)/first(*)/last(*) and so on if (0 == strcmp(pCol->colName, "*")) { return DEAL_RES_CONTINUE; } + + EDealRes res = DEAL_RES_CONTINUE; if ('\0' != pCol->tableAlias[0]) { - return translateColumnWithPrefix(pCxt, pCol); + res = translateColumnWithPrefix(pCxt, pCol); + } else { + bool found = false; + if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) { + found = translateColumnUseAlias(pCxt, pCol); + } + res = (found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol)); } - bool found = false; - if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) { - found = translateColumnUseAlias(pCxt, pCol); + + if (DEAL_RES_ERROR == res) { + return res; } - return found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol); + + if (SQL_CLAUSE_WINDOW == pCxt->currClause && QUERY_NODE_STATE_WINDOW == nodeType(pCxt->pCurrStmt->pWindow)) { + if (!IS_INTEGER_TYPE(pCol->node.resType.type)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE); + } + if (COLUMN_TYPE_TAG == pCol->colType) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_COL); + } + if (TSDB_SUPER_TABLE == pCol->tableType) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE); + } + } + return DEAL_RES_CONTINUE; } static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { uint8_t precision = (NULL != pCxt->pCurrStmt ? pCxt->pCurrStmt->precision : pVal->node.resType.precision); pVal->node.resType.precision = precision; + if (pVal->placeholderNo > 0) { + return DEAL_RES_CONTINUE; + } if (pVal->isDuration) { if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) != TSDB_CODE_SUCCESS) { @@ -466,8 +491,20 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { TSDB_DATA_TYPE_BLOB == rdt.type) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } - pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; - pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + if (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + + if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) || + (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) || + (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) || + (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) { + pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + } else { + pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + } } else if (nodesIsComparisonOp(pOp)) { if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { @@ -639,7 +676,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) if (!pSelect->isDistinct) { nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); } - if (cxt.existAggFunc && cxt.existCol) { + if ((cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP); } return TSDB_CODE_SUCCESS; @@ -775,7 +812,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { size_t nums = taosArrayGetSize(pTables); for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); - int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols); + int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -801,7 +838,8 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { return NULL; } pFunc->pParameterList = nodesMakeList(); - if (NULL == pFunc->pParameterList || TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) { + if (NULL == pFunc->pParameterList || + TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) { nodesDestroyNode(pFunc); return NULL; } @@ -810,7 +848,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { pFunc->funcId = pSrcFunc->funcId; pFunc->funcType = pSrcFunc->funcType; strcpy(pFunc->functionName, pSrcFunc->functionName); - char buf[TSDB_FUNC_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN]; + char buf[TSDB_FUNC_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN]; int32_t len = 0; if (QUERY_NODE_COLUMN == nodeType(pExpr)) { SColumnNode* pCol = (SColumnNode*)pExpr; @@ -838,7 +876,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) { STableNode* pTable = NULL; - int32_t code = findTable(pCxt, pCol->tableAlias, &pTable); + int32_t code = findTable(pCxt, pCol->tableAlias, &pTable); if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) { *pOutput = nodesMakeList(); if (NULL == *pOutput) { @@ -852,18 +890,20 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN } static bool isStar(SNode* pNode) { - return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && + (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } static bool isTableStar(SNode* pNode) { - return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && + (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrcParas, SNodeList** pOutput) { int32_t code = TSDB_CODE_SUCCESS; SNodeList* pExprs = NULL; - SNode* pPara = NULL; + SNode* pPara = NULL; FOREACH(pPara, pSrcParas) { if (isStar(pPara)) { code = createAllColumns(pCxt, &pExprs); @@ -895,7 +935,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S } int32_t code = TSDB_CODE_SUCCESS; - SNode* pExpr = NULL; + SNode* pExpr = NULL; FOREACH(pExpr, pExprs) { code = nodesListStrictAppend(pFuncs, createMultiResFunc(pSrcFunc, (SExprNode*)pExpr)); if (TSDB_CODE_SUCCESS != code) { @@ -914,7 +954,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNode* pSrcFunc, SNodeList** pOutput) { SNodeList* pExprs = NULL; - int32_t code = createMultiResFuncsParas(pCxt, pSrcFunc->pParameterList, &pExprs); + int32_t code = createMultiResFuncsParas(pCxt, pSrcFunc->pParameterList, &pExprs); if (TSDB_CODE_SUCCESS == code) { code = createMultiResFuncs(pSrcFunc, pExprs, pOutput); } @@ -936,8 +976,8 @@ static bool isCountStar(SNode* pNode) { static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) { SColumnNode* pCol = nodesListGetNode(pCount->pParameterList, 0); - STableNode* pTable = NULL; - int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); + STableNode* pTable = NULL; + int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) { setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, false, pCol); } @@ -1091,20 +1131,99 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) { return translateExprList(pCxt, pSelect->pGroupByList); } -static int32_t translateIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { - SValueNode* pIntervalVal = (SValueNode*)pInterval->pInterval; - SValueNode* pIntervalOffset = (SValueNode*)pInterval->pOffset; - SValueNode* pSliding = (SValueNode*)pInterval->pSliding; - if (pIntervalVal->datum.i <= 0) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL, pIntervalVal->literal); +static bool isValTimeUnit(char unit) { return ('n' == unit || 'y' == unit); } + +static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) { + int64_t days = convertTimeFromPrecisionToUnit(val, fromPrecision, 'd'); + switch (unit) { + case 'b': + case 'u': + case 'a': + case 's': + case 'm': + case 'h': + case 'd': + case 'w': + return days / 28; + case 'n': + return val; + case 'y': + return val * 12; + default: + break; } + return -1; +} + +static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { + uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision; + + SValueNode* pInter = (SValueNode*)pInterval->pInterval; + bool valInter = isValTimeUnit(pInter->unit); + if (pInter->datum.i <= 0 || + (!valInter && convertTimePrecision(pInter->datum.i, precision, TSDB_TIME_PRECISION_MICRO) < tsMinIntervalTime)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime); + } + + if (NULL != pInterval->pOffset) { + SValueNode* pOffset = (SValueNode*)pInterval->pOffset; + if (pOffset->datum.i <= 0) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE); + } + if (pInter->unit == 'n' && pOffset->unit == 'y') { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_UNIT); + } + bool fixed = !isValTimeUnit(pOffset->unit) && !valInter; + if ((fixed && pOffset->datum.i >= pInter->datum.i) || + (!fixed && getMonthsFromTimeVal(pOffset->datum.i, precision, pOffset->unit) >= + getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit))) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG); + } + } + + if (NULL != pInterval->pSliding) { + const static int32_t INTERVAL_SLIDING_FACTOR = 100; + + SValueNode* pSliding = (SValueNode*)pInterval->pSliding; + if (pInter->unit == 'n' || pInter->unit == 'y') { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_UNIT); + } + if ((pSliding->datum.i < convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, precision)) || + (pInter->datum.i / pSliding->datum.i > INTERVAL_SLIDING_FACTOR)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL); + } + if (pSliding->datum.i > pInter->datum.i) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG); + } + } + return TSDB_CODE_SUCCESS; } -static int32_t doTranslateWindow(STranslateContext* pCxt, SNode* pWindow) { +static int32_t checkStateWindow(STranslateContext* pCxt, SStateWindowNode* pState) { + // todo check for "function not support for state_window" + return TSDB_CODE_SUCCESS; +} + +static int32_t checkSessionWindow(STranslateContext* pCxt, SSessionWindowNode* pSession) { + if ('y' == pSession->pGap->unit || 'n' == pSession->pGap->unit || 0 == pSession->pGap->datum.i) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_GAP); + } + if (PRIMARYKEY_TIMESTAMP_COL_ID != pSession->pCol->colId) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_COL); + } + // todo check for "function not support for session" + return TSDB_CODE_SUCCESS; +} + +static int32_t checkWindow(STranslateContext* pCxt, SNode* pWindow) { switch (nodeType(pWindow)) { + case QUERY_NODE_STATE_WINDOW: + return checkStateWindow(pCxt, (SStateWindowNode*)pWindow); + case QUERY_NODE_SESSION_WINDOW: + return checkSessionWindow(pCxt, (SSessionWindowNode*)pWindow); case QUERY_NODE_INTERVAL_WINDOW: - return translateIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow); + return checkIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow); default: break; } @@ -1118,7 +1237,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SNode* pWindow) { pCxt->currClause = SQL_CLAUSE_WINDOW; int32_t code = translateExpr(pCxt, pWindow); if (TSDB_CODE_SUCCESS == code) { - code = doTranslateWindow(pCxt, pWindow); + code = checkWindow(pCxt, pWindow); } return code; } @@ -1174,14 +1293,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { static int64_t getUnitPerMinute(uint8_t precision) { switch (precision) { - case TSDB_TIME_PRECISION_MILLI: - return MILLISECOND_PER_MINUTE; - case TSDB_TIME_PRECISION_MICRO: - return MILLISECOND_PER_MINUTE * 1000L; - case TSDB_TIME_PRECISION_NANO: - return NANOSECOND_PER_MINUTE; - default: - break; + case TSDB_TIME_PRECISION_MILLI: + return MILLISECOND_PER_MINUTE; + case TSDB_TIME_PRECISION_MICRO: + return MILLISECOND_PER_MINUTE * 1000L; + case TSDB_TIME_PRECISION_NANO: + return NANOSECOND_PER_MINUTE; + default: + break; } return MILLISECOND_PER_MINUTE; } @@ -1250,7 +1369,8 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) { return pCxt->errCode; } - if (pVal->isDuration && (TIME_UNIT_MINUTE != pVal->unit && TIME_UNIT_HOUR != pVal->unit && TIME_UNIT_DAY != pVal->unit)) { + if (pVal->isDuration && + (TIME_UNIT_MINUTE != pVal->unit && TIME_UNIT_HOUR != pVal->unit && TIME_UNIT_DAY != pVal->unit)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_OPTION_UNIT, pName, pVal->unit); } int64_t val = getBigintFromValueNode(pVal); @@ -1345,9 +1465,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) { SValueNode* pKeep0 = (SValueNode*)nodesListGetNode(pKeep, 0); SValueNode* pKeep1 = (SValueNode*)nodesListGetNode(pKeep, 1); SValueNode* pKeep2 = (SValueNode*)nodesListGetNode(pKeep, 2); - if ((pKeep0->isDuration && (TIME_UNIT_MINUTE != pKeep0->unit && TIME_UNIT_HOUR != pKeep0->unit && TIME_UNIT_DAY != pKeep0->unit)) || - (pKeep1->isDuration && (TIME_UNIT_MINUTE != pKeep1->unit && TIME_UNIT_HOUR != pKeep1->unit && TIME_UNIT_DAY != pKeep1->unit)) || - (pKeep2->isDuration && (TIME_UNIT_MINUTE != pKeep2->unit && TIME_UNIT_HOUR != pKeep2->unit && TIME_UNIT_DAY != pKeep2->unit))) { + if ((pKeep0->isDuration && + (TIME_UNIT_MINUTE != pKeep0->unit && TIME_UNIT_HOUR != pKeep0->unit && TIME_UNIT_DAY != pKeep0->unit)) || + (pKeep1->isDuration && + (TIME_UNIT_MINUTE != pKeep1->unit && TIME_UNIT_HOUR != pKeep1->unit && TIME_UNIT_DAY != pKeep1->unit)) || + (pKeep2->isDuration && + (TIME_UNIT_MINUTE != pKeep2->unit && TIME_UNIT_HOUR != pKeep2->unit && TIME_UNIT_DAY != pKeep2->unit))) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_KEEP_UNIT, pKeep0->unit, pKeep1->unit, pKeep2->unit); } @@ -1404,7 +1527,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p code = checkRangeOption(pCxt, "compression", pOptions->pCompressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL); } if (TSDB_CODE_SUCCESS == code) { - code = checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + code = + checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); } if (TSDB_CODE_SUCCESS == code) { code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->pFsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD); @@ -1457,7 +1581,7 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* return checkDatabaseOptions(pCxt, pStmt->pOptions); } -typedef int32_t (*FSerializeFunc)(void *pBuf, int32_t bufLen, void *pReq); +typedef int32_t (*FSerializeFunc)(void* pBuf, int32_t bufLen, void* pReq); static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeFunc func, void* pReq) { pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); @@ -1493,7 +1617,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) { SDropDbReq dropReq = {0}; - SName name = {0}; + SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, dropReq.db); dropReq.ignoreNotExists = pStmt->ignoreNotExists; @@ -1707,7 +1831,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt STableMeta* pTableMeta = NULL; SName tableName; int32_t code = getTableMetaImpl( - pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); + pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); if ((TSDB_CODE_TDB_INVALID_TABLE_ID == code || TSDB_CODE_VND_TB_NOT_EXIST == code) && pClause->ignoreNotExists) { return TSDB_CODE_SUCCESS; } @@ -1993,7 +2117,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt } SMCreateSmaReq createSmaReq = {0}; - int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); + int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq); } @@ -2006,7 +2130,7 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt* } static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { SMCreateFullTextReq createFTReq = {0}; - int32_t code = buildCreateFullTextReq(pCxt, pStmt, &createFTReq); + int32_t code = buildCreateFullTextReq(pCxt, pStmt, &createFTReq); if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_INDEX, (FSerializeFunc)tSerializeSMCreateFullTextReq, &createFTReq); } @@ -2062,7 +2186,8 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) { static int32_t translateCreateComponentNode(STranslateContext* pCxt, SCreateComponentNodeStmt* pStmt) { SMCreateQnodeReq createReq = {.dnodeId = pStmt->dnodeId}; - return buildCmdMsg(pCxt, getCreateComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &createReq); + return buildCmdMsg(pCxt, getCreateComponentNodeMsgType(nodeType(pStmt)), + (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &createReq); } static int16_t getDropComponentNodeMsgType(ENodeType type) { @@ -2083,7 +2208,8 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) { static int32_t translateDropComponentNode(STranslateContext* pCxt, SDropComponentNodeStmt* pStmt) { SDDropQnodeReq dropReq = {.dnodeId = pStmt->dnodeId}; - return buildCmdMsg(pCxt, getDropComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &dropReq); + return buildCmdMsg(pCxt, getDropComponentNodeMsgType(nodeType(pStmt)), + (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &dropReq); } static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) { @@ -2187,11 +2313,13 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt* } if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pWatermark) { - code = (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark)) ? pCxt->errCode : TSDB_CODE_SUCCESS; + code = (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark)) ? pCxt->errCode + : TSDB_CODE_SUCCESS; } if (TSDB_CODE_SUCCESS == code) { createReq.triggerType = pStmt->pOptions->triggerType; - createReq.watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); + createReq.watermark = + (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); } if (TSDB_CODE_SUCCESS == code) { @@ -2343,9 +2471,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu return TSDB_CODE_SUCCESS; } -static int8_t extractResultTsPrecision(const SSelectStmt* pSelect) { - return pSelect->precision; -} +static int8_t extractResultTsPrecision(const SSelectStmt* pSelect) { return pSelect->precision; } static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 1; @@ -2608,11 +2734,15 @@ typedef struct SVgroupTablesBatch { char dbName[TSDB_DB_NAME_LEN]; } SVgroupTablesBatch; -static void toSchemaEx(const SColumnDefNode* pCol, col_id_t colId, SSchemaEx* pSchema) { +static void toSchemaEx(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchema) { + int8_t flags = 0; + if (pCol->sma) { + flags |= SCHEMA_SMA_ON; + } pSchema->colId = colId; pSchema->type = pCol->dataType.type; pSchema->bytes = calcTypeBytes(pCol->dataType); - pSchema->sma = pCol->sma ? TSDB_BSMA_TYPE_LATEST : TSDB_BSMA_TYPE_NONE; + pSchema->flags = flags; strcpy(pSchema->name, pCol->colName); } @@ -2657,7 +2787,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* req.dbFName = strdup(dbFName); req.name = strdup(pStmt->tableName); req.ntbCfg.nCols = LIST_LENGTH(pStmt->pCols); - req.ntbCfg.pSchema = taosMemoryCalloc(req.ntbCfg.nCols, sizeof(SSchemaEx)); + req.ntbCfg.pSchema = taosMemoryCalloc(req.ntbCfg.nCols, sizeof(SSchema)); if (NULL == req.name || NULL == req.ntbCfg.pSchema) { destroyCreateTbReq(&req); return TSDB_CODE_OUT_OF_MEMORY; @@ -3062,7 +3192,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } - pQuery->precision = extractResultTsPrecision((SSelectStmt*) pQuery->pRoot); + pQuery->precision = extractResultTsPrecision((SSelectStmt*)pQuery->pRoot); } if (NULL != pCxt->pDbs) { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 549f448ff4..51e0b2a328 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -55,8 +55,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Endpoint should be in the format of 'fqdn:port'"; case TSDB_CODE_PAR_EXPRIE_STATEMENT: return "This statement is no longer supported"; - case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL: - return "This interval value is too small : %s"; + case TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL: + return "Interval cannot be less than %d us"; case TSDB_CODE_PAR_DB_NOT_SPECIFIED: return "Database not specified"; case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME: @@ -93,6 +93,28 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid option keep unit: %c, %c, %c, only m, h, d allowed"; case TSDB_CODE_PAR_AGG_FUNC_NESTING: return "Aggregate functions do not support nesting"; + case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE: + return "Only support STATE_WINDOW on integer column"; + case TSDB_CODE_PAR_INVALID_STATE_WIN_COL: + return "Not support STATE_WINDOW on tag column"; + case TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE: + return "STATE_WINDOW not support for super table query"; + case TSDB_CODE_PAR_INTER_SESSION_GAP: + return "SESSION gap should be fixed time window, and greater than 0"; + case TSDB_CODE_PAR_INTER_SESSION_COL: + return "Only support SESSION on primary timestamp column"; + case TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE: + return "Interval offset cannot be negative"; + case TSDB_CODE_PAR_INTER_OFFSET_UNIT: + return "Cannot use 'year' as offset when interval is 'month'"; + case TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG: + return "Interval offset should be shorter than interval"; + case TSDB_CODE_PAR_INTER_SLIDING_UNIT: + return "Does not support sliding when interval is natural month/year"; + case TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG: + return "sliding value no larger than the interval value"; + case TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL: + return "sliding value can not less than 1% of interval value"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index e9ec9c987c..224d647017 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 333 +#define YYNOCODE 334 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SAlterOption yy11; - int32_t yy100; - EJoinType yy162; - EOperatorType yy218; - EOrder yy326; - SDataType yy430; - SNode* yy452; - SNodeList* yy478; - SToken yy479; - EFillMode yy540; - ENullOrder yy595; - bool yy659; + SAlterOption yy29; + EJoinType yy164; + ENullOrder yy209; + SDataType yy388; + EOperatorType yy416; + SNode* yy456; + SToken yy537; + EOrder yy626; + SNodeList* yy632; + EFillMode yy646; + bool yy649; + int32_t yy652; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -133,16 +133,16 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYNSTATE 568 -#define YYNRULE 432 -#define YYNTOKEN 219 +#define YYNRULE 433 +#define YYNTOKEN 220 #define YY_MAX_SHIFT 567 -#define YY_MIN_SHIFTREDUCE 842 -#define YY_MAX_SHIFTREDUCE 1273 -#define YY_ERROR_ACTION 1274 -#define YY_ACCEPT_ACTION 1275 -#define YY_NO_ACTION 1276 -#define YY_MIN_REDUCE 1277 -#define YY_MAX_REDUCE 1708 +#define YY_MIN_SHIFTREDUCE 843 +#define YY_MAX_SHIFTREDUCE 1275 +#define YY_ERROR_ACTION 1276 +#define YY_ACCEPT_ACTION 1277 +#define YY_NO_ACTION 1278 +#define YY_MIN_REDUCE 1279 +#define YY_MAX_REDUCE 1711 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -209,545 +209,534 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1929) +#define YY_ACTTAB_COUNT (1863) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1388, 1687, 1386, 1561, 268, 26, 203, 323, 482, 1275, - /* 10 */ 469, 1547, 33, 31, 1686, 1561, 1490, 77, 1685, 1300, - /* 20 */ 277, 1547, 1095, 285, 380, 1543, 1550, 1577, 34, 32, - /* 30 */ 30, 29, 28, 1397, 466, 1543, 1549, 248, 1093, 1577, - /* 40 */ 1547, 481, 53, 417, 465, 1533, 466, 441, 1533, 1116, - /* 50 */ 12, 33, 31, 1216, 1543, 1549, 465, 1101, 481, 277, - /* 60 */ 1533, 1095, 293, 1393, 1533, 445, 125, 1562, 468, 1564, - /* 70 */ 1565, 464, 104, 459, 1, 482, 359, 1093, 72, 1562, - /* 80 */ 468, 1564, 1565, 464, 321, 459, 1375, 418, 1626, 12, - /* 90 */ 482, 1230, 249, 1622, 124, 36, 1101, 564, 1355, 77, - /* 100 */ 1397, 1687, 33, 31, 1687, 123, 387, 1289, 102, 1094, - /* 110 */ 277, 1701, 1095, 1, 136, 1397, 1373, 136, 1685, 1118, - /* 120 */ 22, 1685, 443, 132, 1633, 1634, 1687, 1638, 1093, 1278, - /* 130 */ 34, 32, 30, 29, 28, 359, 564, 1329, 1446, 136, - /* 140 */ 12, 560, 559, 1685, 267, 1577, 1096, 1101, 1094, 1444, + /* 0 */ 1390, 1690, 1388, 1563, 268, 26, 203, 323, 482, 1277, + /* 10 */ 469, 1549, 33, 31, 1689, 1563, 1492, 77, 1688, 1302, + /* 20 */ 277, 1549, 1096, 285, 380, 1545, 1552, 1579, 34, 32, + /* 30 */ 30, 29, 28, 1399, 466, 1545, 1551, 248, 1094, 1579, + /* 40 */ 1549, 481, 53, 417, 465, 1535, 466, 441, 1535, 1301, + /* 50 */ 12, 33, 31, 1218, 1545, 1551, 465, 1102, 481, 277, + /* 60 */ 1535, 1096, 293, 1395, 1535, 445, 125, 1564, 468, 1566, + /* 70 */ 1567, 464, 104, 459, 1, 482, 359, 1094, 72, 1564, + /* 80 */ 468, 1566, 1567, 464, 321, 459, 1377, 418, 1629, 12, + /* 90 */ 482, 1232, 249, 1625, 1535, 36, 1102, 564, 62, 77, + /* 100 */ 1399, 1690, 33, 31, 1690, 123, 387, 1291, 102, 1095, + /* 110 */ 277, 1704, 1096, 1, 136, 1399, 1375, 136, 1688, 1392, + /* 120 */ 22, 1688, 443, 132, 1636, 1637, 1690, 1641, 1094, 1280, + /* 130 */ 34, 32, 30, 29, 28, 359, 564, 1331, 1448, 136, + /* 140 */ 12, 1117, 481, 1688, 267, 1579, 1097, 1102, 1095, 1446, /* 150 */ 87, 127, 466, 86, 85, 84, 83, 82, 81, 80, - /* 160 */ 79, 78, 1438, 469, 1, 518, 280, 1099, 1100, 1489, - /* 170 */ 1144, 1145, 1146, 1147, 1148, 1149, 1150, 461, 1155, 1156, - /* 180 */ 1157, 1158, 1159, 1160, 53, 1096, 434, 564, 431, 395, - /* 190 */ 316, 389, 315, 1299, 481, 394, 137, 99, 101, 1094, - /* 200 */ 390, 388, 1298, 391, 1640, 1392, 1099, 1100, 878, 1144, - /* 210 */ 1145, 1146, 1147, 1148, 1149, 1150, 461, 1155, 1156, 1157, - /* 220 */ 1158, 1159, 1160, 100, 378, 137, 441, 383, 1637, 33, - /* 230 */ 31, 34, 32, 30, 29, 28, 1096, 277, 1533, 1095, - /* 240 */ 930, 137, 34, 32, 30, 29, 28, 1533, 36, 386, - /* 250 */ 137, 104, 1522, 436, 432, 1093, 441, 1099, 1100, 932, - /* 260 */ 1144, 1145, 1146, 1147, 1148, 1149, 1150, 461, 1155, 1156, - /* 270 */ 1157, 1158, 1159, 1160, 1101, 33, 31, 1161, 55, 266, - /* 280 */ 250, 104, 174, 277, 435, 1095, 1326, 102, 300, 87, - /* 290 */ 1297, 7, 86, 85, 84, 83, 82, 81, 80, 79, - /* 300 */ 78, 1093, 133, 1633, 1634, 1131, 1638, 281, 9, 8, - /* 310 */ 395, 1120, 389, 1178, 564, 121, 394, 102, 1119, 101, - /* 320 */ 1101, 390, 388, 1399, 391, 317, 1094, 1240, 30, 29, - /* 330 */ 28, 260, 134, 1633, 1634, 1533, 1638, 7, 540, 539, - /* 340 */ 538, 537, 292, 1117, 536, 535, 534, 107, 529, 528, - /* 350 */ 527, 526, 525, 524, 523, 522, 114, 100, 385, 384, - /* 360 */ 564, 383, 1179, 1096, 1687, 428, 1238, 1239, 1241, 1242, - /* 370 */ 137, 225, 1094, 261, 1427, 259, 258, 136, 382, 1296, - /* 380 */ 1184, 1685, 1192, 386, 1099, 1100, 448, 1144, 1145, 1146, - /* 390 */ 1147, 1148, 1149, 1150, 461, 1155, 1156, 1157, 1158, 1159, - /* 400 */ 1160, 449, 33, 31, 34, 32, 30, 29, 28, 1096, - /* 410 */ 277, 69, 1095, 137, 25, 275, 1173, 1174, 1175, 1176, - /* 420 */ 1177, 1181, 1182, 1183, 1533, 105, 143, 409, 1093, 198, - /* 430 */ 1099, 1100, 1389, 1144, 1145, 1146, 1147, 1148, 1149, 1150, - /* 440 */ 461, 1155, 1156, 1157, 1158, 1159, 1160, 1101, 33, 31, - /* 450 */ 284, 283, 51, 1215, 288, 50, 277, 1446, 1095, 24, - /* 460 */ 1109, 1480, 1482, 282, 7, 400, 1687, 1446, 1444, 34, - /* 470 */ 32, 30, 29, 28, 1093, 482, 1102, 1295, 1481, 136, - /* 480 */ 408, 1640, 287, 1685, 322, 532, 879, 564, 878, 311, - /* 490 */ 121, 393, 392, 1101, 173, 1101, 345, 403, 1399, 1094, - /* 500 */ 1397, 1294, 397, 6, 1293, 1636, 880, 521, 172, 1369, - /* 510 */ 1, 968, 505, 504, 503, 972, 502, 974, 975, 501, - /* 520 */ 977, 498, 1533, 983, 495, 985, 986, 492, 489, 247, - /* 530 */ 120, 1116, 290, 564, 45, 483, 1096, 44, 338, 518, - /* 540 */ 121, 350, 147, 146, 450, 1094, 1533, 1105, 1399, 1533, - /* 550 */ 351, 34, 32, 30, 29, 28, 1292, 1099, 1100, 1640, - /* 560 */ 1144, 1145, 1146, 1147, 1148, 1149, 1150, 461, 1155, 1156, - /* 570 */ 1157, 1158, 1159, 1160, 34, 32, 30, 29, 28, 1180, - /* 580 */ 1291, 508, 1096, 1635, 1110, 515, 514, 533, 531, 250, - /* 590 */ 34, 32, 30, 29, 28, 447, 1121, 1185, 9, 8, - /* 600 */ 62, 1533, 1288, 1099, 1100, 1113, 1144, 1145, 1146, 1147, - /* 610 */ 1148, 1149, 1150, 461, 1155, 1156, 1157, 1158, 1159, 1160, - /* 620 */ 1561, 1390, 1178, 349, 520, 1533, 344, 343, 342, 341, - /* 630 */ 340, 23, 337, 336, 335, 334, 333, 329, 328, 327, - /* 640 */ 326, 325, 324, 482, 1577, 482, 1214, 1533, 482, 567, - /* 650 */ 121, 444, 330, 1131, 331, 1211, 1446, 358, 1400, 1645, - /* 660 */ 1211, 465, 289, 221, 1287, 1533, 98, 1444, 1397, 482, - /* 670 */ 1397, 1179, 556, 1397, 552, 548, 544, 220, 1394, 1081, - /* 680 */ 1082, 1446, 416, 73, 1562, 468, 1564, 1565, 464, 1184, - /* 690 */ 459, 482, 1445, 1626, 1397, 482, 1290, 270, 1622, 131, - /* 700 */ 291, 1270, 1286, 70, 1514, 1285, 215, 452, 1477, 1533, - /* 710 */ 1561, 199, 482, 482, 184, 145, 1397, 424, 1653, 1382, - /* 720 */ 1397, 479, 480, 25, 275, 1173, 1174, 1175, 1176, 1177, - /* 730 */ 1181, 1182, 1183, 1223, 1577, 1316, 478, 1397, 1397, 1118, - /* 740 */ 482, 444, 165, 308, 456, 163, 1284, 1533, 1283, 217, - /* 750 */ 1533, 465, 1282, 1281, 1166, 1533, 1280, 396, 407, 200, - /* 760 */ 1118, 1384, 310, 167, 423, 1397, 166, 180, 1561, 169, - /* 770 */ 1380, 405, 168, 73, 1562, 468, 1564, 1565, 464, 1269, - /* 780 */ 459, 429, 1073, 1626, 176, 1311, 68, 270, 1622, 131, - /* 790 */ 1277, 1533, 1577, 1533, 1272, 1273, 64, 1533, 1533, 466, - /* 800 */ 171, 1533, 1309, 170, 177, 460, 507, 398, 1654, 465, - /* 810 */ 1356, 1439, 410, 1533, 96, 95, 94, 93, 92, 91, - /* 820 */ 90, 89, 88, 112, 401, 47, 1561, 420, 377, 1237, - /* 830 */ 1554, 73, 1562, 468, 1564, 1565, 464, 193, 459, 187, - /* 840 */ 1656, 1626, 1552, 189, 35, 270, 1622, 1699, 1186, 442, - /* 850 */ 1577, 35, 453, 122, 904, 1151, 1660, 466, 231, 35, - /* 860 */ 206, 1170, 1104, 1056, 208, 1578, 160, 465, 1103, 130, - /* 870 */ 229, 1533, 109, 905, 202, 376, 474, 372, 368, 364, - /* 880 */ 159, 110, 2, 148, 1561, 214, 1116, 295, 299, 73, - /* 890 */ 1562, 468, 1564, 1565, 464, 255, 459, 112, 930, 1626, - /* 900 */ 257, 961, 1065, 270, 1622, 1699, 54, 47, 1577, 157, - /* 910 */ 222, 956, 332, 487, 1683, 466, 110, 989, 111, 112, - /* 920 */ 993, 1479, 1000, 999, 110, 465, 144, 339, 113, 1533, - /* 930 */ 347, 346, 348, 1107, 352, 353, 1125, 149, 354, 1106, - /* 940 */ 1561, 1124, 355, 152, 1123, 356, 71, 73, 1562, 468, - /* 950 */ 1564, 1565, 464, 1561, 459, 155, 52, 1626, 360, 357, - /* 960 */ 1122, 270, 1622, 1699, 1577, 379, 156, 381, 151, 158, - /* 970 */ 153, 466, 1644, 1387, 49, 48, 320, 1577, 142, 162, - /* 980 */ 1383, 465, 164, 314, 463, 1533, 265, 150, 115, 116, - /* 990 */ 445, 1561, 1385, 1381, 465, 256, 117, 306, 1533, 302, - /* 1000 */ 298, 139, 97, 238, 1562, 468, 1564, 1565, 464, 441, - /* 1010 */ 459, 118, 1101, 175, 411, 1577, 245, 1562, 468, 1564, - /* 1020 */ 1565, 464, 466, 459, 1518, 1599, 223, 412, 421, 1687, - /* 1030 */ 415, 137, 465, 1121, 104, 419, 1533, 1657, 179, 182, - /* 1040 */ 422, 430, 136, 472, 1667, 185, 1685, 188, 438, 1561, - /* 1050 */ 427, 269, 5, 445, 74, 1562, 468, 1564, 1565, 464, - /* 1060 */ 433, 459, 426, 1647, 1626, 1666, 4, 1211, 1625, 1622, - /* 1070 */ 102, 103, 192, 1577, 129, 194, 1120, 1641, 37, 1561, - /* 1080 */ 466, 16, 271, 451, 195, 196, 1633, 440, 454, 439, - /* 1090 */ 465, 1488, 1687, 1684, 1533, 1702, 201, 1607, 470, 471, - /* 1100 */ 224, 475, 1487, 1577, 210, 136, 279, 212, 476, 1685, - /* 1110 */ 463, 61, 74, 1562, 468, 1564, 1565, 464, 477, 459, - /* 1120 */ 465, 63, 1626, 485, 1533, 1370, 455, 1622, 1561, 1398, - /* 1130 */ 226, 219, 563, 43, 128, 232, 233, 1561, 228, 1095, - /* 1140 */ 230, 1527, 245, 1562, 468, 1564, 1565, 464, 462, 459, - /* 1150 */ 457, 1598, 1577, 1526, 294, 1093, 1523, 296, 297, 466, - /* 1160 */ 1089, 1577, 1090, 140, 301, 1521, 303, 304, 466, 465, - /* 1170 */ 307, 305, 1520, 1533, 1101, 1561, 1519, 309, 465, 1504, - /* 1180 */ 141, 312, 1533, 313, 1068, 1067, 1498, 1561, 1497, 318, - /* 1190 */ 319, 125, 1562, 468, 1564, 1565, 464, 1496, 459, 1577, - /* 1200 */ 74, 1562, 468, 1564, 1565, 464, 466, 459, 1495, 1472, - /* 1210 */ 1626, 1577, 1039, 1471, 564, 1623, 465, 1470, 466, 1469, - /* 1220 */ 1533, 108, 1456, 425, 1468, 1467, 1094, 1466, 465, 1465, - /* 1230 */ 1464, 1463, 1533, 1462, 1461, 446, 1700, 1460, 246, 1562, - /* 1240 */ 468, 1564, 1565, 464, 1459, 459, 1561, 1458, 1457, 1455, - /* 1250 */ 241, 1562, 468, 1564, 1565, 464, 1454, 459, 1453, 1561, - /* 1260 */ 1452, 1451, 1041, 1096, 1450, 1449, 1448, 1447, 1328, 1512, - /* 1270 */ 1577, 154, 1376, 1327, 897, 1325, 361, 466, 1506, 1494, - /* 1280 */ 1485, 362, 363, 1577, 1099, 1100, 1323, 465, 437, 365, - /* 1290 */ 466, 1533, 1321, 366, 276, 367, 371, 369, 370, 1319, - /* 1300 */ 465, 373, 1308, 1307, 1533, 1304, 374, 274, 1378, 246, - /* 1310 */ 1562, 468, 1564, 1565, 464, 76, 459, 1561, 1005, 375, - /* 1320 */ 1008, 1377, 246, 1562, 468, 1564, 1565, 464, 929, 459, - /* 1330 */ 1317, 161, 928, 1561, 262, 927, 926, 1312, 923, 263, - /* 1340 */ 1310, 1577, 922, 1303, 264, 1561, 399, 402, 466, 404, - /* 1350 */ 1302, 406, 530, 75, 532, 1511, 46, 1577, 465, 1505, - /* 1360 */ 413, 1075, 1533, 119, 466, 278, 1493, 1492, 1484, 1577, - /* 1370 */ 186, 178, 38, 414, 465, 181, 466, 3, 1533, 1374, - /* 1380 */ 246, 1562, 468, 1564, 1565, 464, 465, 459, 56, 35, - /* 1390 */ 1533, 13, 1561, 40, 1236, 41, 234, 1562, 468, 1564, - /* 1400 */ 1565, 464, 126, 459, 14, 1561, 1229, 183, 240, 1562, - /* 1410 */ 468, 1564, 1565, 464, 1208, 459, 1577, 191, 190, 20, - /* 1420 */ 1552, 57, 21, 466, 39, 15, 11, 1207, 197, 1577, - /* 1430 */ 58, 1263, 1258, 465, 135, 1257, 466, 1533, 1372, 272, - /* 1440 */ 106, 1262, 1261, 1561, 513, 273, 465, 8, 17, 1154, - /* 1450 */ 1533, 1171, 458, 1139, 27, 242, 1562, 468, 1564, 1565, - /* 1460 */ 464, 1153, 459, 1152, 205, 10, 516, 1577, 235, 1562, - /* 1470 */ 468, 1564, 1565, 464, 466, 459, 138, 1234, 204, 18, - /* 1480 */ 467, 1483, 19, 207, 465, 512, 511, 510, 1533, 509, - /* 1490 */ 209, 59, 211, 1561, 213, 60, 473, 64, 1551, 106, - /* 1500 */ 216, 1111, 42, 513, 484, 990, 243, 1562, 468, 1564, - /* 1510 */ 1565, 464, 486, 459, 286, 488, 490, 1577, 987, 984, - /* 1520 */ 491, 493, 494, 1561, 466, 516, 978, 496, 497, 499, - /* 1530 */ 976, 500, 982, 967, 465, 981, 980, 506, 1533, 979, - /* 1540 */ 65, 1002, 66, 67, 512, 511, 510, 1577, 509, 995, - /* 1550 */ 998, 1001, 895, 936, 466, 517, 236, 1562, 468, 1564, - /* 1560 */ 1565, 464, 519, 459, 465, 911, 218, 918, 1533, 917, - /* 1570 */ 916, 1561, 915, 914, 913, 912, 933, 931, 908, 907, - /* 1580 */ 1561, 543, 906, 903, 902, 901, 244, 1562, 468, 1564, - /* 1590 */ 1565, 464, 900, 459, 1324, 1577, 541, 542, 1322, 546, - /* 1600 */ 545, 1320, 466, 547, 1577, 549, 550, 551, 1318, 553, - /* 1610 */ 554, 466, 465, 1306, 557, 555, 1533, 558, 1305, 1301, - /* 1620 */ 562, 465, 561, 566, 1097, 1533, 227, 565, 1561, 1276, - /* 1630 */ 1276, 1276, 1276, 1276, 237, 1562, 468, 1564, 1565, 464, - /* 1640 */ 1276, 459, 1276, 1573, 1562, 468, 1564, 1565, 464, 1276, - /* 1650 */ 459, 1276, 1577, 1276, 1276, 1276, 1561, 1276, 1276, 466, - /* 1660 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 465, - /* 1670 */ 1276, 1276, 1276, 1533, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1680 */ 1577, 1276, 1276, 1276, 1276, 1276, 1276, 466, 1276, 1276, - /* 1690 */ 1276, 1572, 1562, 468, 1564, 1565, 464, 465, 459, 1276, - /* 1700 */ 1276, 1533, 1276, 1276, 1276, 1276, 1276, 1561, 1276, 1276, - /* 1710 */ 1276, 1276, 1276, 1276, 1276, 1276, 1561, 1276, 1276, 1571, - /* 1720 */ 1562, 468, 1564, 1565, 464, 1276, 459, 1276, 1276, 1276, - /* 1730 */ 1276, 1577, 1276, 1276, 1276, 1276, 1276, 1276, 466, 1276, - /* 1740 */ 1577, 1276, 1276, 1276, 1276, 1276, 1276, 466, 465, 1276, - /* 1750 */ 1276, 1276, 1533, 1276, 1276, 1276, 1276, 465, 1276, 1276, - /* 1760 */ 1276, 1533, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1770 */ 253, 1562, 468, 1564, 1565, 464, 1276, 459, 1276, 252, - /* 1780 */ 1562, 468, 1564, 1565, 464, 1276, 459, 1561, 1276, 1276, - /* 1790 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1800 */ 1276, 1276, 1276, 1561, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1810 */ 1276, 1577, 1276, 1276, 1276, 1276, 1276, 1276, 466, 1276, - /* 1820 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1577, 465, 1276, - /* 1830 */ 1276, 1276, 1533, 1276, 466, 1276, 1276, 1276, 1276, 1276, - /* 1840 */ 1276, 1276, 1276, 1276, 465, 1276, 1276, 1276, 1533, 1276, - /* 1850 */ 254, 1562, 468, 1564, 1565, 464, 1276, 459, 1561, 1276, - /* 1860 */ 1276, 1276, 1276, 1276, 1276, 1276, 251, 1562, 468, 1564, - /* 1870 */ 1565, 464, 1276, 459, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1880 */ 1276, 1276, 1577, 1276, 1276, 1276, 1276, 1276, 1276, 466, - /* 1890 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 465, - /* 1900 */ 1276, 1276, 1276, 1533, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1910 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, - /* 1920 */ 1276, 239, 1562, 468, 1564, 1565, 464, 1276, 459, + /* 160 */ 79, 78, 1440, 469, 1, 518, 280, 1100, 1101, 1491, + /* 170 */ 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, + /* 180 */ 1158, 1159, 1160, 1161, 1162, 1097, 434, 564, 431, 395, + /* 190 */ 316, 389, 315, 560, 559, 394, 36, 137, 101, 1095, + /* 200 */ 390, 388, 137, 391, 55, 266, 1100, 1101, 174, 1145, + /* 210 */ 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, + /* 220 */ 1159, 1160, 1161, 1162, 482, 482, 482, 441, 482, 931, + /* 230 */ 33, 31, 452, 322, 330, 331, 1097, 358, 277, 880, + /* 240 */ 1096, 879, 137, 34, 32, 30, 29, 28, 933, 1399, + /* 250 */ 1399, 1399, 104, 1399, 436, 432, 1094, 1100, 1101, 881, + /* 260 */ 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, + /* 270 */ 1158, 1159, 1160, 1161, 1162, 1102, 33, 31, 1163, 385, + /* 280 */ 384, 250, 345, 143, 277, 1300, 1096, 1328, 102, 521, + /* 290 */ 87, 1371, 7, 86, 85, 84, 83, 82, 81, 80, + /* 300 */ 79, 78, 1094, 133, 1636, 1637, 1132, 1641, 281, 51, + /* 310 */ 1119, 395, 50, 389, 1180, 564, 121, 394, 137, 137, + /* 320 */ 101, 1102, 390, 388, 1401, 391, 1242, 1095, 147, 146, + /* 330 */ 1535, 317, 260, 34, 32, 30, 29, 28, 7, 540, + /* 340 */ 539, 538, 537, 292, 879, 536, 535, 534, 107, 529, + /* 350 */ 528, 527, 526, 525, 524, 523, 522, 114, 100, 53, + /* 360 */ 378, 564, 383, 1181, 1097, 428, 1240, 1241, 1243, 1244, + /* 370 */ 1690, 124, 99, 1095, 261, 1357, 259, 258, 453, 382, + /* 380 */ 1394, 1186, 435, 136, 386, 1100, 1101, 1688, 1145, 1146, + /* 390 */ 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, 1159, + /* 400 */ 1160, 1161, 1162, 441, 33, 31, 393, 392, 441, 532, + /* 410 */ 1097, 1120, 277, 311, 1096, 137, 25, 275, 1175, 1176, + /* 420 */ 1177, 1178, 1179, 1183, 1184, 1185, 515, 514, 104, 456, + /* 430 */ 1094, 1100, 1101, 104, 1145, 1146, 1147, 1148, 1149, 1150, + /* 440 */ 1151, 461, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1102, + /* 450 */ 33, 31, 445, 482, 409, 287, 69, 1096, 277, 120, + /* 460 */ 1096, 1448, 1396, 121, 102, 1121, 7, 282, 905, 102, + /* 470 */ 105, 1401, 1446, 1094, 9, 8, 1094, 1391, 1399, 134, + /* 480 */ 1636, 1637, 449, 1641, 196, 1636, 440, 906, 439, 564, + /* 490 */ 1376, 1690, 1102, 1690, 1299, 1102, 34, 32, 30, 29, + /* 500 */ 28, 1095, 1318, 1118, 136, 1298, 136, 518, 1688, 1297, + /* 510 */ 1688, 1296, 1, 969, 505, 504, 503, 973, 502, 975, + /* 520 */ 976, 501, 978, 498, 396, 984, 495, 986, 987, 492, + /* 530 */ 489, 247, 564, 1117, 288, 564, 482, 508, 1097, 1535, + /* 540 */ 338, 1482, 1484, 350, 1095, 1516, 1172, 1095, 1194, 1295, + /* 550 */ 1535, 106, 351, 100, 1535, 513, 1535, 383, 1313, 1100, + /* 560 */ 1101, 1399, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, + /* 570 */ 1156, 1157, 1158, 1159, 1160, 1161, 1162, 516, 1479, 386, + /* 580 */ 398, 1097, 482, 198, 1097, 145, 34, 32, 30, 29, + /* 590 */ 28, 479, 225, 1448, 1535, 1429, 512, 511, 510, 289, + /* 600 */ 509, 520, 1100, 1101, 1446, 1100, 1101, 1399, 1145, 1146, + /* 610 */ 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, 1159, + /* 620 */ 1160, 1161, 1162, 1563, 250, 349, 450, 1294, 344, 343, + /* 630 */ 342, 341, 340, 1384, 337, 336, 335, 334, 333, 329, + /* 640 */ 328, 327, 326, 325, 324, 448, 482, 1579, 34, 32, + /* 650 */ 30, 29, 28, 482, 444, 480, 567, 1180, 1182, 290, + /* 660 */ 482, 1386, 217, 1293, 465, 533, 531, 121, 1535, 291, + /* 670 */ 221, 1399, 1535, 98, 1563, 1401, 1187, 1290, 1399, 556, + /* 680 */ 1289, 552, 548, 544, 220, 1399, 73, 1564, 468, 1566, + /* 690 */ 1567, 464, 1122, 459, 1648, 1213, 1629, 6, 1579, 1643, + /* 700 */ 270, 1625, 131, 1288, 1287, 444, 1181, 1448, 1535, 1286, + /* 710 */ 70, 23, 1285, 215, 199, 465, 24, 1382, 1483, 1535, + /* 720 */ 424, 1656, 1535, 1640, 1186, 1535, 34, 32, 30, 29, + /* 730 */ 28, 30, 29, 28, 1448, 1284, 1217, 73, 1564, 468, + /* 740 */ 1566, 1567, 464, 478, 459, 1447, 1643, 1629, 1535, 1535, + /* 750 */ 1225, 270, 1625, 131, 1535, 1563, 1119, 1535, 400, 25, + /* 760 */ 275, 1175, 1176, 1177, 1178, 1179, 1183, 1184, 1185, 1283, + /* 770 */ 1639, 423, 1657, 408, 180, 1272, 1524, 1311, 1643, 1579, + /* 780 */ 1535, 34, 32, 30, 29, 28, 466, 173, 1168, 1074, + /* 790 */ 403, 176, 1282, 177, 1119, 397, 465, 121, 308, 401, + /* 800 */ 1535, 172, 1638, 165, 167, 1402, 163, 166, 1082, 1083, + /* 810 */ 184, 1563, 300, 169, 1535, 460, 168, 310, 73, 1564, + /* 820 */ 468, 1566, 1567, 464, 507, 459, 171, 45, 1629, 170, + /* 830 */ 44, 416, 270, 1625, 1702, 1579, 1374, 1535, 407, 1292, + /* 840 */ 122, 1563, 466, 1663, 1132, 231, 9, 8, 1358, 112, + /* 850 */ 1213, 405, 465, 420, 1271, 447, 1535, 229, 47, 187, + /* 860 */ 1274, 1275, 1239, 189, 35, 1579, 200, 1441, 1188, 35, + /* 870 */ 148, 1563, 466, 1152, 73, 1564, 468, 1566, 1567, 464, + /* 880 */ 1556, 459, 465, 429, 1629, 1105, 1535, 410, 270, 1625, + /* 890 */ 1702, 377, 1554, 1104, 35, 1579, 193, 106, 1057, 1686, + /* 900 */ 68, 513, 466, 442, 73, 1564, 468, 1566, 1567, 464, + /* 910 */ 64, 459, 465, 206, 1629, 1659, 1535, 208, 270, 1625, + /* 920 */ 1702, 445, 1580, 516, 109, 202, 1563, 110, 474, 1647, + /* 930 */ 1216, 214, 2, 71, 238, 1564, 468, 1566, 1567, 464, + /* 940 */ 1117, 459, 512, 511, 510, 112, 509, 47, 487, 962, + /* 950 */ 1579, 957, 990, 295, 299, 255, 1108, 466, 1066, 222, + /* 960 */ 1690, 49, 48, 320, 1107, 142, 931, 465, 144, 332, + /* 970 */ 314, 1535, 257, 136, 110, 1481, 1563, 1688, 994, 111, + /* 980 */ 339, 112, 256, 1001, 306, 1000, 302, 298, 139, 74, + /* 990 */ 1564, 468, 1566, 1567, 464, 347, 459, 346, 110, 1629, + /* 1000 */ 1579, 348, 113, 1628, 1625, 1126, 353, 466, 352, 354, + /* 1010 */ 1125, 149, 152, 356, 355, 1124, 357, 465, 360, 137, + /* 1020 */ 160, 1535, 155, 130, 1563, 52, 158, 1123, 379, 376, + /* 1030 */ 381, 372, 368, 364, 159, 1563, 97, 1389, 265, 74, + /* 1040 */ 1564, 468, 1566, 1567, 464, 1102, 459, 162, 1579, 1629, + /* 1050 */ 1520, 1385, 164, 455, 1625, 463, 115, 116, 1387, 1579, + /* 1060 */ 54, 175, 1383, 157, 223, 465, 466, 117, 118, 1535, + /* 1070 */ 411, 419, 415, 412, 179, 1122, 465, 182, 421, 1670, + /* 1080 */ 1535, 422, 1660, 430, 472, 1669, 427, 245, 1564, 468, + /* 1090 */ 1566, 1567, 464, 462, 459, 457, 1601, 185, 125, 1564, + /* 1100 */ 468, 1566, 1567, 464, 188, 459, 1563, 269, 284, 283, + /* 1110 */ 5, 433, 438, 103, 426, 4, 1644, 1121, 1110, 1213, + /* 1120 */ 156, 1650, 151, 37, 153, 271, 451, 454, 16, 1490, + /* 1130 */ 1579, 1489, 195, 470, 1103, 129, 1563, 466, 471, 1610, + /* 1140 */ 194, 150, 446, 1703, 1563, 192, 475, 465, 476, 279, + /* 1150 */ 210, 1535, 477, 1102, 212, 63, 1400, 61, 224, 1687, + /* 1160 */ 1579, 201, 1372, 1705, 226, 219, 563, 466, 1579, 74, + /* 1170 */ 1564, 468, 1566, 1567, 464, 466, 459, 465, 128, 1629, + /* 1180 */ 485, 1535, 43, 232, 1626, 465, 233, 228, 230, 1535, + /* 1190 */ 1529, 1563, 425, 483, 1528, 294, 1525, 296, 297, 241, + /* 1200 */ 1564, 468, 1566, 1567, 464, 1106, 459, 246, 1564, 468, + /* 1210 */ 1566, 1567, 464, 1090, 459, 1579, 1091, 140, 1523, 303, + /* 1220 */ 301, 304, 466, 305, 1522, 307, 1521, 309, 1506, 141, + /* 1230 */ 312, 313, 465, 1069, 1068, 1500, 1535, 437, 1040, 274, + /* 1240 */ 1499, 1563, 1111, 319, 318, 1498, 1497, 1474, 1473, 1472, + /* 1250 */ 1471, 1470, 1469, 1468, 246, 1564, 468, 1566, 1567, 464, + /* 1260 */ 1467, 459, 1466, 1114, 1465, 1579, 1464, 1463, 1462, 1461, + /* 1270 */ 1460, 1459, 463, 108, 1458, 1457, 1456, 1455, 1454, 1563, + /* 1280 */ 1453, 1042, 465, 1452, 1451, 1450, 1535, 1449, 1330, 1514, + /* 1290 */ 1563, 1508, 1496, 1487, 1378, 898, 1329, 154, 1327, 361, + /* 1300 */ 363, 362, 1325, 1579, 245, 1564, 468, 1566, 1567, 464, + /* 1310 */ 466, 459, 1323, 1602, 1579, 367, 371, 365, 366, 369, + /* 1320 */ 465, 466, 370, 1321, 1535, 1310, 1309, 276, 373, 1306, + /* 1330 */ 1380, 465, 1006, 374, 530, 1535, 161, 1009, 278, 1279, + /* 1340 */ 1379, 76, 246, 1564, 468, 1566, 1567, 464, 1563, 459, + /* 1350 */ 1319, 375, 930, 246, 1564, 468, 1566, 1567, 464, 929, + /* 1360 */ 459, 1563, 928, 96, 95, 94, 93, 92, 91, 90, + /* 1370 */ 89, 88, 1579, 927, 532, 924, 923, 262, 1314, 466, + /* 1380 */ 263, 399, 1312, 264, 402, 1579, 1305, 404, 1304, 465, + /* 1390 */ 406, 75, 466, 1535, 1513, 1076, 1507, 413, 1495, 1563, + /* 1400 */ 1494, 1486, 465, 181, 3, 56, 1535, 119, 1563, 13, + /* 1410 */ 126, 234, 1564, 468, 1566, 1567, 464, 190, 459, 35, + /* 1420 */ 41, 14, 186, 1579, 240, 1564, 468, 1566, 1567, 464, + /* 1430 */ 466, 459, 1579, 46, 1238, 191, 178, 20, 414, 466, + /* 1440 */ 465, 1231, 40, 57, 1535, 21, 1563, 1210, 1554, 465, + /* 1450 */ 183, 1209, 39, 1535, 1265, 15, 197, 58, 1260, 135, + /* 1460 */ 1259, 1563, 242, 1564, 468, 1566, 1567, 464, 272, 459, + /* 1470 */ 1579, 235, 1564, 468, 1566, 1567, 464, 466, 459, 1264, + /* 1480 */ 1263, 273, 8, 1173, 17, 1579, 1155, 465, 458, 138, + /* 1490 */ 1154, 1535, 466, 27, 204, 1140, 1153, 10, 18, 19, + /* 1500 */ 38, 467, 465, 205, 1236, 1485, 1535, 11, 207, 243, + /* 1510 */ 1564, 468, 1566, 1567, 464, 211, 459, 64, 209, 473, + /* 1520 */ 59, 60, 213, 1553, 236, 1564, 468, 1566, 1567, 464, + /* 1530 */ 1563, 459, 1112, 42, 216, 484, 991, 486, 1563, 286, + /* 1540 */ 488, 490, 988, 491, 493, 985, 979, 496, 494, 497, + /* 1550 */ 499, 977, 968, 500, 1579, 983, 982, 981, 65, 980, + /* 1560 */ 1003, 466, 1579, 1002, 506, 66, 67, 999, 1563, 466, + /* 1570 */ 996, 465, 896, 517, 937, 1535, 519, 919, 218, 465, + /* 1580 */ 918, 917, 916, 1535, 915, 914, 912, 913, 932, 934, + /* 1590 */ 909, 908, 1579, 244, 1564, 468, 1566, 1567, 464, 466, + /* 1600 */ 459, 237, 1564, 468, 1566, 1567, 464, 1326, 459, 465, + /* 1610 */ 907, 904, 903, 1535, 902, 901, 1563, 541, 542, 1324, + /* 1620 */ 1322, 543, 545, 546, 547, 550, 549, 1320, 551, 553, + /* 1630 */ 554, 1575, 1564, 468, 1566, 1567, 464, 1308, 459, 555, + /* 1640 */ 1579, 557, 558, 1307, 1303, 561, 562, 466, 1098, 566, + /* 1650 */ 227, 565, 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, + /* 1660 */ 1278, 1535, 1278, 1563, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1670 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1579, 1574, + /* 1680 */ 1564, 468, 1566, 1567, 464, 466, 459, 1579, 1278, 1278, + /* 1690 */ 1278, 1278, 1278, 1278, 466, 465, 1278, 1278, 1278, 1535, + /* 1700 */ 1278, 1563, 1278, 1278, 465, 1278, 1278, 1278, 1535, 1278, + /* 1710 */ 1278, 1278, 1278, 1278, 1278, 1278, 1563, 1573, 1564, 468, + /* 1720 */ 1566, 1567, 464, 1278, 459, 1579, 253, 1564, 468, 1566, + /* 1730 */ 1567, 464, 466, 459, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1740 */ 1579, 1278, 465, 1278, 1278, 1278, 1535, 466, 1278, 1278, + /* 1750 */ 1278, 1278, 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, + /* 1760 */ 1278, 1535, 1278, 1278, 252, 1564, 468, 1566, 1567, 464, + /* 1770 */ 1278, 459, 1278, 1278, 1278, 1278, 1278, 1278, 1579, 254, + /* 1780 */ 1564, 468, 1566, 1567, 464, 466, 459, 1278, 1278, 1278, + /* 1790 */ 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, 1278, 1535, + /* 1800 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1810 */ 1278, 1278, 1278, 1278, 1278, 1278, 1579, 251, 1564, 468, + /* 1820 */ 1566, 1567, 464, 466, 459, 1278, 1278, 1278, 1278, 1278, + /* 1830 */ 1278, 1278, 1278, 465, 1278, 1278, 1278, 1535, 1278, 1278, + /* 1840 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1850 */ 1278, 1278, 1278, 1278, 1278, 239, 1564, 468, 1566, 1567, + /* 1860 */ 464, 1278, 459, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 222, 311, 247, 222, 250, 296, 297, 228, 228, 219, - /* 10 */ 263, 267, 12, 13, 324, 222, 269, 237, 328, 222, - /* 20 */ 20, 267, 22, 250, 244, 281, 282, 246, 12, 13, - /* 30 */ 14, 15, 16, 253, 253, 281, 282, 258, 38, 246, - /* 40 */ 267, 20, 230, 228, 263, 267, 253, 228, 267, 20, - /* 50 */ 50, 12, 13, 14, 281, 282, 263, 57, 20, 20, - /* 60 */ 267, 22, 272, 251, 267, 272, 285, 286, 287, 288, - /* 70 */ 289, 290, 253, 292, 74, 228, 49, 38, 285, 286, - /* 80 */ 287, 288, 289, 290, 237, 292, 0, 272, 295, 50, - /* 90 */ 228, 75, 299, 300, 231, 74, 57, 97, 235, 237, - /* 100 */ 253, 311, 12, 13, 311, 221, 244, 223, 289, 109, - /* 110 */ 20, 330, 22, 74, 324, 253, 0, 324, 328, 20, - /* 120 */ 2, 328, 303, 304, 305, 306, 311, 308, 38, 0, - /* 130 */ 12, 13, 14, 15, 16, 49, 97, 0, 246, 324, - /* 140 */ 50, 225, 226, 328, 252, 246, 146, 57, 109, 257, - /* 150 */ 21, 245, 253, 24, 25, 26, 27, 28, 29, 30, - /* 160 */ 31, 32, 256, 263, 74, 49, 266, 167, 168, 269, + /* 0 */ 223, 312, 248, 223, 251, 297, 298, 229, 229, 220, + /* 10 */ 264, 268, 12, 13, 325, 223, 270, 238, 329, 223, + /* 20 */ 20, 268, 22, 251, 245, 282, 283, 247, 12, 13, + /* 30 */ 14, 15, 16, 254, 254, 282, 283, 259, 38, 247, + /* 40 */ 268, 20, 231, 229, 264, 268, 254, 229, 268, 223, + /* 50 */ 50, 12, 13, 14, 282, 283, 264, 57, 20, 20, + /* 60 */ 268, 22, 273, 252, 268, 273, 286, 287, 288, 289, + /* 70 */ 290, 291, 254, 293, 74, 229, 49, 38, 286, 287, + /* 80 */ 288, 289, 290, 291, 238, 293, 0, 273, 296, 50, + /* 90 */ 229, 75, 300, 301, 268, 74, 57, 97, 228, 238, + /* 100 */ 254, 312, 12, 13, 312, 222, 245, 224, 290, 109, + /* 110 */ 20, 331, 22, 74, 325, 254, 0, 325, 329, 249, + /* 120 */ 2, 329, 304, 305, 306, 307, 312, 309, 38, 0, + /* 130 */ 12, 13, 14, 15, 16, 49, 97, 0, 247, 325, + /* 140 */ 50, 20, 20, 329, 253, 247, 146, 57, 109, 258, + /* 150 */ 21, 246, 254, 24, 25, 26, 27, 28, 29, 30, + /* 160 */ 31, 32, 257, 264, 74, 49, 267, 167, 168, 270, /* 170 */ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - /* 180 */ 180, 181, 182, 183, 230, 146, 287, 97, 136, 52, - /* 190 */ 145, 54, 147, 222, 20, 58, 196, 243, 61, 109, - /* 200 */ 63, 64, 222, 66, 283, 251, 167, 168, 22, 170, + /* 180 */ 180, 181, 182, 183, 184, 146, 288, 97, 136, 52, + /* 190 */ 145, 54, 147, 226, 227, 58, 74, 197, 61, 109, + /* 200 */ 63, 64, 197, 66, 155, 156, 167, 168, 159, 170, /* 210 */ 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, - /* 220 */ 181, 182, 183, 61, 38, 196, 228, 65, 307, 12, - /* 230 */ 13, 12, 13, 14, 15, 16, 146, 20, 267, 22, - /* 240 */ 38, 196, 12, 13, 14, 15, 16, 267, 74, 87, - /* 250 */ 196, 253, 0, 201, 202, 38, 228, 167, 168, 57, + /* 220 */ 181, 182, 183, 184, 229, 229, 229, 229, 229, 38, + /* 230 */ 12, 13, 71, 238, 238, 238, 146, 238, 20, 20, + /* 240 */ 22, 22, 197, 12, 13, 14, 15, 16, 57, 254, + /* 250 */ 254, 254, 254, 254, 202, 203, 38, 167, 168, 40, /* 260 */ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - /* 270 */ 180, 181, 182, 183, 57, 12, 13, 14, 155, 156, - /* 280 */ 50, 253, 159, 20, 20, 22, 0, 289, 36, 21, - /* 290 */ 222, 74, 24, 25, 26, 27, 28, 29, 30, 31, - /* 300 */ 32, 38, 304, 305, 306, 75, 308, 238, 1, 2, - /* 310 */ 52, 20, 54, 83, 97, 246, 58, 289, 20, 61, - /* 320 */ 57, 63, 64, 254, 66, 272, 109, 167, 14, 15, - /* 330 */ 16, 35, 304, 305, 306, 267, 308, 74, 52, 53, - /* 340 */ 54, 55, 56, 20, 58, 59, 60, 61, 62, 63, - /* 350 */ 64, 65, 66, 67, 68, 69, 70, 61, 232, 233, - /* 360 */ 97, 65, 132, 146, 311, 205, 206, 207, 208, 209, - /* 370 */ 196, 239, 109, 77, 242, 79, 80, 324, 82, 222, - /* 380 */ 150, 328, 75, 87, 167, 168, 3, 170, 171, 172, - /* 390 */ 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, - /* 400 */ 183, 71, 12, 13, 12, 13, 14, 15, 16, 146, - /* 410 */ 20, 227, 22, 196, 184, 185, 186, 187, 188, 189, - /* 420 */ 190, 191, 192, 193, 267, 241, 47, 272, 38, 138, - /* 430 */ 167, 168, 248, 170, 171, 172, 173, 174, 175, 176, - /* 440 */ 177, 178, 179, 180, 181, 182, 183, 57, 12, 13, - /* 450 */ 12, 13, 73, 4, 255, 76, 20, 246, 22, 2, - /* 460 */ 22, 262, 263, 252, 74, 4, 311, 246, 257, 12, - /* 470 */ 13, 14, 15, 16, 38, 228, 38, 222, 257, 324, - /* 480 */ 19, 283, 238, 328, 237, 71, 20, 97, 22, 75, - /* 490 */ 246, 232, 233, 57, 33, 57, 67, 36, 254, 109, - /* 500 */ 253, 222, 41, 43, 222, 307, 40, 234, 47, 236, - /* 510 */ 74, 88, 89, 90, 91, 92, 93, 94, 95, 96, - /* 520 */ 97, 98, 267, 100, 101, 102, 103, 104, 105, 18, - /* 530 */ 138, 20, 238, 97, 73, 97, 146, 76, 27, 49, - /* 540 */ 246, 30, 113, 114, 214, 109, 267, 109, 254, 267, - /* 550 */ 39, 12, 13, 14, 15, 16, 222, 167, 168, 283, - /* 560 */ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - /* 570 */ 180, 181, 182, 183, 12, 13, 14, 15, 16, 132, - /* 580 */ 222, 85, 146, 307, 146, 232, 233, 232, 233, 50, - /* 590 */ 12, 13, 14, 15, 16, 212, 20, 150, 1, 2, - /* 600 */ 227, 267, 222, 167, 168, 167, 170, 171, 172, 173, - /* 610 */ 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, - /* 620 */ 222, 248, 83, 112, 57, 267, 115, 116, 117, 118, - /* 630 */ 119, 184, 121, 122, 123, 124, 125, 126, 127, 128, - /* 640 */ 129, 130, 131, 228, 246, 228, 197, 267, 228, 19, - /* 650 */ 246, 253, 237, 75, 237, 195, 246, 237, 254, 194, - /* 660 */ 195, 263, 252, 33, 222, 267, 36, 257, 253, 228, - /* 670 */ 253, 132, 42, 253, 44, 45, 46, 47, 237, 157, - /* 680 */ 158, 246, 275, 285, 286, 287, 288, 289, 290, 150, - /* 690 */ 292, 228, 257, 295, 253, 228, 223, 299, 300, 301, - /* 700 */ 237, 139, 222, 73, 237, 222, 76, 71, 253, 267, - /* 710 */ 222, 313, 228, 228, 138, 260, 253, 319, 320, 247, - /* 720 */ 253, 237, 237, 184, 185, 186, 187, 188, 189, 190, - /* 730 */ 191, 192, 193, 14, 246, 0, 106, 253, 253, 20, - /* 740 */ 228, 253, 78, 142, 50, 81, 222, 267, 222, 237, - /* 750 */ 267, 263, 222, 222, 14, 267, 222, 22, 21, 331, - /* 760 */ 20, 247, 161, 78, 134, 253, 81, 137, 222, 78, - /* 770 */ 247, 34, 81, 285, 286, 287, 288, 289, 290, 217, - /* 780 */ 292, 322, 152, 295, 154, 0, 74, 299, 300, 301, - /* 790 */ 0, 267, 246, 267, 181, 182, 84, 267, 267, 253, - /* 800 */ 78, 267, 0, 81, 247, 247, 247, 22, 320, 263, - /* 810 */ 235, 256, 279, 267, 24, 25, 26, 27, 28, 29, - /* 820 */ 30, 31, 32, 71, 22, 71, 222, 75, 225, 75, - /* 830 */ 74, 285, 286, 287, 288, 289, 290, 316, 292, 71, - /* 840 */ 284, 295, 86, 75, 71, 299, 300, 301, 75, 309, - /* 850 */ 246, 71, 216, 18, 38, 75, 310, 253, 23, 71, - /* 860 */ 71, 167, 38, 75, 75, 246, 33, 263, 38, 36, - /* 870 */ 35, 267, 71, 57, 325, 42, 75, 44, 45, 46, - /* 880 */ 47, 71, 312, 48, 222, 75, 20, 228, 36, 285, - /* 890 */ 286, 287, 288, 289, 290, 280, 292, 71, 38, 295, - /* 900 */ 232, 75, 144, 299, 300, 301, 73, 71, 246, 76, - /* 910 */ 273, 75, 228, 71, 310, 253, 71, 75, 71, 71, - /* 920 */ 75, 228, 75, 75, 71, 263, 120, 261, 75, 267, - /* 930 */ 132, 259, 259, 109, 228, 277, 20, 230, 263, 109, - /* 940 */ 222, 20, 271, 230, 20, 253, 111, 285, 286, 287, - /* 950 */ 288, 289, 290, 222, 292, 230, 230, 295, 228, 264, - /* 960 */ 20, 299, 300, 301, 246, 224, 133, 246, 135, 230, - /* 970 */ 137, 253, 310, 246, 139, 140, 141, 246, 143, 246, - /* 980 */ 246, 263, 246, 148, 253, 267, 224, 154, 246, 246, - /* 990 */ 272, 222, 246, 246, 263, 160, 246, 162, 267, 164, - /* 1000 */ 165, 166, 228, 285, 286, 287, 288, 289, 290, 228, - /* 1010 */ 292, 246, 57, 227, 153, 246, 285, 286, 287, 288, - /* 1020 */ 289, 290, 253, 292, 267, 294, 277, 276, 253, 311, - /* 1030 */ 263, 196, 263, 20, 253, 271, 267, 284, 227, 227, - /* 1040 */ 264, 204, 324, 203, 321, 268, 328, 268, 210, 222, - /* 1050 */ 267, 267, 211, 272, 285, 286, 287, 288, 289, 290, - /* 1060 */ 267, 292, 199, 318, 295, 321, 198, 195, 299, 300, - /* 1070 */ 289, 253, 317, 246, 315, 314, 20, 283, 120, 222, - /* 1080 */ 253, 74, 218, 213, 302, 304, 305, 306, 215, 308, - /* 1090 */ 263, 268, 311, 327, 267, 332, 326, 298, 267, 267, - /* 1100 */ 242, 135, 268, 246, 253, 324, 267, 227, 265, 328, - /* 1110 */ 253, 227, 285, 286, 287, 288, 289, 290, 264, 292, - /* 1120 */ 263, 74, 295, 249, 267, 236, 299, 300, 222, 253, - /* 1130 */ 228, 227, 224, 274, 278, 240, 240, 222, 229, 22, - /* 1140 */ 220, 0, 285, 286, 287, 288, 289, 290, 291, 292, - /* 1150 */ 293, 294, 246, 0, 64, 38, 0, 38, 163, 253, - /* 1160 */ 38, 246, 38, 38, 163, 0, 38, 38, 253, 263, - /* 1170 */ 38, 163, 0, 267, 57, 222, 0, 38, 263, 0, - /* 1180 */ 74, 150, 267, 149, 109, 146, 0, 222, 0, 53, - /* 1190 */ 142, 285, 286, 287, 288, 289, 290, 0, 292, 246, - /* 1200 */ 285, 286, 287, 288, 289, 290, 253, 292, 0, 0, - /* 1210 */ 295, 246, 86, 0, 97, 300, 263, 0, 253, 0, - /* 1220 */ 267, 120, 0, 270, 0, 0, 109, 0, 263, 0, - /* 1230 */ 0, 0, 267, 0, 0, 329, 330, 0, 285, 286, - /* 1240 */ 287, 288, 289, 290, 0, 292, 222, 0, 0, 0, - /* 1250 */ 285, 286, 287, 288, 289, 290, 0, 292, 0, 222, - /* 1260 */ 0, 0, 22, 146, 0, 0, 0, 0, 0, 0, - /* 1270 */ 246, 43, 0, 0, 51, 0, 38, 253, 0, 0, - /* 1280 */ 0, 36, 43, 246, 167, 168, 0, 263, 323, 38, - /* 1290 */ 253, 267, 0, 36, 270, 43, 43, 38, 36, 0, - /* 1300 */ 263, 38, 0, 0, 267, 0, 36, 270, 0, 285, - /* 1310 */ 286, 287, 288, 289, 290, 83, 292, 222, 22, 43, - /* 1320 */ 38, 0, 285, 286, 287, 288, 289, 290, 38, 292, - /* 1330 */ 0, 81, 38, 222, 22, 38, 38, 0, 38, 22, - /* 1340 */ 0, 246, 38, 0, 22, 222, 39, 38, 253, 22, - /* 1350 */ 0, 22, 71, 20, 71, 0, 138, 246, 263, 0, - /* 1360 */ 22, 38, 267, 151, 253, 270, 0, 0, 0, 246, - /* 1370 */ 75, 135, 194, 138, 263, 43, 253, 71, 267, 0, - /* 1380 */ 285, 286, 287, 288, 289, 290, 263, 292, 74, 71, - /* 1390 */ 267, 200, 222, 138, 75, 71, 285, 286, 287, 288, - /* 1400 */ 289, 290, 74, 292, 200, 222, 75, 133, 285, 286, - /* 1410 */ 287, 288, 289, 290, 75, 292, 246, 71, 74, 74, - /* 1420 */ 86, 74, 71, 253, 71, 71, 200, 75, 86, 246, - /* 1430 */ 4, 75, 38, 263, 86, 38, 253, 267, 0, 38, - /* 1440 */ 61, 38, 38, 222, 65, 38, 263, 2, 71, 75, - /* 1450 */ 267, 167, 74, 22, 74, 285, 286, 287, 288, 289, - /* 1460 */ 290, 75, 292, 75, 75, 74, 87, 246, 285, 286, - /* 1470 */ 287, 288, 289, 290, 253, 292, 86, 75, 86, 74, - /* 1480 */ 169, 0, 74, 74, 263, 106, 107, 108, 267, 110, - /* 1490 */ 74, 74, 43, 222, 133, 74, 136, 84, 86, 61, - /* 1500 */ 86, 22, 74, 65, 85, 75, 285, 286, 287, 288, - /* 1510 */ 289, 290, 38, 292, 38, 74, 38, 246, 75, 75, - /* 1520 */ 74, 38, 74, 222, 253, 87, 75, 38, 74, 38, - /* 1530 */ 75, 74, 99, 22, 263, 99, 99, 87, 267, 99, - /* 1540 */ 74, 38, 74, 74, 106, 107, 108, 246, 110, 22, - /* 1550 */ 38, 109, 51, 57, 253, 50, 285, 286, 287, 288, - /* 1560 */ 289, 290, 72, 292, 263, 22, 71, 38, 267, 38, - /* 1570 */ 38, 222, 38, 38, 38, 38, 57, 38, 38, 38, - /* 1580 */ 222, 43, 38, 38, 38, 38, 285, 286, 287, 288, - /* 1590 */ 289, 290, 38, 292, 0, 246, 38, 36, 0, 36, - /* 1600 */ 38, 0, 253, 43, 246, 38, 36, 43, 0, 38, - /* 1610 */ 36, 253, 263, 0, 38, 43, 267, 37, 0, 0, - /* 1620 */ 21, 263, 22, 20, 22, 267, 22, 21, 222, 333, - /* 1630 */ 333, 333, 333, 333, 285, 286, 287, 288, 289, 290, - /* 1640 */ 333, 292, 333, 285, 286, 287, 288, 289, 290, 333, - /* 1650 */ 292, 333, 246, 333, 333, 333, 222, 333, 333, 253, - /* 1660 */ 333, 333, 333, 333, 333, 333, 333, 333, 333, 263, - /* 1670 */ 333, 333, 333, 267, 333, 333, 333, 333, 333, 333, - /* 1680 */ 246, 333, 333, 333, 333, 333, 333, 253, 333, 333, - /* 1690 */ 333, 285, 286, 287, 288, 289, 290, 263, 292, 333, - /* 1700 */ 333, 267, 333, 333, 333, 333, 333, 222, 333, 333, - /* 1710 */ 333, 333, 333, 333, 333, 333, 222, 333, 333, 285, - /* 1720 */ 286, 287, 288, 289, 290, 333, 292, 333, 333, 333, - /* 1730 */ 333, 246, 333, 333, 333, 333, 333, 333, 253, 333, - /* 1740 */ 246, 333, 333, 333, 333, 333, 333, 253, 263, 333, - /* 1750 */ 333, 333, 267, 333, 333, 333, 333, 263, 333, 333, - /* 1760 */ 333, 267, 333, 333, 333, 333, 333, 333, 333, 333, - /* 1770 */ 285, 286, 287, 288, 289, 290, 333, 292, 333, 285, - /* 1780 */ 286, 287, 288, 289, 290, 333, 292, 222, 333, 333, - /* 1790 */ 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - /* 1800 */ 333, 333, 333, 222, 333, 333, 333, 333, 333, 333, - /* 1810 */ 333, 246, 333, 333, 333, 333, 333, 333, 253, 333, - /* 1820 */ 333, 333, 333, 333, 333, 333, 333, 246, 263, 333, - /* 1830 */ 333, 333, 267, 333, 253, 333, 333, 333, 333, 333, - /* 1840 */ 333, 333, 333, 333, 263, 333, 333, 333, 267, 333, - /* 1850 */ 285, 286, 287, 288, 289, 290, 333, 292, 222, 333, - /* 1860 */ 333, 333, 333, 333, 333, 333, 285, 286, 287, 288, - /* 1870 */ 289, 290, 333, 292, 333, 333, 333, 333, 333, 333, - /* 1880 */ 333, 333, 246, 333, 333, 333, 333, 333, 333, 253, - /* 1890 */ 333, 333, 333, 333, 333, 333, 333, 333, 333, 263, - /* 1900 */ 333, 333, 333, 267, 333, 333, 333, 333, 333, 333, - /* 1910 */ 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - /* 1920 */ 333, 285, 286, 287, 288, 289, 290, 333, 292, + /* 270 */ 180, 181, 182, 183, 184, 57, 12, 13, 14, 233, + /* 280 */ 234, 50, 67, 47, 20, 223, 22, 0, 290, 235, + /* 290 */ 21, 237, 74, 24, 25, 26, 27, 28, 29, 30, + /* 300 */ 31, 32, 38, 305, 306, 307, 75, 309, 239, 73, + /* 310 */ 20, 52, 76, 54, 83, 97, 247, 58, 197, 197, + /* 320 */ 61, 57, 63, 64, 255, 66, 167, 109, 113, 114, + /* 330 */ 268, 273, 35, 12, 13, 14, 15, 16, 74, 52, + /* 340 */ 53, 54, 55, 56, 22, 58, 59, 60, 61, 62, + /* 350 */ 63, 64, 65, 66, 67, 68, 69, 70, 61, 231, + /* 360 */ 38, 97, 65, 132, 146, 206, 207, 208, 209, 210, + /* 370 */ 312, 232, 244, 109, 77, 236, 79, 80, 217, 82, + /* 380 */ 252, 150, 20, 325, 87, 167, 168, 329, 170, 171, + /* 390 */ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + /* 400 */ 182, 183, 184, 229, 12, 13, 233, 234, 229, 71, + /* 410 */ 146, 20, 20, 75, 22, 197, 185, 186, 187, 188, + /* 420 */ 189, 190, 191, 192, 193, 194, 233, 234, 254, 50, + /* 430 */ 38, 167, 168, 254, 170, 171, 172, 173, 174, 175, + /* 440 */ 176, 177, 178, 179, 180, 181, 182, 183, 184, 57, + /* 450 */ 12, 13, 273, 229, 273, 239, 228, 22, 20, 138, + /* 460 */ 22, 247, 238, 247, 290, 20, 74, 253, 38, 290, + /* 470 */ 242, 255, 258, 38, 1, 2, 38, 249, 254, 305, + /* 480 */ 306, 307, 71, 309, 305, 306, 307, 57, 309, 97, + /* 490 */ 0, 312, 57, 312, 223, 57, 12, 13, 14, 15, + /* 500 */ 16, 109, 0, 20, 325, 223, 325, 49, 329, 223, + /* 510 */ 329, 223, 74, 88, 89, 90, 91, 92, 93, 94, + /* 520 */ 95, 96, 97, 98, 22, 100, 101, 102, 103, 104, + /* 530 */ 105, 18, 97, 20, 256, 97, 229, 85, 146, 268, + /* 540 */ 27, 263, 264, 30, 109, 238, 167, 109, 75, 223, + /* 550 */ 268, 61, 39, 61, 268, 65, 268, 65, 0, 167, + /* 560 */ 168, 254, 170, 171, 172, 173, 174, 175, 176, 177, + /* 570 */ 178, 179, 180, 181, 182, 183, 184, 87, 254, 87, + /* 580 */ 22, 146, 229, 138, 146, 261, 12, 13, 14, 15, + /* 590 */ 16, 238, 240, 247, 268, 243, 106, 107, 108, 253, + /* 600 */ 110, 57, 167, 168, 258, 167, 168, 254, 170, 171, + /* 610 */ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + /* 620 */ 182, 183, 184, 223, 50, 112, 215, 223, 115, 116, + /* 630 */ 117, 118, 119, 248, 121, 122, 123, 124, 125, 126, + /* 640 */ 127, 128, 129, 130, 131, 3, 229, 247, 12, 13, + /* 650 */ 14, 15, 16, 229, 254, 238, 19, 83, 132, 239, + /* 660 */ 229, 248, 238, 223, 264, 233, 234, 247, 268, 238, + /* 670 */ 33, 254, 268, 36, 223, 255, 150, 223, 254, 42, + /* 680 */ 223, 44, 45, 46, 47, 254, 286, 287, 288, 289, + /* 690 */ 290, 291, 20, 293, 195, 196, 296, 43, 247, 284, + /* 700 */ 300, 301, 302, 223, 223, 254, 132, 247, 268, 223, + /* 710 */ 73, 185, 223, 76, 314, 264, 2, 248, 258, 268, + /* 720 */ 320, 321, 268, 308, 150, 268, 12, 13, 14, 15, + /* 730 */ 16, 14, 15, 16, 247, 223, 4, 286, 287, 288, + /* 740 */ 289, 290, 291, 106, 293, 258, 284, 296, 268, 268, + /* 750 */ 14, 300, 301, 302, 268, 223, 20, 268, 4, 185, + /* 760 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 223, + /* 770 */ 308, 134, 321, 19, 137, 139, 0, 0, 284, 247, + /* 780 */ 268, 12, 13, 14, 15, 16, 254, 33, 14, 152, + /* 790 */ 36, 154, 223, 248, 20, 41, 264, 247, 142, 22, + /* 800 */ 268, 47, 308, 78, 78, 255, 81, 81, 157, 158, + /* 810 */ 138, 223, 36, 78, 268, 248, 81, 161, 286, 287, + /* 820 */ 288, 289, 290, 291, 248, 293, 78, 73, 296, 81, + /* 830 */ 76, 276, 300, 301, 302, 247, 0, 268, 21, 224, + /* 840 */ 18, 223, 254, 311, 75, 23, 1, 2, 236, 71, + /* 850 */ 196, 34, 264, 75, 218, 213, 268, 35, 71, 71, + /* 860 */ 182, 183, 75, 75, 71, 247, 332, 257, 75, 71, + /* 870 */ 48, 223, 254, 75, 286, 287, 288, 289, 290, 291, + /* 880 */ 74, 293, 264, 323, 296, 38, 268, 280, 300, 301, + /* 890 */ 302, 226, 86, 38, 71, 247, 317, 61, 75, 311, + /* 900 */ 74, 65, 254, 310, 286, 287, 288, 289, 290, 291, + /* 910 */ 84, 293, 264, 71, 296, 285, 268, 75, 300, 301, + /* 920 */ 302, 273, 247, 87, 71, 326, 223, 71, 75, 311, + /* 930 */ 198, 75, 313, 111, 286, 287, 288, 289, 290, 291, + /* 940 */ 20, 293, 106, 107, 108, 71, 110, 71, 71, 75, + /* 950 */ 247, 75, 75, 229, 36, 281, 109, 254, 144, 274, + /* 960 */ 312, 139, 140, 141, 109, 143, 38, 264, 120, 229, + /* 970 */ 148, 268, 233, 325, 71, 229, 223, 329, 75, 71, + /* 980 */ 262, 71, 160, 75, 162, 75, 164, 165, 166, 286, + /* 990 */ 287, 288, 289, 290, 291, 132, 293, 260, 71, 296, + /* 1000 */ 247, 260, 75, 300, 301, 20, 278, 254, 229, 264, + /* 1010 */ 20, 231, 231, 254, 272, 20, 265, 264, 229, 197, + /* 1020 */ 33, 268, 231, 36, 223, 231, 231, 20, 225, 42, + /* 1030 */ 247, 44, 45, 46, 47, 223, 229, 247, 225, 286, + /* 1040 */ 287, 288, 289, 290, 291, 57, 293, 247, 247, 296, + /* 1050 */ 268, 247, 247, 300, 301, 254, 247, 247, 247, 247, + /* 1060 */ 73, 228, 247, 76, 278, 264, 254, 247, 247, 268, + /* 1070 */ 153, 272, 264, 277, 228, 20, 264, 228, 254, 322, + /* 1080 */ 268, 265, 285, 205, 204, 322, 268, 286, 287, 288, + /* 1090 */ 289, 290, 291, 292, 293, 294, 295, 269, 286, 287, + /* 1100 */ 288, 289, 290, 291, 269, 293, 223, 268, 12, 13, + /* 1110 */ 212, 268, 211, 254, 200, 199, 284, 20, 22, 196, + /* 1120 */ 133, 319, 135, 120, 137, 219, 214, 216, 74, 269, + /* 1130 */ 247, 269, 303, 268, 38, 316, 223, 254, 268, 299, + /* 1140 */ 315, 154, 330, 331, 223, 318, 135, 264, 266, 268, + /* 1150 */ 254, 268, 265, 57, 228, 74, 254, 228, 243, 328, + /* 1160 */ 247, 327, 237, 333, 229, 228, 225, 254, 247, 286, + /* 1170 */ 287, 288, 289, 290, 291, 254, 293, 264, 279, 296, + /* 1180 */ 250, 268, 275, 241, 301, 264, 241, 230, 221, 268, + /* 1190 */ 0, 223, 271, 97, 0, 64, 0, 38, 163, 286, + /* 1200 */ 287, 288, 289, 290, 291, 109, 293, 286, 287, 288, + /* 1210 */ 289, 290, 291, 38, 293, 247, 38, 38, 0, 38, + /* 1220 */ 163, 38, 254, 163, 0, 38, 0, 38, 0, 74, + /* 1230 */ 150, 149, 264, 109, 146, 0, 268, 324, 86, 271, + /* 1240 */ 0, 223, 146, 142, 53, 0, 0, 0, 0, 0, + /* 1250 */ 0, 0, 0, 0, 286, 287, 288, 289, 290, 291, + /* 1260 */ 0, 293, 0, 167, 0, 247, 0, 0, 0, 0, + /* 1270 */ 0, 0, 254, 120, 0, 0, 0, 0, 0, 223, + /* 1280 */ 0, 22, 264, 0, 0, 0, 268, 0, 0, 0, + /* 1290 */ 223, 0, 0, 0, 0, 51, 0, 43, 0, 38, + /* 1300 */ 43, 36, 0, 247, 286, 287, 288, 289, 290, 291, + /* 1310 */ 254, 293, 0, 295, 247, 43, 43, 38, 36, 38, + /* 1320 */ 264, 254, 36, 0, 268, 0, 0, 271, 38, 0, + /* 1330 */ 0, 264, 22, 36, 71, 268, 81, 38, 271, 0, + /* 1340 */ 0, 83, 286, 287, 288, 289, 290, 291, 223, 293, + /* 1350 */ 0, 43, 38, 286, 287, 288, 289, 290, 291, 38, + /* 1360 */ 293, 223, 38, 24, 25, 26, 27, 28, 29, 30, + /* 1370 */ 31, 32, 247, 38, 71, 38, 38, 22, 0, 254, + /* 1380 */ 22, 39, 0, 22, 38, 247, 0, 22, 0, 264, + /* 1390 */ 22, 20, 254, 268, 0, 38, 0, 22, 0, 223, + /* 1400 */ 0, 0, 264, 43, 71, 74, 268, 151, 223, 201, + /* 1410 */ 74, 286, 287, 288, 289, 290, 291, 74, 293, 71, + /* 1420 */ 71, 201, 75, 247, 286, 287, 288, 289, 290, 291, + /* 1430 */ 254, 293, 247, 138, 75, 71, 135, 74, 138, 254, + /* 1440 */ 264, 75, 138, 74, 268, 71, 223, 75, 86, 264, + /* 1450 */ 133, 75, 71, 268, 75, 71, 86, 4, 38, 86, + /* 1460 */ 38, 223, 286, 287, 288, 289, 290, 291, 38, 293, + /* 1470 */ 247, 286, 287, 288, 289, 290, 291, 254, 293, 38, + /* 1480 */ 38, 38, 2, 167, 71, 247, 75, 264, 74, 86, + /* 1490 */ 75, 268, 254, 74, 86, 22, 75, 74, 74, 74, + /* 1500 */ 195, 169, 264, 75, 75, 0, 268, 201, 74, 286, + /* 1510 */ 287, 288, 289, 290, 291, 43, 293, 84, 74, 136, + /* 1520 */ 74, 74, 133, 86, 286, 287, 288, 289, 290, 291, + /* 1530 */ 223, 293, 22, 74, 86, 85, 75, 38, 223, 38, + /* 1540 */ 74, 38, 75, 74, 38, 75, 75, 38, 74, 74, + /* 1550 */ 38, 75, 22, 74, 247, 99, 99, 99, 74, 99, + /* 1560 */ 38, 254, 247, 109, 87, 74, 74, 38, 223, 254, + /* 1570 */ 22, 264, 51, 50, 57, 268, 72, 38, 71, 264, + /* 1580 */ 38, 38, 38, 268, 38, 38, 22, 38, 38, 57, + /* 1590 */ 38, 38, 247, 286, 287, 288, 289, 290, 291, 254, + /* 1600 */ 293, 286, 287, 288, 289, 290, 291, 0, 293, 264, + /* 1610 */ 38, 38, 38, 268, 38, 38, 223, 38, 36, 0, + /* 1620 */ 0, 43, 38, 36, 43, 36, 38, 0, 43, 38, + /* 1630 */ 36, 286, 287, 288, 289, 290, 291, 0, 293, 43, + /* 1640 */ 247, 38, 37, 0, 0, 22, 21, 254, 22, 20, + /* 1650 */ 22, 21, 334, 334, 223, 334, 334, 264, 334, 334, + /* 1660 */ 334, 268, 334, 223, 334, 334, 334, 334, 334, 334, + /* 1670 */ 334, 334, 334, 334, 334, 334, 334, 334, 247, 286, + /* 1680 */ 287, 288, 289, 290, 291, 254, 293, 247, 334, 334, + /* 1690 */ 334, 334, 334, 334, 254, 264, 334, 334, 334, 268, + /* 1700 */ 334, 223, 334, 334, 264, 334, 334, 334, 268, 334, + /* 1710 */ 334, 334, 334, 334, 334, 334, 223, 286, 287, 288, + /* 1720 */ 289, 290, 291, 334, 293, 247, 286, 287, 288, 289, + /* 1730 */ 290, 291, 254, 293, 334, 334, 334, 334, 334, 334, + /* 1740 */ 247, 334, 264, 334, 334, 334, 268, 254, 334, 334, + /* 1750 */ 334, 334, 334, 334, 223, 334, 334, 264, 334, 334, + /* 1760 */ 334, 268, 334, 334, 286, 287, 288, 289, 290, 291, + /* 1770 */ 334, 293, 334, 334, 334, 334, 334, 334, 247, 286, + /* 1780 */ 287, 288, 289, 290, 291, 254, 293, 334, 334, 334, + /* 1790 */ 334, 334, 223, 334, 334, 264, 334, 334, 334, 268, + /* 1800 */ 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, + /* 1810 */ 334, 334, 334, 334, 334, 334, 247, 286, 287, 288, + /* 1820 */ 289, 290, 291, 254, 293, 334, 334, 334, 334, 334, + /* 1830 */ 334, 334, 334, 264, 334, 334, 334, 268, 334, 334, + /* 1840 */ 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, + /* 1850 */ 334, 334, 334, 334, 334, 286, 287, 288, 289, 290, + /* 1860 */ 291, 334, 293, 334, 334, 334, 334, 334, 334, 334, + /* 1870 */ 334, 334, }; #define YY_SHIFT_COUNT (567) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1619) +#define YY_SHIFT_MAX (1644) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 835, 0, 39, 90, 90, 90, 90, 217, 90, 90, - /* 10 */ 263, 390, 436, 390, 390, 390, 390, 390, 390, 390, - /* 20 */ 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - /* 30 */ 390, 390, 390, 390, 390, 390, 174, 21, 21, 21, - /* 40 */ 29, 438, 438, 45, 38, 38, 54, 438, 38, 38, - /* 50 */ 38, 38, 38, 38, 27, 38, 99, 264, 54, 298, - /* 60 */ 99, 38, 38, 99, 38, 99, 298, 99, 99, 38, - /* 70 */ 490, 511, 230, 539, 539, 268, 1117, 296, 1117, 1117, - /* 80 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, - /* 90 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 258, 466, 86, - /* 100 */ 202, 202, 291, 291, 291, 116, 202, 202, 323, 298, - /* 110 */ 99, 99, 99, 496, 567, 423, 423, 423, 423, 423, - /* 120 */ 423, 423, 630, 129, 137, 562, 160, 162, 123, 52, - /* 130 */ 186, 576, 465, 460, 465, 719, 383, 449, 740, 866, - /* 140 */ 852, 860, 758, 866, 866, 806, 798, 798, 866, 916, - /* 150 */ 27, 298, 921, 27, 323, 924, 27, 27, 866, 27, - /* 160 */ 940, 99, 99, 99, 99, 99, 99, 99, 99, 99, - /* 170 */ 99, 99, 866, 940, 955, 916, 490, 861, 298, 921, - /* 180 */ 490, 323, 924, 490, 1013, 837, 840, 955, 837, 840, - /* 190 */ 955, 955, 841, 838, 863, 868, 872, 323, 1056, 958, - /* 200 */ 864, 873, 870, 1007, 99, 840, 955, 955, 840, 955, - /* 210 */ 966, 323, 924, 490, 496, 490, 323, 1047, 567, 866, - /* 220 */ 490, 940, 1929, 1929, 1929, 1929, 1929, 1929, 286, 833, - /* 230 */ 790, 461, 1379, 1438, 16, 118, 457, 392, 578, 219, - /* 240 */ 219, 219, 219, 219, 219, 219, 219, 379, 429, 307, - /* 250 */ 447, 314, 314, 314, 314, 252, 601, 414, 664, 685, - /* 260 */ 691, 722, 735, 785, 802, 737, 522, 752, 754, 768, - /* 270 */ 597, 613, 330, 636, 773, 694, 780, 756, 788, 789, - /* 280 */ 801, 810, 826, 824, 830, 836, 842, 845, 847, 848, - /* 290 */ 853, 712, 816, 1141, 1153, 1090, 1156, 1119, 995, 1122, - /* 300 */ 1124, 1125, 1001, 1165, 1128, 1129, 1008, 1172, 1132, 1176, - /* 310 */ 1139, 1179, 1106, 1031, 1034, 1075, 1039, 1186, 1188, 1136, - /* 320 */ 1048, 1197, 1208, 1126, 1209, 1213, 1217, 1219, 1224, 1225, - /* 330 */ 1227, 1229, 1230, 1231, 1233, 1234, 1237, 1244, 1247, 1248, - /* 340 */ 1101, 1222, 1249, 1256, 1258, 1260, 1261, 1240, 1264, 1265, - /* 350 */ 1266, 1267, 1268, 1269, 1278, 1279, 1280, 1228, 1272, 1223, - /* 360 */ 1273, 1275, 1238, 1245, 1239, 1286, 1251, 1257, 1252, 1292, - /* 370 */ 1259, 1262, 1253, 1299, 1263, 1270, 1276, 1302, 1303, 1305, - /* 380 */ 1308, 1232, 1250, 1282, 1281, 1283, 1296, 1321, 1290, 1294, - /* 390 */ 1297, 1298, 1281, 1283, 1300, 1304, 1330, 1312, 1337, 1317, - /* 400 */ 1307, 1340, 1322, 1309, 1343, 1327, 1350, 1329, 1333, 1355, - /* 410 */ 1218, 1323, 1359, 1212, 1338, 1235, 1236, 1366, 1367, 1255, - /* 420 */ 1368, 1314, 1332, 1274, 1306, 1318, 1191, 1295, 1324, 1319, - /* 430 */ 1328, 1344, 1345, 1331, 1346, 1334, 1347, 1351, 1204, 1339, - /* 440 */ 1352, 1342, 1178, 1353, 1348, 1356, 1354, 1226, 1426, 1394, - /* 450 */ 1397, 1401, 1403, 1404, 1407, 1445, 1284, 1377, 1374, 1378, - /* 460 */ 1386, 1380, 1388, 1390, 1391, 1405, 1392, 1431, 1311, 1408, - /* 470 */ 1389, 1402, 1409, 1416, 1360, 1417, 1481, 1449, 1361, 1421, - /* 480 */ 1413, 1412, 1414, 1479, 1428, 1419, 1430, 1474, 1476, 1441, - /* 490 */ 1443, 1478, 1446, 1444, 1483, 1448, 1451, 1489, 1454, 1455, - /* 500 */ 1491, 1457, 1433, 1436, 1437, 1440, 1511, 1450, 1466, 1503, - /* 510 */ 1442, 1468, 1469, 1512, 1281, 1283, 1527, 1501, 1505, 1496, - /* 520 */ 1490, 1495, 1529, 1531, 1532, 1534, 1535, 1536, 1537, 1543, - /* 530 */ 1519, 1281, 1539, 1283, 1540, 1541, 1544, 1545, 1546, 1547, - /* 540 */ 1554, 1594, 1558, 1561, 1538, 1598, 1562, 1563, 1560, 1601, - /* 550 */ 1567, 1570, 1564, 1608, 1571, 1574, 1572, 1613, 1576, 1580, - /* 560 */ 1618, 1619, 1600, 1599, 1602, 1604, 1606, 1603, + /* 0 */ 822, 0, 39, 90, 90, 90, 90, 218, 90, 90, + /* 10 */ 264, 392, 438, 392, 392, 392, 392, 392, 392, 392, + /* 20 */ 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, + /* 30 */ 392, 392, 392, 392, 392, 392, 122, 21, 21, 21, + /* 40 */ 121, 1096, 1096, 45, 38, 38, 5, 1096, 38, 38, + /* 50 */ 38, 38, 38, 38, 27, 38, 290, 362, 5, 391, + /* 60 */ 290, 38, 38, 290, 38, 290, 391, 290, 290, 38, + /* 70 */ 458, 513, 231, 574, 574, 269, 435, 297, 435, 435, + /* 80 */ 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + /* 90 */ 435, 435, 435, 435, 435, 435, 435, 259, 219, 86, + /* 100 */ 191, 191, 445, 445, 445, 116, 191, 191, 483, 391, + /* 110 */ 290, 290, 290, 452, 544, 425, 425, 425, 425, 425, + /* 120 */ 425, 425, 637, 129, 137, 636, 159, 492, 49, 52, + /* 130 */ 322, 672, 499, 654, 499, 736, 642, 732, 774, 920, + /* 140 */ 918, 928, 814, 920, 920, 848, 863, 863, 920, 985, + /* 150 */ 27, 391, 990, 27, 483, 995, 27, 27, 920, 27, + /* 160 */ 1007, 290, 290, 290, 290, 290, 290, 290, 290, 290, + /* 170 */ 290, 290, 920, 1007, 988, 985, 458, 917, 391, 990, + /* 180 */ 458, 483, 995, 458, 1055, 878, 880, 988, 878, 880, + /* 190 */ 988, 988, 898, 901, 914, 916, 923, 483, 1097, 1003, + /* 200 */ 906, 911, 912, 1054, 290, 880, 988, 988, 880, 988, + /* 210 */ 1011, 483, 995, 458, 452, 458, 483, 1081, 544, 920, + /* 220 */ 458, 1007, 1863, 1863, 1863, 1863, 1863, 1863, 287, 987, + /* 230 */ 1339, 754, 490, 836, 16, 118, 714, 321, 769, 484, + /* 240 */ 484, 484, 484, 484, 484, 484, 484, 236, 215, 473, + /* 250 */ 526, 717, 717, 717, 717, 776, 656, 338, 725, 726, + /* 260 */ 735, 748, 502, 558, 777, 817, 651, 778, 787, 788, + /* 270 */ 845, 678, 411, 161, 793, 379, 798, 806, 823, 842, + /* 280 */ 853, 856, 874, 847, 855, 876, 877, 903, 908, 910, + /* 290 */ 927, 826, 430, 1190, 1194, 1131, 1196, 1159, 1035, 1175, + /* 300 */ 1178, 1179, 1057, 1218, 1181, 1183, 1060, 1224, 1187, 1226, + /* 310 */ 1189, 1228, 1155, 1080, 1082, 1124, 1088, 1235, 1240, 1191, + /* 320 */ 1101, 1245, 1246, 1152, 1247, 1248, 1249, 1250, 1251, 1252, + /* 330 */ 1253, 1260, 1262, 1264, 1266, 1267, 1268, 1269, 1270, 1271, + /* 340 */ 1153, 1274, 1275, 1276, 1277, 1278, 1280, 1259, 1283, 1284, + /* 350 */ 1285, 1287, 1288, 1289, 1291, 1292, 1293, 1254, 1294, 1244, + /* 360 */ 1296, 1298, 1261, 1265, 1257, 1302, 1279, 1282, 1272, 1312, + /* 370 */ 1281, 1286, 1273, 1323, 1290, 1297, 1308, 1325, 1326, 1329, + /* 380 */ 1330, 1258, 1255, 1299, 1263, 1303, 1310, 1340, 1314, 1321, + /* 390 */ 1324, 1335, 1263, 1303, 1337, 1338, 1350, 1355, 1378, 1358, + /* 400 */ 1342, 1382, 1361, 1346, 1386, 1365, 1388, 1368, 1371, 1394, + /* 410 */ 1295, 1357, 1396, 1256, 1375, 1300, 1301, 1398, 1400, 1304, + /* 420 */ 1401, 1331, 1360, 1317, 1333, 1348, 1208, 1347, 1349, 1359, + /* 430 */ 1336, 1343, 1363, 1366, 1364, 1362, 1369, 1374, 1220, 1372, + /* 440 */ 1376, 1370, 1305, 1381, 1373, 1379, 1384, 1306, 1453, 1420, + /* 450 */ 1422, 1430, 1441, 1442, 1443, 1480, 1316, 1413, 1411, 1414, + /* 460 */ 1415, 1419, 1421, 1403, 1423, 1424, 1408, 1473, 1332, 1425, + /* 470 */ 1428, 1429, 1434, 1444, 1383, 1446, 1505, 1472, 1389, 1447, + /* 480 */ 1433, 1437, 1448, 1510, 1459, 1450, 1461, 1499, 1501, 1466, + /* 490 */ 1467, 1503, 1469, 1470, 1506, 1474, 1471, 1509, 1475, 1476, + /* 500 */ 1512, 1479, 1456, 1457, 1458, 1460, 1530, 1477, 1484, 1522, + /* 510 */ 1454, 1491, 1492, 1529, 1263, 1303, 1548, 1521, 1523, 1517, + /* 520 */ 1504, 1507, 1539, 1542, 1543, 1544, 1546, 1547, 1549, 1564, + /* 530 */ 1532, 1263, 1550, 1303, 1552, 1553, 1572, 1573, 1574, 1576, + /* 540 */ 1577, 1607, 1579, 1582, 1578, 1619, 1584, 1587, 1581, 1620, + /* 550 */ 1588, 1589, 1585, 1627, 1591, 1594, 1596, 1637, 1603, 1605, + /* 560 */ 1643, 1644, 1623, 1625, 1626, 1628, 1630, 1629, }; #define YY_REDUCE_COUNT (227) -#define YY_REDUCE_MIN (-310) -#define YY_REDUCE_MAX (1636) +#define YY_REDUCE_MIN (-311) +#define YY_REDUCE_MAX (1569) static const short yy_reduce_ofst[] = { - /* 0 */ -210, -207, 398, 488, 546, 604, 662, 718, 769, 827, - /* 10 */ 857, 906, 915, 953, 965, -219, 1037, 731, 1024, 1095, - /* 20 */ 1111, 1123, 1170, 1183, 1221, 1271, 1301, 1349, 1358, 1406, - /* 30 */ 1434, 1485, 1494, 1565, 1581, 1636, 781, -181, -2, 28, - /* 40 */ -185, -246, -227, 53, -220, -138, 155, -256, -153, 247, - /* 50 */ 415, 417, 420, 441, -46, 467, -108, -101, -310, -100, - /* 60 */ 69, 484, 485, 211, 512, 244, 199, 410, 294, 463, - /* 70 */ 184, -221, -291, -291, -291, -116, -222, -94, -203, -29, - /* 80 */ -20, 68, 157, 255, 279, 282, 334, 358, 380, 442, - /* 90 */ 480, 483, 524, 526, 530, 531, 534, -137, -84, -188, - /* 100 */ 126, 259, -79, 198, 276, 373, 353, 355, 455, -253, - /* 110 */ 404, 221, 435, 132, 273, -245, 472, 514, 523, 557, - /* 120 */ 558, 559, 407, 473, 575, 428, 459, 555, 533, 521, - /* 130 */ 603, 556, 540, 540, 540, 619, 549, 570, 619, 659, - /* 140 */ 615, 668, 637, 684, 693, 666, 672, 673, 706, 658, - /* 150 */ 707, 675, 671, 713, 692, 695, 725, 726, 730, 739, - /* 160 */ 741, 721, 727, 733, 734, 736, 742, 743, 746, 747, - /* 170 */ 750, 765, 774, 762, 757, 749, 786, 751, 767, 764, - /* 180 */ 811, 775, 776, 812, 753, 723, 777, 783, 744, 779, - /* 190 */ 784, 793, 745, 755, 759, 761, 540, 818, 794, 782, - /* 200 */ 763, 766, 770, 799, 619, 823, 831, 832, 834, 839, - /* 210 */ 843, 851, 854, 880, 858, 884, 876, 874, 889, 902, - /* 220 */ 904, 908, 859, 856, 895, 896, 909, 920, + /* 0 */ -211, -208, 400, 451, 532, 588, 618, 648, 703, 753, + /* 10 */ 801, 812, 883, 921, 913, -220, 968, 1018, 1056, 1067, + /* 20 */ 1125, 1138, 1176, 1185, 1223, 1238, 1307, 1315, 1345, 1393, + /* 30 */ 1431, 1440, 1478, 1493, 1531, 1569, 179, -182, -2, 174, + /* 40 */ -186, -247, -228, 58, -221, -139, 181, -257, -154, -5, + /* 50 */ -4, -3, -1, 224, 128, 307, -109, -102, -311, -101, + /* 60 */ 69, 353, 417, 214, 424, 216, 278, 346, 420, 431, + /* 70 */ 228, -222, -292, -292, -292, -117, -223, -95, -204, -174, + /* 80 */ 62, 271, 282, 286, 288, 326, 404, 440, 454, 457, + /* 90 */ 480, 481, 486, 489, 512, 546, 569, 139, -33, -189, + /* 100 */ 46, 173, 415, 462, 494, -130, 193, 432, 324, -254, + /* 110 */ 550, 460, 487, 352, 54, -246, 385, 413, 469, 545, + /* 120 */ 567, 576, 555, 615, 612, 534, 560, 610, 607, 579, + /* 130 */ 665, 630, 593, 593, 593, 675, 599, 619, 675, 724, + /* 140 */ 674, 739, 685, 740, 746, 718, 737, 741, 779, 728, + /* 150 */ 780, 745, 742, 781, 759, 751, 791, 794, 789, 795, + /* 160 */ 803, 783, 790, 800, 804, 805, 809, 810, 811, 815, + /* 170 */ 820, 821, 807, 813, 782, 786, 833, 796, 808, 799, + /* 180 */ 846, 824, 816, 849, 797, 757, 828, 818, 763, 835, + /* 190 */ 839, 843, 802, 827, 819, 825, 593, 859, 832, 829, + /* 200 */ 830, 831, 834, 840, 675, 860, 865, 870, 862, 881, + /* 210 */ 882, 896, 887, 926, 915, 929, 902, 930, 925, 935, + /* 220 */ 937, 941, 907, 899, 942, 945, 957, 967, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 10 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 20 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 30 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 40 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 50 */ 1274, 1274, 1274, 1274, 1333, 1274, 1274, 1274, 1274, 1274, - /* 60 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 70 */ 1331, 1473, 1274, 1628, 1274, 1274, 1274, 1274, 1274, 1274, - /* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 90 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1333, - /* 100 */ 1274, 1274, 1639, 1639, 1639, 1331, 1274, 1274, 1274, 1274, - /* 110 */ 1274, 1274, 1274, 1426, 1274, 1274, 1274, 1274, 1274, 1274, - /* 120 */ 1274, 1274, 1507, 1274, 1274, 1703, 1274, 1379, 1513, 1663, - /* 130 */ 1274, 1655, 1631, 1645, 1632, 1274, 1688, 1648, 1274, 1274, - /* 140 */ 1274, 1274, 1499, 1274, 1274, 1478, 1475, 1475, 1274, 1274, - /* 150 */ 1333, 1274, 1274, 1333, 1274, 1274, 1333, 1333, 1274, 1333, - /* 160 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 170 */ 1274, 1274, 1274, 1274, 1274, 1274, 1331, 1509, 1274, 1274, - /* 180 */ 1331, 1274, 1274, 1331, 1274, 1670, 1668, 1274, 1670, 1668, - /* 190 */ 1274, 1274, 1682, 1678, 1661, 1659, 1645, 1274, 1274, 1274, - /* 200 */ 1706, 1694, 1690, 1274, 1274, 1668, 1274, 1274, 1668, 1274, - /* 210 */ 1486, 1274, 1274, 1331, 1274, 1331, 1274, 1395, 1274, 1274, - /* 220 */ 1331, 1274, 1501, 1515, 1429, 1429, 1334, 1279, 1274, 1274, - /* 230 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1576, - /* 240 */ 1681, 1680, 1604, 1603, 1602, 1600, 1575, 1274, 1274, 1274, - /* 250 */ 1274, 1569, 1570, 1568, 1567, 1274, 1274, 1274, 1274, 1274, - /* 260 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 270 */ 1629, 1274, 1691, 1695, 1274, 1274, 1274, 1553, 1274, 1274, - /* 280 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 290 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 300 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 310 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 320 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 330 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 340 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 350 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 360 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 370 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 380 */ 1274, 1274, 1274, 1274, 1442, 1441, 1274, 1274, 1274, 1274, - /* 390 */ 1274, 1274, 1360, 1359, 1274, 1274, 1274, 1274, 1274, 1274, - /* 400 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 410 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 420 */ 1274, 1274, 1274, 1274, 1652, 1662, 1274, 1274, 1274, 1274, - /* 430 */ 1274, 1274, 1274, 1274, 1274, 1553, 1274, 1679, 1274, 1638, - /* 440 */ 1634, 1274, 1274, 1630, 1274, 1274, 1689, 1274, 1274, 1274, - /* 450 */ 1274, 1274, 1274, 1274, 1274, 1624, 1274, 1597, 1274, 1274, - /* 460 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1563, 1274, - /* 470 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 480 */ 1274, 1552, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1423, - /* 490 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 500 */ 1274, 1274, 1408, 1406, 1405, 1404, 1274, 1401, 1274, 1274, - /* 510 */ 1274, 1274, 1274, 1274, 1432, 1431, 1274, 1274, 1274, 1274, - /* 520 */ 1274, 1354, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 530 */ 1274, 1345, 1274, 1344, 1274, 1274, 1274, 1274, 1274, 1274, - /* 540 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 550 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, - /* 560 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, + /* 0 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 10 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 20 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 30 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 40 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 50 */ 1276, 1276, 1276, 1276, 1335, 1276, 1276, 1276, 1276, 1276, + /* 60 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 70 */ 1333, 1475, 1276, 1631, 1276, 1276, 1276, 1276, 1276, 1276, + /* 80 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 90 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1335, + /* 100 */ 1276, 1276, 1642, 1642, 1642, 1333, 1276, 1276, 1276, 1276, + /* 110 */ 1276, 1276, 1276, 1428, 1276, 1276, 1276, 1276, 1276, 1276, + /* 120 */ 1276, 1276, 1509, 1276, 1276, 1706, 1276, 1381, 1515, 1666, + /* 130 */ 1276, 1658, 1634, 1648, 1635, 1276, 1691, 1651, 1276, 1276, + /* 140 */ 1276, 1276, 1501, 1276, 1276, 1480, 1477, 1477, 1276, 1276, + /* 150 */ 1335, 1276, 1276, 1335, 1276, 1276, 1335, 1335, 1276, 1335, + /* 160 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 170 */ 1276, 1276, 1276, 1276, 1276, 1276, 1333, 1511, 1276, 1276, + /* 180 */ 1333, 1276, 1276, 1333, 1276, 1673, 1671, 1276, 1673, 1671, + /* 190 */ 1276, 1276, 1685, 1681, 1664, 1662, 1648, 1276, 1276, 1276, + /* 200 */ 1709, 1697, 1693, 1276, 1276, 1671, 1276, 1276, 1671, 1276, + /* 210 */ 1488, 1276, 1276, 1333, 1276, 1333, 1276, 1397, 1276, 1276, + /* 220 */ 1333, 1276, 1503, 1517, 1431, 1431, 1336, 1281, 1276, 1276, + /* 230 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1578, + /* 240 */ 1684, 1683, 1607, 1606, 1605, 1603, 1577, 1276, 1276, 1276, + /* 250 */ 1276, 1571, 1572, 1570, 1569, 1276, 1276, 1276, 1276, 1276, + /* 260 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 270 */ 1632, 1276, 1694, 1698, 1276, 1276, 1276, 1555, 1276, 1276, + /* 280 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 290 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 300 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 310 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 320 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 330 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 340 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 350 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 360 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 370 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 380 */ 1276, 1276, 1276, 1276, 1444, 1443, 1276, 1276, 1276, 1276, + /* 390 */ 1276, 1276, 1362, 1361, 1276, 1276, 1276, 1276, 1276, 1276, + /* 400 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 410 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 420 */ 1276, 1276, 1276, 1276, 1655, 1665, 1276, 1276, 1276, 1276, + /* 430 */ 1276, 1276, 1276, 1276, 1276, 1555, 1276, 1682, 1276, 1641, + /* 440 */ 1637, 1276, 1276, 1633, 1276, 1276, 1692, 1276, 1276, 1276, + /* 450 */ 1276, 1276, 1276, 1276, 1276, 1627, 1276, 1600, 1276, 1276, + /* 460 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1565, 1276, + /* 470 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 480 */ 1276, 1554, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1425, + /* 490 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 500 */ 1276, 1276, 1410, 1408, 1407, 1406, 1276, 1403, 1276, 1276, + /* 510 */ 1276, 1276, 1276, 1276, 1434, 1433, 1276, 1276, 1276, 1276, + /* 520 */ 1276, 1356, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 530 */ 1276, 1347, 1276, 1346, 1276, 1276, 1276, 1276, 1276, 1276, + /* 540 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 550 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 560 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1034,159 +1023,160 @@ static const char *const yyTokenName[] = { /* 177 */ "CAST", /* 178 */ "NOW", /* 179 */ "TODAY", - /* 180 */ "COUNT", - /* 181 */ "FIRST", - /* 182 */ "LAST", - /* 183 */ "LAST_ROW", - /* 184 */ "BETWEEN", - /* 185 */ "IS", - /* 186 */ "NK_LT", - /* 187 */ "NK_GT", - /* 188 */ "NK_LE", - /* 189 */ "NK_GE", - /* 190 */ "NK_NE", - /* 191 */ "MATCH", - /* 192 */ "NMATCH", - /* 193 */ "CONTAINS", - /* 194 */ "JOIN", - /* 195 */ "INNER", - /* 196 */ "SELECT", - /* 197 */ "DISTINCT", - /* 198 */ "WHERE", - /* 199 */ "PARTITION", - /* 200 */ "BY", - /* 201 */ "SESSION", - /* 202 */ "STATE_WINDOW", - /* 203 */ "SLIDING", - /* 204 */ "FILL", - /* 205 */ "VALUE", - /* 206 */ "NONE", - /* 207 */ "PREV", - /* 208 */ "LINEAR", - /* 209 */ "NEXT", - /* 210 */ "GROUP", - /* 211 */ "HAVING", - /* 212 */ "ORDER", - /* 213 */ "SLIMIT", - /* 214 */ "SOFFSET", - /* 215 */ "LIMIT", - /* 216 */ "OFFSET", - /* 217 */ "ASC", - /* 218 */ "NULLS", - /* 219 */ "cmd", - /* 220 */ "account_options", - /* 221 */ "alter_account_options", - /* 222 */ "literal", - /* 223 */ "alter_account_option", - /* 224 */ "user_name", - /* 225 */ "dnode_endpoint", - /* 226 */ "dnode_host_name", - /* 227 */ "not_exists_opt", - /* 228 */ "db_name", - /* 229 */ "db_options", - /* 230 */ "exists_opt", - /* 231 */ "alter_db_options", - /* 232 */ "integer_list", - /* 233 */ "variable_list", - /* 234 */ "retention_list", - /* 235 */ "alter_db_option", - /* 236 */ "retention", - /* 237 */ "full_table_name", - /* 238 */ "column_def_list", - /* 239 */ "tags_def_opt", - /* 240 */ "table_options", - /* 241 */ "multi_create_clause", - /* 242 */ "tags_def", - /* 243 */ "multi_drop_clause", - /* 244 */ "alter_table_clause", - /* 245 */ "alter_table_options", - /* 246 */ "column_name", - /* 247 */ "type_name", - /* 248 */ "create_subtable_clause", - /* 249 */ "specific_tags_opt", - /* 250 */ "literal_list", - /* 251 */ "drop_table_clause", - /* 252 */ "col_name_list", - /* 253 */ "table_name", - /* 254 */ "column_def", - /* 255 */ "func_name_list", - /* 256 */ "alter_table_option", - /* 257 */ "col_name", - /* 258 */ "db_name_cond_opt", - /* 259 */ "like_pattern_opt", - /* 260 */ "table_name_cond", - /* 261 */ "from_db_opt", - /* 262 */ "func_name", - /* 263 */ "function_name", - /* 264 */ "index_name", - /* 265 */ "index_options", - /* 266 */ "func_list", - /* 267 */ "duration_literal", - /* 268 */ "sliding_opt", - /* 269 */ "func", - /* 270 */ "expression_list", - /* 271 */ "topic_name", - /* 272 */ "query_expression", - /* 273 */ "analyze_opt", - /* 274 */ "explain_options", - /* 275 */ "agg_func_opt", - /* 276 */ "bufsize_opt", - /* 277 */ "stream_name", - /* 278 */ "stream_options", - /* 279 */ "into_opt", - /* 280 */ "dnode_list", - /* 281 */ "signed", - /* 282 */ "signed_literal", - /* 283 */ "table_alias", - /* 284 */ "column_alias", - /* 285 */ "expression", - /* 286 */ "pseudo_column", - /* 287 */ "column_reference", - /* 288 */ "function_expression", - /* 289 */ "subquery", - /* 290 */ "star_func", - /* 291 */ "star_func_para_list", - /* 292 */ "noarg_func", - /* 293 */ "other_para_list", - /* 294 */ "star_func_para", - /* 295 */ "predicate", - /* 296 */ "compare_op", - /* 297 */ "in_op", - /* 298 */ "in_predicate_value", - /* 299 */ "boolean_value_expression", - /* 300 */ "boolean_primary", - /* 301 */ "common_expression", - /* 302 */ "from_clause", - /* 303 */ "table_reference_list", - /* 304 */ "table_reference", - /* 305 */ "table_primary", - /* 306 */ "joined_table", - /* 307 */ "alias_opt", - /* 308 */ "parenthesized_joined_table", - /* 309 */ "join_type", - /* 310 */ "search_condition", - /* 311 */ "query_specification", - /* 312 */ "set_quantifier_opt", - /* 313 */ "select_list", - /* 314 */ "where_clause_opt", - /* 315 */ "partition_by_clause_opt", - /* 316 */ "twindow_clause_opt", - /* 317 */ "group_by_clause_opt", - /* 318 */ "having_clause_opt", - /* 319 */ "select_sublist", - /* 320 */ "select_item", - /* 321 */ "fill_opt", - /* 322 */ "fill_mode", - /* 323 */ "group_by_list", - /* 324 */ "query_expression_body", - /* 325 */ "order_by_clause_opt", - /* 326 */ "slimit_clause_opt", - /* 327 */ "limit_clause_opt", - /* 328 */ "query_primary", - /* 329 */ "sort_specification_list", - /* 330 */ "sort_specification", - /* 331 */ "ordering_specification_opt", - /* 332 */ "null_ordering_opt", + /* 180 */ "TIMEZONE", + /* 181 */ "COUNT", + /* 182 */ "FIRST", + /* 183 */ "LAST", + /* 184 */ "LAST_ROW", + /* 185 */ "BETWEEN", + /* 186 */ "IS", + /* 187 */ "NK_LT", + /* 188 */ "NK_GT", + /* 189 */ "NK_LE", + /* 190 */ "NK_GE", + /* 191 */ "NK_NE", + /* 192 */ "MATCH", + /* 193 */ "NMATCH", + /* 194 */ "CONTAINS", + /* 195 */ "JOIN", + /* 196 */ "INNER", + /* 197 */ "SELECT", + /* 198 */ "DISTINCT", + /* 199 */ "WHERE", + /* 200 */ "PARTITION", + /* 201 */ "BY", + /* 202 */ "SESSION", + /* 203 */ "STATE_WINDOW", + /* 204 */ "SLIDING", + /* 205 */ "FILL", + /* 206 */ "VALUE", + /* 207 */ "NONE", + /* 208 */ "PREV", + /* 209 */ "LINEAR", + /* 210 */ "NEXT", + /* 211 */ "GROUP", + /* 212 */ "HAVING", + /* 213 */ "ORDER", + /* 214 */ "SLIMIT", + /* 215 */ "SOFFSET", + /* 216 */ "LIMIT", + /* 217 */ "OFFSET", + /* 218 */ "ASC", + /* 219 */ "NULLS", + /* 220 */ "cmd", + /* 221 */ "account_options", + /* 222 */ "alter_account_options", + /* 223 */ "literal", + /* 224 */ "alter_account_option", + /* 225 */ "user_name", + /* 226 */ "dnode_endpoint", + /* 227 */ "dnode_host_name", + /* 228 */ "not_exists_opt", + /* 229 */ "db_name", + /* 230 */ "db_options", + /* 231 */ "exists_opt", + /* 232 */ "alter_db_options", + /* 233 */ "integer_list", + /* 234 */ "variable_list", + /* 235 */ "retention_list", + /* 236 */ "alter_db_option", + /* 237 */ "retention", + /* 238 */ "full_table_name", + /* 239 */ "column_def_list", + /* 240 */ "tags_def_opt", + /* 241 */ "table_options", + /* 242 */ "multi_create_clause", + /* 243 */ "tags_def", + /* 244 */ "multi_drop_clause", + /* 245 */ "alter_table_clause", + /* 246 */ "alter_table_options", + /* 247 */ "column_name", + /* 248 */ "type_name", + /* 249 */ "create_subtable_clause", + /* 250 */ "specific_tags_opt", + /* 251 */ "literal_list", + /* 252 */ "drop_table_clause", + /* 253 */ "col_name_list", + /* 254 */ "table_name", + /* 255 */ "column_def", + /* 256 */ "func_name_list", + /* 257 */ "alter_table_option", + /* 258 */ "col_name", + /* 259 */ "db_name_cond_opt", + /* 260 */ "like_pattern_opt", + /* 261 */ "table_name_cond", + /* 262 */ "from_db_opt", + /* 263 */ "func_name", + /* 264 */ "function_name", + /* 265 */ "index_name", + /* 266 */ "index_options", + /* 267 */ "func_list", + /* 268 */ "duration_literal", + /* 269 */ "sliding_opt", + /* 270 */ "func", + /* 271 */ "expression_list", + /* 272 */ "topic_name", + /* 273 */ "query_expression", + /* 274 */ "analyze_opt", + /* 275 */ "explain_options", + /* 276 */ "agg_func_opt", + /* 277 */ "bufsize_opt", + /* 278 */ "stream_name", + /* 279 */ "stream_options", + /* 280 */ "into_opt", + /* 281 */ "dnode_list", + /* 282 */ "signed", + /* 283 */ "signed_literal", + /* 284 */ "table_alias", + /* 285 */ "column_alias", + /* 286 */ "expression", + /* 287 */ "pseudo_column", + /* 288 */ "column_reference", + /* 289 */ "function_expression", + /* 290 */ "subquery", + /* 291 */ "star_func", + /* 292 */ "star_func_para_list", + /* 293 */ "noarg_func", + /* 294 */ "other_para_list", + /* 295 */ "star_func_para", + /* 296 */ "predicate", + /* 297 */ "compare_op", + /* 298 */ "in_op", + /* 299 */ "in_predicate_value", + /* 300 */ "boolean_value_expression", + /* 301 */ "boolean_primary", + /* 302 */ "common_expression", + /* 303 */ "from_clause", + /* 304 */ "table_reference_list", + /* 305 */ "table_reference", + /* 306 */ "table_primary", + /* 307 */ "joined_table", + /* 308 */ "alias_opt", + /* 309 */ "parenthesized_joined_table", + /* 310 */ "join_type", + /* 311 */ "search_condition", + /* 312 */ "query_specification", + /* 313 */ "set_quantifier_opt", + /* 314 */ "select_list", + /* 315 */ "where_clause_opt", + /* 316 */ "partition_by_clause_opt", + /* 317 */ "twindow_clause_opt", + /* 318 */ "group_by_clause_opt", + /* 319 */ "having_clause_opt", + /* 320 */ "select_sublist", + /* 321 */ "select_item", + /* 322 */ "fill_opt", + /* 323 */ "fill_mode", + /* 324 */ "group_by_list", + /* 325 */ "query_expression_body", + /* 326 */ "order_by_clause_opt", + /* 327 */ "slimit_clause_opt", + /* 328 */ "limit_clause_opt", + /* 329 */ "query_primary", + /* 330 */ "sort_specification_list", + /* 331 */ "sort_specification", + /* 332 */ "ordering_specification_opt", + /* 333 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1509,123 +1499,124 @@ static const char *const yyRuleName[] = { /* 312 */ "function_expression ::= noarg_func NK_LP NK_RP", /* 313 */ "noarg_func ::= NOW", /* 314 */ "noarg_func ::= TODAY", - /* 315 */ "star_func ::= COUNT", - /* 316 */ "star_func ::= FIRST", - /* 317 */ "star_func ::= LAST", - /* 318 */ "star_func ::= LAST_ROW", - /* 319 */ "star_func_para_list ::= NK_STAR", - /* 320 */ "star_func_para_list ::= other_para_list", - /* 321 */ "other_para_list ::= star_func_para", - /* 322 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 323 */ "star_func_para ::= expression", - /* 324 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 325 */ "predicate ::= expression compare_op expression", - /* 326 */ "predicate ::= expression BETWEEN expression AND expression", - /* 327 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 328 */ "predicate ::= expression IS NULL", - /* 329 */ "predicate ::= expression IS NOT NULL", - /* 330 */ "predicate ::= expression in_op in_predicate_value", - /* 331 */ "compare_op ::= NK_LT", - /* 332 */ "compare_op ::= NK_GT", - /* 333 */ "compare_op ::= NK_LE", - /* 334 */ "compare_op ::= NK_GE", - /* 335 */ "compare_op ::= NK_NE", - /* 336 */ "compare_op ::= NK_EQ", - /* 337 */ "compare_op ::= LIKE", - /* 338 */ "compare_op ::= NOT LIKE", - /* 339 */ "compare_op ::= MATCH", - /* 340 */ "compare_op ::= NMATCH", - /* 341 */ "compare_op ::= CONTAINS", - /* 342 */ "in_op ::= IN", - /* 343 */ "in_op ::= NOT IN", - /* 344 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 345 */ "boolean_value_expression ::= boolean_primary", - /* 346 */ "boolean_value_expression ::= NOT boolean_primary", - /* 347 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 348 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 349 */ "boolean_primary ::= predicate", - /* 350 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 351 */ "common_expression ::= expression", - /* 352 */ "common_expression ::= boolean_value_expression", - /* 353 */ "from_clause ::= FROM table_reference_list", - /* 354 */ "table_reference_list ::= table_reference", - /* 355 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 356 */ "table_reference ::= table_primary", - /* 357 */ "table_reference ::= joined_table", - /* 358 */ "table_primary ::= table_name alias_opt", - /* 359 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 360 */ "table_primary ::= subquery alias_opt", - /* 361 */ "table_primary ::= parenthesized_joined_table", - /* 362 */ "alias_opt ::=", - /* 363 */ "alias_opt ::= table_alias", - /* 364 */ "alias_opt ::= AS table_alias", - /* 365 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 366 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 367 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 368 */ "join_type ::=", - /* 369 */ "join_type ::= INNER", - /* 370 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 371 */ "set_quantifier_opt ::=", - /* 372 */ "set_quantifier_opt ::= DISTINCT", - /* 373 */ "set_quantifier_opt ::= ALL", - /* 374 */ "select_list ::= NK_STAR", - /* 375 */ "select_list ::= select_sublist", - /* 376 */ "select_sublist ::= select_item", - /* 377 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 378 */ "select_item ::= common_expression", - /* 379 */ "select_item ::= common_expression column_alias", - /* 380 */ "select_item ::= common_expression AS column_alias", - /* 381 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 382 */ "where_clause_opt ::=", - /* 383 */ "where_clause_opt ::= WHERE search_condition", - /* 384 */ "partition_by_clause_opt ::=", - /* 385 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 386 */ "twindow_clause_opt ::=", - /* 387 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 388 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 389 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 390 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 391 */ "sliding_opt ::=", - /* 392 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 393 */ "fill_opt ::=", - /* 394 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 395 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 396 */ "fill_mode ::= NONE", - /* 397 */ "fill_mode ::= PREV", - /* 398 */ "fill_mode ::= NULL", - /* 399 */ "fill_mode ::= LINEAR", - /* 400 */ "fill_mode ::= NEXT", - /* 401 */ "group_by_clause_opt ::=", - /* 402 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 403 */ "group_by_list ::= expression", - /* 404 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 405 */ "having_clause_opt ::=", - /* 406 */ "having_clause_opt ::= HAVING search_condition", - /* 407 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 408 */ "query_expression_body ::= query_primary", - /* 409 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 410 */ "query_primary ::= query_specification", - /* 411 */ "order_by_clause_opt ::=", - /* 412 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 413 */ "slimit_clause_opt ::=", - /* 414 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 415 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 416 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 417 */ "limit_clause_opt ::=", - /* 418 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 419 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 420 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 421 */ "subquery ::= NK_LP query_expression NK_RP", - /* 422 */ "search_condition ::= common_expression", - /* 423 */ "sort_specification_list ::= sort_specification", - /* 424 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 425 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 426 */ "ordering_specification_opt ::=", - /* 427 */ "ordering_specification_opt ::= ASC", - /* 428 */ "ordering_specification_opt ::= DESC", - /* 429 */ "null_ordering_opt ::=", - /* 430 */ "null_ordering_opt ::= NULLS FIRST", - /* 431 */ "null_ordering_opt ::= NULLS LAST", + /* 315 */ "noarg_func ::= TIMEZONE", + /* 316 */ "star_func ::= COUNT", + /* 317 */ "star_func ::= FIRST", + /* 318 */ "star_func ::= LAST", + /* 319 */ "star_func ::= LAST_ROW", + /* 320 */ "star_func_para_list ::= NK_STAR", + /* 321 */ "star_func_para_list ::= other_para_list", + /* 322 */ "other_para_list ::= star_func_para", + /* 323 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 324 */ "star_func_para ::= expression", + /* 325 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 326 */ "predicate ::= expression compare_op expression", + /* 327 */ "predicate ::= expression BETWEEN expression AND expression", + /* 328 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 329 */ "predicate ::= expression IS NULL", + /* 330 */ "predicate ::= expression IS NOT NULL", + /* 331 */ "predicate ::= expression in_op in_predicate_value", + /* 332 */ "compare_op ::= NK_LT", + /* 333 */ "compare_op ::= NK_GT", + /* 334 */ "compare_op ::= NK_LE", + /* 335 */ "compare_op ::= NK_GE", + /* 336 */ "compare_op ::= NK_NE", + /* 337 */ "compare_op ::= NK_EQ", + /* 338 */ "compare_op ::= LIKE", + /* 339 */ "compare_op ::= NOT LIKE", + /* 340 */ "compare_op ::= MATCH", + /* 341 */ "compare_op ::= NMATCH", + /* 342 */ "compare_op ::= CONTAINS", + /* 343 */ "in_op ::= IN", + /* 344 */ "in_op ::= NOT IN", + /* 345 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 346 */ "boolean_value_expression ::= boolean_primary", + /* 347 */ "boolean_value_expression ::= NOT boolean_primary", + /* 348 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 349 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 350 */ "boolean_primary ::= predicate", + /* 351 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 352 */ "common_expression ::= expression", + /* 353 */ "common_expression ::= boolean_value_expression", + /* 354 */ "from_clause ::= FROM table_reference_list", + /* 355 */ "table_reference_list ::= table_reference", + /* 356 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 357 */ "table_reference ::= table_primary", + /* 358 */ "table_reference ::= joined_table", + /* 359 */ "table_primary ::= table_name alias_opt", + /* 360 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 361 */ "table_primary ::= subquery alias_opt", + /* 362 */ "table_primary ::= parenthesized_joined_table", + /* 363 */ "alias_opt ::=", + /* 364 */ "alias_opt ::= table_alias", + /* 365 */ "alias_opt ::= AS table_alias", + /* 366 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 367 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 368 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 369 */ "join_type ::=", + /* 370 */ "join_type ::= INNER", + /* 371 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 372 */ "set_quantifier_opt ::=", + /* 373 */ "set_quantifier_opt ::= DISTINCT", + /* 374 */ "set_quantifier_opt ::= ALL", + /* 375 */ "select_list ::= NK_STAR", + /* 376 */ "select_list ::= select_sublist", + /* 377 */ "select_sublist ::= select_item", + /* 378 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 379 */ "select_item ::= common_expression", + /* 380 */ "select_item ::= common_expression column_alias", + /* 381 */ "select_item ::= common_expression AS column_alias", + /* 382 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 383 */ "where_clause_opt ::=", + /* 384 */ "where_clause_opt ::= WHERE search_condition", + /* 385 */ "partition_by_clause_opt ::=", + /* 386 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 387 */ "twindow_clause_opt ::=", + /* 388 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 389 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 390 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 391 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 392 */ "sliding_opt ::=", + /* 393 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 394 */ "fill_opt ::=", + /* 395 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 396 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 397 */ "fill_mode ::= NONE", + /* 398 */ "fill_mode ::= PREV", + /* 399 */ "fill_mode ::= NULL", + /* 400 */ "fill_mode ::= LINEAR", + /* 401 */ "fill_mode ::= NEXT", + /* 402 */ "group_by_clause_opt ::=", + /* 403 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 404 */ "group_by_list ::= expression", + /* 405 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 406 */ "having_clause_opt ::=", + /* 407 */ "having_clause_opt ::= HAVING search_condition", + /* 408 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 409 */ "query_expression_body ::= query_primary", + /* 410 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 411 */ "query_primary ::= query_specification", + /* 412 */ "order_by_clause_opt ::=", + /* 413 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 414 */ "slimit_clause_opt ::=", + /* 415 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 416 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 417 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 418 */ "limit_clause_opt ::=", + /* 419 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 420 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 421 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 422 */ "subquery ::= NK_LP query_expression NK_RP", + /* 423 */ "search_condition ::= common_expression", + /* 424 */ "sort_specification_list ::= sort_specification", + /* 425 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 426 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 427 */ "ordering_specification_opt ::=", + /* 428 */ "ordering_specification_opt ::= ASC", + /* 429 */ "ordering_specification_opt ::= DESC", + /* 430 */ "null_ordering_opt ::=", + /* 431 */ "null_ordering_opt ::= NULLS FIRST", + /* 432 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1752,164 +1743,164 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 219: /* cmd */ - case 222: /* literal */ - case 229: /* db_options */ - case 231: /* alter_db_options */ - case 236: /* retention */ - case 237: /* full_table_name */ - case 240: /* table_options */ - case 244: /* alter_table_clause */ - case 245: /* alter_table_options */ - case 248: /* create_subtable_clause */ - case 251: /* drop_table_clause */ - case 254: /* column_def */ - case 257: /* col_name */ - case 258: /* db_name_cond_opt */ - case 259: /* like_pattern_opt */ - case 260: /* table_name_cond */ - case 261: /* from_db_opt */ - case 262: /* func_name */ - case 265: /* index_options */ - case 267: /* duration_literal */ - case 268: /* sliding_opt */ - case 269: /* func */ - case 272: /* query_expression */ - case 274: /* explain_options */ - case 278: /* stream_options */ - case 279: /* into_opt */ - case 281: /* signed */ - case 282: /* signed_literal */ - case 285: /* expression */ - case 286: /* pseudo_column */ - case 287: /* column_reference */ - case 288: /* function_expression */ - case 289: /* subquery */ - case 294: /* star_func_para */ - case 295: /* predicate */ - case 298: /* in_predicate_value */ - case 299: /* boolean_value_expression */ - case 300: /* boolean_primary */ - case 301: /* common_expression */ - case 302: /* from_clause */ - case 303: /* table_reference_list */ - case 304: /* table_reference */ - case 305: /* table_primary */ - case 306: /* joined_table */ - case 308: /* parenthesized_joined_table */ - case 310: /* search_condition */ - case 311: /* query_specification */ - case 314: /* where_clause_opt */ - case 316: /* twindow_clause_opt */ - case 318: /* having_clause_opt */ - case 320: /* select_item */ - case 321: /* fill_opt */ - case 324: /* query_expression_body */ - case 326: /* slimit_clause_opt */ - case 327: /* limit_clause_opt */ - case 328: /* query_primary */ - case 330: /* sort_specification */ + case 220: /* cmd */ + case 223: /* literal */ + case 230: /* db_options */ + case 232: /* alter_db_options */ + case 237: /* retention */ + case 238: /* full_table_name */ + case 241: /* table_options */ + case 245: /* alter_table_clause */ + case 246: /* alter_table_options */ + case 249: /* create_subtable_clause */ + case 252: /* drop_table_clause */ + case 255: /* column_def */ + case 258: /* col_name */ + case 259: /* db_name_cond_opt */ + case 260: /* like_pattern_opt */ + case 261: /* table_name_cond */ + case 262: /* from_db_opt */ + case 263: /* func_name */ + case 266: /* index_options */ + case 268: /* duration_literal */ + case 269: /* sliding_opt */ + case 270: /* func */ + case 273: /* query_expression */ + case 275: /* explain_options */ + case 279: /* stream_options */ + case 280: /* into_opt */ + case 282: /* signed */ + case 283: /* signed_literal */ + case 286: /* expression */ + case 287: /* pseudo_column */ + case 288: /* column_reference */ + case 289: /* function_expression */ + case 290: /* subquery */ + case 295: /* star_func_para */ + case 296: /* predicate */ + case 299: /* in_predicate_value */ + case 300: /* boolean_value_expression */ + case 301: /* boolean_primary */ + case 302: /* common_expression */ + case 303: /* from_clause */ + case 304: /* table_reference_list */ + case 305: /* table_reference */ + case 306: /* table_primary */ + case 307: /* joined_table */ + case 309: /* parenthesized_joined_table */ + case 311: /* search_condition */ + case 312: /* query_specification */ + case 315: /* where_clause_opt */ + case 317: /* twindow_clause_opt */ + case 319: /* having_clause_opt */ + case 321: /* select_item */ + case 322: /* fill_opt */ + case 325: /* query_expression_body */ + case 327: /* slimit_clause_opt */ + case 328: /* limit_clause_opt */ + case 329: /* query_primary */ + case 331: /* sort_specification */ { - nodesDestroyNode((yypminor->yy452)); + nodesDestroyNode((yypminor->yy456)); } break; - case 220: /* account_options */ - case 221: /* alter_account_options */ - case 223: /* alter_account_option */ - case 276: /* bufsize_opt */ + case 221: /* account_options */ + case 222: /* alter_account_options */ + case 224: /* alter_account_option */ + case 277: /* bufsize_opt */ { } break; - case 224: /* user_name */ - case 225: /* dnode_endpoint */ - case 226: /* dnode_host_name */ - case 228: /* db_name */ - case 246: /* column_name */ - case 253: /* table_name */ - case 263: /* function_name */ - case 264: /* index_name */ - case 271: /* topic_name */ - case 277: /* stream_name */ - case 283: /* table_alias */ - case 284: /* column_alias */ - case 290: /* star_func */ - case 292: /* noarg_func */ - case 307: /* alias_opt */ + case 225: /* user_name */ + case 226: /* dnode_endpoint */ + case 227: /* dnode_host_name */ + case 229: /* db_name */ + case 247: /* column_name */ + case 254: /* table_name */ + case 264: /* function_name */ + case 265: /* index_name */ + case 272: /* topic_name */ + case 278: /* stream_name */ + case 284: /* table_alias */ + case 285: /* column_alias */ + case 291: /* star_func */ + case 293: /* noarg_func */ + case 308: /* alias_opt */ { } break; - case 227: /* not_exists_opt */ - case 230: /* exists_opt */ - case 273: /* analyze_opt */ - case 275: /* agg_func_opt */ - case 312: /* set_quantifier_opt */ + case 228: /* not_exists_opt */ + case 231: /* exists_opt */ + case 274: /* analyze_opt */ + case 276: /* agg_func_opt */ + case 313: /* set_quantifier_opt */ { } break; - case 232: /* integer_list */ - case 233: /* variable_list */ - case 234: /* retention_list */ - case 238: /* column_def_list */ - case 239: /* tags_def_opt */ - case 241: /* multi_create_clause */ - case 242: /* tags_def */ - case 243: /* multi_drop_clause */ - case 249: /* specific_tags_opt */ - case 250: /* literal_list */ - case 252: /* col_name_list */ - case 255: /* func_name_list */ - case 266: /* func_list */ - case 270: /* expression_list */ - case 280: /* dnode_list */ - case 291: /* star_func_para_list */ - case 293: /* other_para_list */ - case 313: /* select_list */ - case 315: /* partition_by_clause_opt */ - case 317: /* group_by_clause_opt */ - case 319: /* select_sublist */ - case 323: /* group_by_list */ - case 325: /* order_by_clause_opt */ - case 329: /* sort_specification_list */ + case 233: /* integer_list */ + case 234: /* variable_list */ + case 235: /* retention_list */ + case 239: /* column_def_list */ + case 240: /* tags_def_opt */ + case 242: /* multi_create_clause */ + case 243: /* tags_def */ + case 244: /* multi_drop_clause */ + case 250: /* specific_tags_opt */ + case 251: /* literal_list */ + case 253: /* col_name_list */ + case 256: /* func_name_list */ + case 267: /* func_list */ + case 271: /* expression_list */ + case 281: /* dnode_list */ + case 292: /* star_func_para_list */ + case 294: /* other_para_list */ + case 314: /* select_list */ + case 316: /* partition_by_clause_opt */ + case 318: /* group_by_clause_opt */ + case 320: /* select_sublist */ + case 324: /* group_by_list */ + case 326: /* order_by_clause_opt */ + case 330: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy478)); + nodesDestroyList((yypminor->yy632)); } break; - case 235: /* alter_db_option */ - case 256: /* alter_table_option */ + case 236: /* alter_db_option */ + case 257: /* alter_table_option */ { } break; - case 247: /* type_name */ + case 248: /* type_name */ { } break; - case 296: /* compare_op */ - case 297: /* in_op */ + case 297: /* compare_op */ + case 298: /* in_op */ { } break; - case 309: /* join_type */ + case 310: /* join_type */ { } break; - case 322: /* fill_mode */ + case 323: /* fill_mode */ { } break; - case 331: /* ordering_specification_opt */ + case 332: /* ordering_specification_opt */ { } break; - case 332: /* null_ordering_opt */ + case 333: /* null_ordering_opt */ { } @@ -2208,438 +2199,439 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 219, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 219, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 220, 0 }, /* (2) account_options ::= */ - { 220, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 220, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 220, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 220, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 220, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 220, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 220, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 220, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 220, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 221, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 221, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 223, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 223, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 223, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 223, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 223, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 223, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 223, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 223, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 223, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 223, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 219, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 219, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 219, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 219, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 219, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - { 219, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 219, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - { 219, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - { 219, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 219, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 219, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - { 219, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 225, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ - { 226, -1 }, /* (37) dnode_host_name ::= NK_ID */ - { 226, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ - { 219, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - { 219, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 219, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 219, -5 }, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 219, -4 }, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ - { 219, -2 }, /* (51) cmd ::= USE db_name */ - { 219, -4 }, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 227, -3 }, /* (53) not_exists_opt ::= IF NOT EXISTS */ - { 227, 0 }, /* (54) not_exists_opt ::= */ - { 230, -2 }, /* (55) exists_opt ::= IF EXISTS */ - { 230, 0 }, /* (56) exists_opt ::= */ - { 229, 0 }, /* (57) db_options ::= */ - { 229, -3 }, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ - { 229, -3 }, /* (59) db_options ::= db_options CACHE NK_INTEGER */ - { 229, -3 }, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ - { 229, -3 }, /* (61) db_options ::= db_options COMP NK_INTEGER */ - { 229, -3 }, /* (62) db_options ::= db_options DAYS NK_INTEGER */ - { 229, -3 }, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ - { 229, -3 }, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ - { 229, -3 }, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ - { 229, -3 }, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ - { 229, -3 }, /* (67) db_options ::= db_options KEEP integer_list */ - { 229, -3 }, /* (68) db_options ::= db_options KEEP variable_list */ - { 229, -3 }, /* (69) db_options ::= db_options PRECISION NK_STRING */ - { 229, -3 }, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ - { 229, -3 }, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ - { 229, -3 }, /* (72) db_options ::= db_options TTL NK_INTEGER */ - { 229, -3 }, /* (73) db_options ::= db_options WAL NK_INTEGER */ - { 229, -3 }, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ - { 229, -3 }, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 229, -3 }, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 229, -3 }, /* (77) db_options ::= db_options RETENTIONS retention_list */ - { 231, -1 }, /* (78) alter_db_options ::= alter_db_option */ - { 231, -2 }, /* (79) alter_db_options ::= alter_db_options alter_db_option */ - { 235, -2 }, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ - { 235, -2 }, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ - { 235, -2 }, /* (82) alter_db_option ::= KEEP integer_list */ - { 235, -2 }, /* (83) alter_db_option ::= KEEP variable_list */ - { 235, -2 }, /* (84) alter_db_option ::= WAL NK_INTEGER */ - { 235, -2 }, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ - { 235, -2 }, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ - { 235, -2 }, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ - { 232, -1 }, /* (88) integer_list ::= NK_INTEGER */ - { 232, -3 }, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 233, -1 }, /* (90) variable_list ::= NK_VARIABLE */ - { 233, -3 }, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 234, -1 }, /* (92) retention_list ::= retention */ - { 234, -3 }, /* (93) retention_list ::= retention_list NK_COMMA retention */ - { 236, -3 }, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 219, -9 }, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 219, -3 }, /* (96) cmd ::= CREATE TABLE multi_create_clause */ - { 219, -9 }, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 219, -3 }, /* (98) cmd ::= DROP TABLE multi_drop_clause */ - { 219, -4 }, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ - { 219, -3 }, /* (100) cmd ::= ALTER TABLE alter_table_clause */ - { 219, -3 }, /* (101) cmd ::= ALTER STABLE alter_table_clause */ - { 244, -2 }, /* (102) alter_table_clause ::= full_table_name alter_table_options */ - { 244, -5 }, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 244, -4 }, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 244, -5 }, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 244, -5 }, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 244, -5 }, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 244, -4 }, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 244, -5 }, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 244, -5 }, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 244, -6 }, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - { 241, -1 }, /* (112) multi_create_clause ::= create_subtable_clause */ - { 241, -2 }, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 248, -9 }, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 243, -1 }, /* (115) multi_drop_clause ::= drop_table_clause */ - { 243, -2 }, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 251, -2 }, /* (117) drop_table_clause ::= exists_opt full_table_name */ - { 249, 0 }, /* (118) specific_tags_opt ::= */ - { 249, -3 }, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 237, -1 }, /* (120) full_table_name ::= table_name */ - { 237, -3 }, /* (121) full_table_name ::= db_name NK_DOT table_name */ - { 238, -1 }, /* (122) column_def_list ::= column_def */ - { 238, -3 }, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ - { 254, -2 }, /* (124) column_def ::= column_name type_name */ - { 254, -4 }, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ - { 247, -1 }, /* (126) type_name ::= BOOL */ - { 247, -1 }, /* (127) type_name ::= TINYINT */ - { 247, -1 }, /* (128) type_name ::= SMALLINT */ - { 247, -1 }, /* (129) type_name ::= INT */ - { 247, -1 }, /* (130) type_name ::= INTEGER */ - { 247, -1 }, /* (131) type_name ::= BIGINT */ - { 247, -1 }, /* (132) type_name ::= FLOAT */ - { 247, -1 }, /* (133) type_name ::= DOUBLE */ - { 247, -4 }, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 247, -1 }, /* (135) type_name ::= TIMESTAMP */ - { 247, -4 }, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 247, -2 }, /* (137) type_name ::= TINYINT UNSIGNED */ - { 247, -2 }, /* (138) type_name ::= SMALLINT UNSIGNED */ - { 247, -2 }, /* (139) type_name ::= INT UNSIGNED */ - { 247, -2 }, /* (140) type_name ::= BIGINT UNSIGNED */ - { 247, -1 }, /* (141) type_name ::= JSON */ - { 247, -4 }, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 247, -1 }, /* (143) type_name ::= MEDIUMBLOB */ - { 247, -1 }, /* (144) type_name ::= BLOB */ - { 247, -4 }, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 247, -1 }, /* (146) type_name ::= DECIMAL */ - { 247, -4 }, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 247, -6 }, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 239, 0 }, /* (149) tags_def_opt ::= */ - { 239, -1 }, /* (150) tags_def_opt ::= tags_def */ - { 242, -4 }, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 240, 0 }, /* (152) table_options ::= */ - { 240, -3 }, /* (153) table_options ::= table_options COMMENT NK_STRING */ - { 240, -3 }, /* (154) table_options ::= table_options KEEP integer_list */ - { 240, -3 }, /* (155) table_options ::= table_options KEEP variable_list */ - { 240, -3 }, /* (156) table_options ::= table_options TTL NK_INTEGER */ - { 240, -5 }, /* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 240, -5 }, /* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 240, -3 }, /* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 240, -3 }, /* (160) table_options ::= table_options DELAY NK_INTEGER */ - { 245, -1 }, /* (161) alter_table_options ::= alter_table_option */ - { 245, -2 }, /* (162) alter_table_options ::= alter_table_options alter_table_option */ - { 256, -2 }, /* (163) alter_table_option ::= COMMENT NK_STRING */ - { 256, -2 }, /* (164) alter_table_option ::= KEEP integer_list */ - { 256, -2 }, /* (165) alter_table_option ::= KEEP variable_list */ - { 256, -2 }, /* (166) alter_table_option ::= TTL NK_INTEGER */ - { 252, -1 }, /* (167) col_name_list ::= col_name */ - { 252, -3 }, /* (168) col_name_list ::= col_name_list NK_COMMA col_name */ - { 257, -1 }, /* (169) col_name ::= column_name */ - { 219, -2 }, /* (170) cmd ::= SHOW DNODES */ - { 219, -2 }, /* (171) cmd ::= SHOW USERS */ - { 219, -2 }, /* (172) cmd ::= SHOW DATABASES */ - { 219, -4 }, /* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 219, -4 }, /* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 219, -3 }, /* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 219, -2 }, /* (176) cmd ::= SHOW MNODES */ - { 219, -2 }, /* (177) cmd ::= SHOW MODULES */ - { 219, -2 }, /* (178) cmd ::= SHOW QNODES */ - { 219, -2 }, /* (179) cmd ::= SHOW FUNCTIONS */ - { 219, -5 }, /* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 219, -2 }, /* (181) cmd ::= SHOW STREAMS */ - { 219, -2 }, /* (182) cmd ::= SHOW ACCOUNTS */ - { 219, -2 }, /* (183) cmd ::= SHOW APPS */ - { 219, -2 }, /* (184) cmd ::= SHOW CONNECTIONS */ - { 219, -2 }, /* (185) cmd ::= SHOW LICENCE */ - { 219, -2 }, /* (186) cmd ::= SHOW GRANTS */ - { 219, -4 }, /* (187) cmd ::= SHOW CREATE DATABASE db_name */ - { 219, -4 }, /* (188) cmd ::= SHOW CREATE TABLE full_table_name */ - { 219, -4 }, /* (189) cmd ::= SHOW CREATE STABLE full_table_name */ - { 219, -2 }, /* (190) cmd ::= SHOW QUERIES */ - { 219, -2 }, /* (191) cmd ::= SHOW SCORES */ - { 219, -2 }, /* (192) cmd ::= SHOW TOPICS */ - { 219, -2 }, /* (193) cmd ::= SHOW VARIABLES */ - { 219, -2 }, /* (194) cmd ::= SHOW BNODES */ - { 219, -2 }, /* (195) cmd ::= SHOW SNODES */ - { 258, 0 }, /* (196) db_name_cond_opt ::= */ - { 258, -2 }, /* (197) db_name_cond_opt ::= db_name NK_DOT */ - { 259, 0 }, /* (198) like_pattern_opt ::= */ - { 259, -2 }, /* (199) like_pattern_opt ::= LIKE NK_STRING */ - { 260, -1 }, /* (200) table_name_cond ::= table_name */ - { 261, 0 }, /* (201) from_db_opt ::= */ - { 261, -2 }, /* (202) from_db_opt ::= FROM db_name */ - { 255, -1 }, /* (203) func_name_list ::= func_name */ - { 255, -3 }, /* (204) func_name_list ::= func_name_list NK_COMMA col_name */ - { 262, -1 }, /* (205) func_name ::= function_name */ - { 219, -8 }, /* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 219, -10 }, /* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 219, -6 }, /* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 265, 0 }, /* (209) index_options ::= */ - { 265, -9 }, /* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 265, -11 }, /* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 266, -1 }, /* (212) func_list ::= func */ - { 266, -3 }, /* (213) func_list ::= func_list NK_COMMA func */ - { 269, -4 }, /* (214) func ::= function_name NK_LP expression_list NK_RP */ - { 219, -6 }, /* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 219, -6 }, /* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 219, -4 }, /* (217) cmd ::= DROP TOPIC exists_opt topic_name */ - { 219, -2 }, /* (218) cmd ::= DESC full_table_name */ - { 219, -2 }, /* (219) cmd ::= DESCRIBE full_table_name */ - { 219, -3 }, /* (220) cmd ::= RESET QUERY CACHE */ - { 219, -4 }, /* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 273, 0 }, /* (222) analyze_opt ::= */ - { 273, -1 }, /* (223) analyze_opt ::= ANALYZE */ - { 274, 0 }, /* (224) explain_options ::= */ - { 274, -3 }, /* (225) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 274, -3 }, /* (226) explain_options ::= explain_options RATIO NK_FLOAT */ - { 219, -6 }, /* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 219, -9 }, /* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 219, -3 }, /* (229) cmd ::= DROP FUNCTION function_name */ - { 275, 0 }, /* (230) agg_func_opt ::= */ - { 275, -1 }, /* (231) agg_func_opt ::= AGGREGATE */ - { 276, 0 }, /* (232) bufsize_opt ::= */ - { 276, -2 }, /* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 219, -8 }, /* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 219, -4 }, /* (235) cmd ::= DROP STREAM exists_opt stream_name */ - { 279, 0 }, /* (236) into_opt ::= */ - { 279, -2 }, /* (237) into_opt ::= INTO full_table_name */ - { 278, 0 }, /* (238) stream_options ::= */ - { 278, -3 }, /* (239) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 278, -3 }, /* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 278, -3 }, /* (241) stream_options ::= stream_options WATERMARK duration_literal */ - { 219, -3 }, /* (242) cmd ::= KILL CONNECTION NK_INTEGER */ - { 219, -3 }, /* (243) cmd ::= KILL QUERY NK_INTEGER */ - { 219, -4 }, /* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 219, -4 }, /* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 219, -3 }, /* (246) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 280, -2 }, /* (247) dnode_list ::= DNODE NK_INTEGER */ - { 280, -3 }, /* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 219, -3 }, /* (249) cmd ::= SYNCDB db_name REPLICA */ - { 219, -1 }, /* (250) cmd ::= query_expression */ - { 222, -1 }, /* (251) literal ::= NK_INTEGER */ - { 222, -1 }, /* (252) literal ::= NK_FLOAT */ - { 222, -1 }, /* (253) literal ::= NK_STRING */ - { 222, -1 }, /* (254) literal ::= NK_BOOL */ - { 222, -2 }, /* (255) literal ::= TIMESTAMP NK_STRING */ - { 222, -1 }, /* (256) literal ::= duration_literal */ - { 222, -1 }, /* (257) literal ::= NULL */ - { 222, -1 }, /* (258) literal ::= NK_QUESTION */ - { 267, -1 }, /* (259) duration_literal ::= NK_VARIABLE */ - { 281, -1 }, /* (260) signed ::= NK_INTEGER */ - { 281, -2 }, /* (261) signed ::= NK_PLUS NK_INTEGER */ - { 281, -2 }, /* (262) signed ::= NK_MINUS NK_INTEGER */ - { 281, -1 }, /* (263) signed ::= NK_FLOAT */ - { 281, -2 }, /* (264) signed ::= NK_PLUS NK_FLOAT */ - { 281, -2 }, /* (265) signed ::= NK_MINUS NK_FLOAT */ - { 282, -1 }, /* (266) signed_literal ::= signed */ - { 282, -1 }, /* (267) signed_literal ::= NK_STRING */ - { 282, -1 }, /* (268) signed_literal ::= NK_BOOL */ - { 282, -2 }, /* (269) signed_literal ::= TIMESTAMP NK_STRING */ - { 282, -1 }, /* (270) signed_literal ::= duration_literal */ - { 282, -1 }, /* (271) signed_literal ::= NULL */ - { 250, -1 }, /* (272) literal_list ::= signed_literal */ - { 250, -3 }, /* (273) literal_list ::= literal_list NK_COMMA signed_literal */ - { 228, -1 }, /* (274) db_name ::= NK_ID */ - { 253, -1 }, /* (275) table_name ::= NK_ID */ - { 246, -1 }, /* (276) column_name ::= NK_ID */ - { 263, -1 }, /* (277) function_name ::= NK_ID */ - { 283, -1 }, /* (278) table_alias ::= NK_ID */ - { 284, -1 }, /* (279) column_alias ::= NK_ID */ - { 224, -1 }, /* (280) user_name ::= NK_ID */ - { 264, -1 }, /* (281) index_name ::= NK_ID */ - { 271, -1 }, /* (282) topic_name ::= NK_ID */ - { 277, -1 }, /* (283) stream_name ::= NK_ID */ - { 285, -1 }, /* (284) expression ::= literal */ - { 285, -1 }, /* (285) expression ::= pseudo_column */ - { 285, -1 }, /* (286) expression ::= column_reference */ - { 285, -1 }, /* (287) expression ::= function_expression */ - { 285, -1 }, /* (288) expression ::= subquery */ - { 285, -3 }, /* (289) expression ::= NK_LP expression NK_RP */ - { 285, -2 }, /* (290) expression ::= NK_PLUS expression */ - { 285, -2 }, /* (291) expression ::= NK_MINUS expression */ - { 285, -3 }, /* (292) expression ::= expression NK_PLUS expression */ - { 285, -3 }, /* (293) expression ::= expression NK_MINUS expression */ - { 285, -3 }, /* (294) expression ::= expression NK_STAR expression */ - { 285, -3 }, /* (295) expression ::= expression NK_SLASH expression */ - { 285, -3 }, /* (296) expression ::= expression NK_REM expression */ - { 285, -3 }, /* (297) expression ::= column_reference NK_ARROW NK_STRING */ - { 270, -1 }, /* (298) expression_list ::= expression */ - { 270, -3 }, /* (299) expression_list ::= expression_list NK_COMMA expression */ - { 287, -1 }, /* (300) column_reference ::= column_name */ - { 287, -3 }, /* (301) column_reference ::= table_name NK_DOT column_name */ - { 286, -1 }, /* (302) pseudo_column ::= ROWTS */ - { 286, -1 }, /* (303) pseudo_column ::= TBNAME */ - { 286, -1 }, /* (304) pseudo_column ::= QSTARTTS */ - { 286, -1 }, /* (305) pseudo_column ::= QENDTS */ - { 286, -1 }, /* (306) pseudo_column ::= WSTARTTS */ - { 286, -1 }, /* (307) pseudo_column ::= WENDTS */ - { 286, -1 }, /* (308) pseudo_column ::= WDURATION */ - { 288, -4 }, /* (309) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 288, -4 }, /* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 288, -6 }, /* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 288, -3 }, /* (312) function_expression ::= noarg_func NK_LP NK_RP */ - { 292, -1 }, /* (313) noarg_func ::= NOW */ - { 292, -1 }, /* (314) noarg_func ::= TODAY */ - { 290, -1 }, /* (315) star_func ::= COUNT */ - { 290, -1 }, /* (316) star_func ::= FIRST */ - { 290, -1 }, /* (317) star_func ::= LAST */ - { 290, -1 }, /* (318) star_func ::= LAST_ROW */ - { 291, -1 }, /* (319) star_func_para_list ::= NK_STAR */ - { 291, -1 }, /* (320) star_func_para_list ::= other_para_list */ - { 293, -1 }, /* (321) other_para_list ::= star_func_para */ - { 293, -3 }, /* (322) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 294, -1 }, /* (323) star_func_para ::= expression */ - { 294, -3 }, /* (324) star_func_para ::= table_name NK_DOT NK_STAR */ - { 295, -3 }, /* (325) predicate ::= expression compare_op expression */ - { 295, -5 }, /* (326) predicate ::= expression BETWEEN expression AND expression */ - { 295, -6 }, /* (327) predicate ::= expression NOT BETWEEN expression AND expression */ - { 295, -3 }, /* (328) predicate ::= expression IS NULL */ - { 295, -4 }, /* (329) predicate ::= expression IS NOT NULL */ - { 295, -3 }, /* (330) predicate ::= expression in_op in_predicate_value */ - { 296, -1 }, /* (331) compare_op ::= NK_LT */ - { 296, -1 }, /* (332) compare_op ::= NK_GT */ - { 296, -1 }, /* (333) compare_op ::= NK_LE */ - { 296, -1 }, /* (334) compare_op ::= NK_GE */ - { 296, -1 }, /* (335) compare_op ::= NK_NE */ - { 296, -1 }, /* (336) compare_op ::= NK_EQ */ - { 296, -1 }, /* (337) compare_op ::= LIKE */ - { 296, -2 }, /* (338) compare_op ::= NOT LIKE */ - { 296, -1 }, /* (339) compare_op ::= MATCH */ - { 296, -1 }, /* (340) compare_op ::= NMATCH */ - { 296, -1 }, /* (341) compare_op ::= CONTAINS */ - { 297, -1 }, /* (342) in_op ::= IN */ - { 297, -2 }, /* (343) in_op ::= NOT IN */ - { 298, -3 }, /* (344) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 299, -1 }, /* (345) boolean_value_expression ::= boolean_primary */ - { 299, -2 }, /* (346) boolean_value_expression ::= NOT boolean_primary */ - { 299, -3 }, /* (347) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 299, -3 }, /* (348) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 300, -1 }, /* (349) boolean_primary ::= predicate */ - { 300, -3 }, /* (350) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 301, -1 }, /* (351) common_expression ::= expression */ - { 301, -1 }, /* (352) common_expression ::= boolean_value_expression */ - { 302, -2 }, /* (353) from_clause ::= FROM table_reference_list */ - { 303, -1 }, /* (354) table_reference_list ::= table_reference */ - { 303, -3 }, /* (355) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 304, -1 }, /* (356) table_reference ::= table_primary */ - { 304, -1 }, /* (357) table_reference ::= joined_table */ - { 305, -2 }, /* (358) table_primary ::= table_name alias_opt */ - { 305, -4 }, /* (359) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 305, -2 }, /* (360) table_primary ::= subquery alias_opt */ - { 305, -1 }, /* (361) table_primary ::= parenthesized_joined_table */ - { 307, 0 }, /* (362) alias_opt ::= */ - { 307, -1 }, /* (363) alias_opt ::= table_alias */ - { 307, -2 }, /* (364) alias_opt ::= AS table_alias */ - { 308, -3 }, /* (365) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 308, -3 }, /* (366) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 306, -6 }, /* (367) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 309, 0 }, /* (368) join_type ::= */ - { 309, -1 }, /* (369) join_type ::= INNER */ - { 311, -9 }, /* (370) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 312, 0 }, /* (371) set_quantifier_opt ::= */ - { 312, -1 }, /* (372) set_quantifier_opt ::= DISTINCT */ - { 312, -1 }, /* (373) set_quantifier_opt ::= ALL */ - { 313, -1 }, /* (374) select_list ::= NK_STAR */ - { 313, -1 }, /* (375) select_list ::= select_sublist */ - { 319, -1 }, /* (376) select_sublist ::= select_item */ - { 319, -3 }, /* (377) select_sublist ::= select_sublist NK_COMMA select_item */ - { 320, -1 }, /* (378) select_item ::= common_expression */ - { 320, -2 }, /* (379) select_item ::= common_expression column_alias */ - { 320, -3 }, /* (380) select_item ::= common_expression AS column_alias */ - { 320, -3 }, /* (381) select_item ::= table_name NK_DOT NK_STAR */ - { 314, 0 }, /* (382) where_clause_opt ::= */ - { 314, -2 }, /* (383) where_clause_opt ::= WHERE search_condition */ - { 315, 0 }, /* (384) partition_by_clause_opt ::= */ - { 315, -3 }, /* (385) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 316, 0 }, /* (386) twindow_clause_opt ::= */ - { 316, -6 }, /* (387) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 316, -4 }, /* (388) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 316, -6 }, /* (389) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 316, -8 }, /* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 268, 0 }, /* (391) sliding_opt ::= */ - { 268, -4 }, /* (392) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 321, 0 }, /* (393) fill_opt ::= */ - { 321, -4 }, /* (394) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 321, -6 }, /* (395) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 322, -1 }, /* (396) fill_mode ::= NONE */ - { 322, -1 }, /* (397) fill_mode ::= PREV */ - { 322, -1 }, /* (398) fill_mode ::= NULL */ - { 322, -1 }, /* (399) fill_mode ::= LINEAR */ - { 322, -1 }, /* (400) fill_mode ::= NEXT */ - { 317, 0 }, /* (401) group_by_clause_opt ::= */ - { 317, -3 }, /* (402) group_by_clause_opt ::= GROUP BY group_by_list */ - { 323, -1 }, /* (403) group_by_list ::= expression */ - { 323, -3 }, /* (404) group_by_list ::= group_by_list NK_COMMA expression */ - { 318, 0 }, /* (405) having_clause_opt ::= */ - { 318, -2 }, /* (406) having_clause_opt ::= HAVING search_condition */ - { 272, -4 }, /* (407) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 324, -1 }, /* (408) query_expression_body ::= query_primary */ - { 324, -4 }, /* (409) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 328, -1 }, /* (410) query_primary ::= query_specification */ - { 325, 0 }, /* (411) order_by_clause_opt ::= */ - { 325, -3 }, /* (412) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 326, 0 }, /* (413) slimit_clause_opt ::= */ - { 326, -2 }, /* (414) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 326, -4 }, /* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 326, -4 }, /* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 327, 0 }, /* (417) limit_clause_opt ::= */ - { 327, -2 }, /* (418) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 327, -4 }, /* (419) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 327, -4 }, /* (420) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 289, -3 }, /* (421) subquery ::= NK_LP query_expression NK_RP */ - { 310, -1 }, /* (422) search_condition ::= common_expression */ - { 329, -1 }, /* (423) sort_specification_list ::= sort_specification */ - { 329, -3 }, /* (424) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 330, -3 }, /* (425) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 331, 0 }, /* (426) ordering_specification_opt ::= */ - { 331, -1 }, /* (427) ordering_specification_opt ::= ASC */ - { 331, -1 }, /* (428) ordering_specification_opt ::= DESC */ - { 332, 0 }, /* (429) null_ordering_opt ::= */ - { 332, -2 }, /* (430) null_ordering_opt ::= NULLS FIRST */ - { 332, -2 }, /* (431) null_ordering_opt ::= NULLS LAST */ + { 220, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 220, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 221, 0 }, /* (2) account_options ::= */ + { 221, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 221, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 221, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 221, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 221, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 221, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 221, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 221, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 221, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 222, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 222, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 224, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 224, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 224, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 224, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 224, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 224, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 224, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 224, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 224, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 224, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 220, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 220, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 220, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 220, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 220, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + { 220, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 220, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + { 220, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + { 220, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 220, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 220, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + { 220, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 226, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ + { 227, -1 }, /* (37) dnode_host_name ::= NK_ID */ + { 227, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ + { 220, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + { 220, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 220, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 220, -5 }, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 220, -4 }, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ + { 220, -2 }, /* (51) cmd ::= USE db_name */ + { 220, -4 }, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 228, -3 }, /* (53) not_exists_opt ::= IF NOT EXISTS */ + { 228, 0 }, /* (54) not_exists_opt ::= */ + { 231, -2 }, /* (55) exists_opt ::= IF EXISTS */ + { 231, 0 }, /* (56) exists_opt ::= */ + { 230, 0 }, /* (57) db_options ::= */ + { 230, -3 }, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ + { 230, -3 }, /* (59) db_options ::= db_options CACHE NK_INTEGER */ + { 230, -3 }, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ + { 230, -3 }, /* (61) db_options ::= db_options COMP NK_INTEGER */ + { 230, -3 }, /* (62) db_options ::= db_options DAYS NK_INTEGER */ + { 230, -3 }, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ + { 230, -3 }, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ + { 230, -3 }, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ + { 230, -3 }, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ + { 230, -3 }, /* (67) db_options ::= db_options KEEP integer_list */ + { 230, -3 }, /* (68) db_options ::= db_options KEEP variable_list */ + { 230, -3 }, /* (69) db_options ::= db_options PRECISION NK_STRING */ + { 230, -3 }, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ + { 230, -3 }, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ + { 230, -3 }, /* (72) db_options ::= db_options TTL NK_INTEGER */ + { 230, -3 }, /* (73) db_options ::= db_options WAL NK_INTEGER */ + { 230, -3 }, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ + { 230, -3 }, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 230, -3 }, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 230, -3 }, /* (77) db_options ::= db_options RETENTIONS retention_list */ + { 232, -1 }, /* (78) alter_db_options ::= alter_db_option */ + { 232, -2 }, /* (79) alter_db_options ::= alter_db_options alter_db_option */ + { 236, -2 }, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ + { 236, -2 }, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ + { 236, -2 }, /* (82) alter_db_option ::= KEEP integer_list */ + { 236, -2 }, /* (83) alter_db_option ::= KEEP variable_list */ + { 236, -2 }, /* (84) alter_db_option ::= WAL NK_INTEGER */ + { 236, -2 }, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ + { 236, -2 }, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ + { 236, -2 }, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ + { 233, -1 }, /* (88) integer_list ::= NK_INTEGER */ + { 233, -3 }, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 234, -1 }, /* (90) variable_list ::= NK_VARIABLE */ + { 234, -3 }, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 235, -1 }, /* (92) retention_list ::= retention */ + { 235, -3 }, /* (93) retention_list ::= retention_list NK_COMMA retention */ + { 237, -3 }, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 220, -9 }, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 220, -3 }, /* (96) cmd ::= CREATE TABLE multi_create_clause */ + { 220, -9 }, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 220, -3 }, /* (98) cmd ::= DROP TABLE multi_drop_clause */ + { 220, -4 }, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ + { 220, -3 }, /* (100) cmd ::= ALTER TABLE alter_table_clause */ + { 220, -3 }, /* (101) cmd ::= ALTER STABLE alter_table_clause */ + { 245, -2 }, /* (102) alter_table_clause ::= full_table_name alter_table_options */ + { 245, -5 }, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 245, -4 }, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 245, -5 }, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 245, -5 }, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 245, -5 }, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 245, -4 }, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 245, -5 }, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 245, -5 }, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 245, -6 }, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 242, -1 }, /* (112) multi_create_clause ::= create_subtable_clause */ + { 242, -2 }, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 249, -9 }, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 244, -1 }, /* (115) multi_drop_clause ::= drop_table_clause */ + { 244, -2 }, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 252, -2 }, /* (117) drop_table_clause ::= exists_opt full_table_name */ + { 250, 0 }, /* (118) specific_tags_opt ::= */ + { 250, -3 }, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 238, -1 }, /* (120) full_table_name ::= table_name */ + { 238, -3 }, /* (121) full_table_name ::= db_name NK_DOT table_name */ + { 239, -1 }, /* (122) column_def_list ::= column_def */ + { 239, -3 }, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ + { 255, -2 }, /* (124) column_def ::= column_name type_name */ + { 255, -4 }, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ + { 248, -1 }, /* (126) type_name ::= BOOL */ + { 248, -1 }, /* (127) type_name ::= TINYINT */ + { 248, -1 }, /* (128) type_name ::= SMALLINT */ + { 248, -1 }, /* (129) type_name ::= INT */ + { 248, -1 }, /* (130) type_name ::= INTEGER */ + { 248, -1 }, /* (131) type_name ::= BIGINT */ + { 248, -1 }, /* (132) type_name ::= FLOAT */ + { 248, -1 }, /* (133) type_name ::= DOUBLE */ + { 248, -4 }, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 248, -1 }, /* (135) type_name ::= TIMESTAMP */ + { 248, -4 }, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 248, -2 }, /* (137) type_name ::= TINYINT UNSIGNED */ + { 248, -2 }, /* (138) type_name ::= SMALLINT UNSIGNED */ + { 248, -2 }, /* (139) type_name ::= INT UNSIGNED */ + { 248, -2 }, /* (140) type_name ::= BIGINT UNSIGNED */ + { 248, -1 }, /* (141) type_name ::= JSON */ + { 248, -4 }, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 248, -1 }, /* (143) type_name ::= MEDIUMBLOB */ + { 248, -1 }, /* (144) type_name ::= BLOB */ + { 248, -4 }, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 248, -1 }, /* (146) type_name ::= DECIMAL */ + { 248, -4 }, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 248, -6 }, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 240, 0 }, /* (149) tags_def_opt ::= */ + { 240, -1 }, /* (150) tags_def_opt ::= tags_def */ + { 243, -4 }, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 241, 0 }, /* (152) table_options ::= */ + { 241, -3 }, /* (153) table_options ::= table_options COMMENT NK_STRING */ + { 241, -3 }, /* (154) table_options ::= table_options KEEP integer_list */ + { 241, -3 }, /* (155) table_options ::= table_options KEEP variable_list */ + { 241, -3 }, /* (156) table_options ::= table_options TTL NK_INTEGER */ + { 241, -5 }, /* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 241, -5 }, /* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 241, -3 }, /* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 241, -3 }, /* (160) table_options ::= table_options DELAY NK_INTEGER */ + { 246, -1 }, /* (161) alter_table_options ::= alter_table_option */ + { 246, -2 }, /* (162) alter_table_options ::= alter_table_options alter_table_option */ + { 257, -2 }, /* (163) alter_table_option ::= COMMENT NK_STRING */ + { 257, -2 }, /* (164) alter_table_option ::= KEEP integer_list */ + { 257, -2 }, /* (165) alter_table_option ::= KEEP variable_list */ + { 257, -2 }, /* (166) alter_table_option ::= TTL NK_INTEGER */ + { 253, -1 }, /* (167) col_name_list ::= col_name */ + { 253, -3 }, /* (168) col_name_list ::= col_name_list NK_COMMA col_name */ + { 258, -1 }, /* (169) col_name ::= column_name */ + { 220, -2 }, /* (170) cmd ::= SHOW DNODES */ + { 220, -2 }, /* (171) cmd ::= SHOW USERS */ + { 220, -2 }, /* (172) cmd ::= SHOW DATABASES */ + { 220, -4 }, /* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 220, -4 }, /* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 220, -3 }, /* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 220, -2 }, /* (176) cmd ::= SHOW MNODES */ + { 220, -2 }, /* (177) cmd ::= SHOW MODULES */ + { 220, -2 }, /* (178) cmd ::= SHOW QNODES */ + { 220, -2 }, /* (179) cmd ::= SHOW FUNCTIONS */ + { 220, -5 }, /* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 220, -2 }, /* (181) cmd ::= SHOW STREAMS */ + { 220, -2 }, /* (182) cmd ::= SHOW ACCOUNTS */ + { 220, -2 }, /* (183) cmd ::= SHOW APPS */ + { 220, -2 }, /* (184) cmd ::= SHOW CONNECTIONS */ + { 220, -2 }, /* (185) cmd ::= SHOW LICENCE */ + { 220, -2 }, /* (186) cmd ::= SHOW GRANTS */ + { 220, -4 }, /* (187) cmd ::= SHOW CREATE DATABASE db_name */ + { 220, -4 }, /* (188) cmd ::= SHOW CREATE TABLE full_table_name */ + { 220, -4 }, /* (189) cmd ::= SHOW CREATE STABLE full_table_name */ + { 220, -2 }, /* (190) cmd ::= SHOW QUERIES */ + { 220, -2 }, /* (191) cmd ::= SHOW SCORES */ + { 220, -2 }, /* (192) cmd ::= SHOW TOPICS */ + { 220, -2 }, /* (193) cmd ::= SHOW VARIABLES */ + { 220, -2 }, /* (194) cmd ::= SHOW BNODES */ + { 220, -2 }, /* (195) cmd ::= SHOW SNODES */ + { 259, 0 }, /* (196) db_name_cond_opt ::= */ + { 259, -2 }, /* (197) db_name_cond_opt ::= db_name NK_DOT */ + { 260, 0 }, /* (198) like_pattern_opt ::= */ + { 260, -2 }, /* (199) like_pattern_opt ::= LIKE NK_STRING */ + { 261, -1 }, /* (200) table_name_cond ::= table_name */ + { 262, 0 }, /* (201) from_db_opt ::= */ + { 262, -2 }, /* (202) from_db_opt ::= FROM db_name */ + { 256, -1 }, /* (203) func_name_list ::= func_name */ + { 256, -3 }, /* (204) func_name_list ::= func_name_list NK_COMMA col_name */ + { 263, -1 }, /* (205) func_name ::= function_name */ + { 220, -8 }, /* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 220, -10 }, /* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 220, -6 }, /* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 266, 0 }, /* (209) index_options ::= */ + { 266, -9 }, /* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 266, -11 }, /* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 267, -1 }, /* (212) func_list ::= func */ + { 267, -3 }, /* (213) func_list ::= func_list NK_COMMA func */ + { 270, -4 }, /* (214) func ::= function_name NK_LP expression_list NK_RP */ + { 220, -6 }, /* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 220, -6 }, /* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 220, -4 }, /* (217) cmd ::= DROP TOPIC exists_opt topic_name */ + { 220, -2 }, /* (218) cmd ::= DESC full_table_name */ + { 220, -2 }, /* (219) cmd ::= DESCRIBE full_table_name */ + { 220, -3 }, /* (220) cmd ::= RESET QUERY CACHE */ + { 220, -4 }, /* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 274, 0 }, /* (222) analyze_opt ::= */ + { 274, -1 }, /* (223) analyze_opt ::= ANALYZE */ + { 275, 0 }, /* (224) explain_options ::= */ + { 275, -3 }, /* (225) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 275, -3 }, /* (226) explain_options ::= explain_options RATIO NK_FLOAT */ + { 220, -6 }, /* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 220, -9 }, /* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 220, -3 }, /* (229) cmd ::= DROP FUNCTION function_name */ + { 276, 0 }, /* (230) agg_func_opt ::= */ + { 276, -1 }, /* (231) agg_func_opt ::= AGGREGATE */ + { 277, 0 }, /* (232) bufsize_opt ::= */ + { 277, -2 }, /* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 220, -8 }, /* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 220, -4 }, /* (235) cmd ::= DROP STREAM exists_opt stream_name */ + { 280, 0 }, /* (236) into_opt ::= */ + { 280, -2 }, /* (237) into_opt ::= INTO full_table_name */ + { 279, 0 }, /* (238) stream_options ::= */ + { 279, -3 }, /* (239) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 279, -3 }, /* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 279, -3 }, /* (241) stream_options ::= stream_options WATERMARK duration_literal */ + { 220, -3 }, /* (242) cmd ::= KILL CONNECTION NK_INTEGER */ + { 220, -3 }, /* (243) cmd ::= KILL QUERY NK_INTEGER */ + { 220, -4 }, /* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 220, -4 }, /* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 220, -3 }, /* (246) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 281, -2 }, /* (247) dnode_list ::= DNODE NK_INTEGER */ + { 281, -3 }, /* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 220, -3 }, /* (249) cmd ::= SYNCDB db_name REPLICA */ + { 220, -1 }, /* (250) cmd ::= query_expression */ + { 223, -1 }, /* (251) literal ::= NK_INTEGER */ + { 223, -1 }, /* (252) literal ::= NK_FLOAT */ + { 223, -1 }, /* (253) literal ::= NK_STRING */ + { 223, -1 }, /* (254) literal ::= NK_BOOL */ + { 223, -2 }, /* (255) literal ::= TIMESTAMP NK_STRING */ + { 223, -1 }, /* (256) literal ::= duration_literal */ + { 223, -1 }, /* (257) literal ::= NULL */ + { 223, -1 }, /* (258) literal ::= NK_QUESTION */ + { 268, -1 }, /* (259) duration_literal ::= NK_VARIABLE */ + { 282, -1 }, /* (260) signed ::= NK_INTEGER */ + { 282, -2 }, /* (261) signed ::= NK_PLUS NK_INTEGER */ + { 282, -2 }, /* (262) signed ::= NK_MINUS NK_INTEGER */ + { 282, -1 }, /* (263) signed ::= NK_FLOAT */ + { 282, -2 }, /* (264) signed ::= NK_PLUS NK_FLOAT */ + { 282, -2 }, /* (265) signed ::= NK_MINUS NK_FLOAT */ + { 283, -1 }, /* (266) signed_literal ::= signed */ + { 283, -1 }, /* (267) signed_literal ::= NK_STRING */ + { 283, -1 }, /* (268) signed_literal ::= NK_BOOL */ + { 283, -2 }, /* (269) signed_literal ::= TIMESTAMP NK_STRING */ + { 283, -1 }, /* (270) signed_literal ::= duration_literal */ + { 283, -1 }, /* (271) signed_literal ::= NULL */ + { 251, -1 }, /* (272) literal_list ::= signed_literal */ + { 251, -3 }, /* (273) literal_list ::= literal_list NK_COMMA signed_literal */ + { 229, -1 }, /* (274) db_name ::= NK_ID */ + { 254, -1 }, /* (275) table_name ::= NK_ID */ + { 247, -1 }, /* (276) column_name ::= NK_ID */ + { 264, -1 }, /* (277) function_name ::= NK_ID */ + { 284, -1 }, /* (278) table_alias ::= NK_ID */ + { 285, -1 }, /* (279) column_alias ::= NK_ID */ + { 225, -1 }, /* (280) user_name ::= NK_ID */ + { 265, -1 }, /* (281) index_name ::= NK_ID */ + { 272, -1 }, /* (282) topic_name ::= NK_ID */ + { 278, -1 }, /* (283) stream_name ::= NK_ID */ + { 286, -1 }, /* (284) expression ::= literal */ + { 286, -1 }, /* (285) expression ::= pseudo_column */ + { 286, -1 }, /* (286) expression ::= column_reference */ + { 286, -1 }, /* (287) expression ::= function_expression */ + { 286, -1 }, /* (288) expression ::= subquery */ + { 286, -3 }, /* (289) expression ::= NK_LP expression NK_RP */ + { 286, -2 }, /* (290) expression ::= NK_PLUS expression */ + { 286, -2 }, /* (291) expression ::= NK_MINUS expression */ + { 286, -3 }, /* (292) expression ::= expression NK_PLUS expression */ + { 286, -3 }, /* (293) expression ::= expression NK_MINUS expression */ + { 286, -3 }, /* (294) expression ::= expression NK_STAR expression */ + { 286, -3 }, /* (295) expression ::= expression NK_SLASH expression */ + { 286, -3 }, /* (296) expression ::= expression NK_REM expression */ + { 286, -3 }, /* (297) expression ::= column_reference NK_ARROW NK_STRING */ + { 271, -1 }, /* (298) expression_list ::= expression */ + { 271, -3 }, /* (299) expression_list ::= expression_list NK_COMMA expression */ + { 288, -1 }, /* (300) column_reference ::= column_name */ + { 288, -3 }, /* (301) column_reference ::= table_name NK_DOT column_name */ + { 287, -1 }, /* (302) pseudo_column ::= ROWTS */ + { 287, -1 }, /* (303) pseudo_column ::= TBNAME */ + { 287, -1 }, /* (304) pseudo_column ::= QSTARTTS */ + { 287, -1 }, /* (305) pseudo_column ::= QENDTS */ + { 287, -1 }, /* (306) pseudo_column ::= WSTARTTS */ + { 287, -1 }, /* (307) pseudo_column ::= WENDTS */ + { 287, -1 }, /* (308) pseudo_column ::= WDURATION */ + { 289, -4 }, /* (309) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 289, -4 }, /* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 289, -6 }, /* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 289, -3 }, /* (312) function_expression ::= noarg_func NK_LP NK_RP */ + { 293, -1 }, /* (313) noarg_func ::= NOW */ + { 293, -1 }, /* (314) noarg_func ::= TODAY */ + { 293, -1 }, /* (315) noarg_func ::= TIMEZONE */ + { 291, -1 }, /* (316) star_func ::= COUNT */ + { 291, -1 }, /* (317) star_func ::= FIRST */ + { 291, -1 }, /* (318) star_func ::= LAST */ + { 291, -1 }, /* (319) star_func ::= LAST_ROW */ + { 292, -1 }, /* (320) star_func_para_list ::= NK_STAR */ + { 292, -1 }, /* (321) star_func_para_list ::= other_para_list */ + { 294, -1 }, /* (322) other_para_list ::= star_func_para */ + { 294, -3 }, /* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 295, -1 }, /* (324) star_func_para ::= expression */ + { 295, -3 }, /* (325) star_func_para ::= table_name NK_DOT NK_STAR */ + { 296, -3 }, /* (326) predicate ::= expression compare_op expression */ + { 296, -5 }, /* (327) predicate ::= expression BETWEEN expression AND expression */ + { 296, -6 }, /* (328) predicate ::= expression NOT BETWEEN expression AND expression */ + { 296, -3 }, /* (329) predicate ::= expression IS NULL */ + { 296, -4 }, /* (330) predicate ::= expression IS NOT NULL */ + { 296, -3 }, /* (331) predicate ::= expression in_op in_predicate_value */ + { 297, -1 }, /* (332) compare_op ::= NK_LT */ + { 297, -1 }, /* (333) compare_op ::= NK_GT */ + { 297, -1 }, /* (334) compare_op ::= NK_LE */ + { 297, -1 }, /* (335) compare_op ::= NK_GE */ + { 297, -1 }, /* (336) compare_op ::= NK_NE */ + { 297, -1 }, /* (337) compare_op ::= NK_EQ */ + { 297, -1 }, /* (338) compare_op ::= LIKE */ + { 297, -2 }, /* (339) compare_op ::= NOT LIKE */ + { 297, -1 }, /* (340) compare_op ::= MATCH */ + { 297, -1 }, /* (341) compare_op ::= NMATCH */ + { 297, -1 }, /* (342) compare_op ::= CONTAINS */ + { 298, -1 }, /* (343) in_op ::= IN */ + { 298, -2 }, /* (344) in_op ::= NOT IN */ + { 299, -3 }, /* (345) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 300, -1 }, /* (346) boolean_value_expression ::= boolean_primary */ + { 300, -2 }, /* (347) boolean_value_expression ::= NOT boolean_primary */ + { 300, -3 }, /* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 300, -3 }, /* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 301, -1 }, /* (350) boolean_primary ::= predicate */ + { 301, -3 }, /* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 302, -1 }, /* (352) common_expression ::= expression */ + { 302, -1 }, /* (353) common_expression ::= boolean_value_expression */ + { 303, -2 }, /* (354) from_clause ::= FROM table_reference_list */ + { 304, -1 }, /* (355) table_reference_list ::= table_reference */ + { 304, -3 }, /* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 305, -1 }, /* (357) table_reference ::= table_primary */ + { 305, -1 }, /* (358) table_reference ::= joined_table */ + { 306, -2 }, /* (359) table_primary ::= table_name alias_opt */ + { 306, -4 }, /* (360) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 306, -2 }, /* (361) table_primary ::= subquery alias_opt */ + { 306, -1 }, /* (362) table_primary ::= parenthesized_joined_table */ + { 308, 0 }, /* (363) alias_opt ::= */ + { 308, -1 }, /* (364) alias_opt ::= table_alias */ + { 308, -2 }, /* (365) alias_opt ::= AS table_alias */ + { 309, -3 }, /* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 309, -3 }, /* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 307, -6 }, /* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 310, 0 }, /* (369) join_type ::= */ + { 310, -1 }, /* (370) join_type ::= INNER */ + { 312, -9 }, /* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 313, 0 }, /* (372) set_quantifier_opt ::= */ + { 313, -1 }, /* (373) set_quantifier_opt ::= DISTINCT */ + { 313, -1 }, /* (374) set_quantifier_opt ::= ALL */ + { 314, -1 }, /* (375) select_list ::= NK_STAR */ + { 314, -1 }, /* (376) select_list ::= select_sublist */ + { 320, -1 }, /* (377) select_sublist ::= select_item */ + { 320, -3 }, /* (378) select_sublist ::= select_sublist NK_COMMA select_item */ + { 321, -1 }, /* (379) select_item ::= common_expression */ + { 321, -2 }, /* (380) select_item ::= common_expression column_alias */ + { 321, -3 }, /* (381) select_item ::= common_expression AS column_alias */ + { 321, -3 }, /* (382) select_item ::= table_name NK_DOT NK_STAR */ + { 315, 0 }, /* (383) where_clause_opt ::= */ + { 315, -2 }, /* (384) where_clause_opt ::= WHERE search_condition */ + { 316, 0 }, /* (385) partition_by_clause_opt ::= */ + { 316, -3 }, /* (386) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 317, 0 }, /* (387) twindow_clause_opt ::= */ + { 317, -6 }, /* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 317, -4 }, /* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 317, -6 }, /* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 317, -8 }, /* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 269, 0 }, /* (392) sliding_opt ::= */ + { 269, -4 }, /* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 322, 0 }, /* (394) fill_opt ::= */ + { 322, -4 }, /* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 322, -6 }, /* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 323, -1 }, /* (397) fill_mode ::= NONE */ + { 323, -1 }, /* (398) fill_mode ::= PREV */ + { 323, -1 }, /* (399) fill_mode ::= NULL */ + { 323, -1 }, /* (400) fill_mode ::= LINEAR */ + { 323, -1 }, /* (401) fill_mode ::= NEXT */ + { 318, 0 }, /* (402) group_by_clause_opt ::= */ + { 318, -3 }, /* (403) group_by_clause_opt ::= GROUP BY group_by_list */ + { 324, -1 }, /* (404) group_by_list ::= expression */ + { 324, -3 }, /* (405) group_by_list ::= group_by_list NK_COMMA expression */ + { 319, 0 }, /* (406) having_clause_opt ::= */ + { 319, -2 }, /* (407) having_clause_opt ::= HAVING search_condition */ + { 273, -4 }, /* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 325, -1 }, /* (409) query_expression_body ::= query_primary */ + { 325, -4 }, /* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 329, -1 }, /* (411) query_primary ::= query_specification */ + { 326, 0 }, /* (412) order_by_clause_opt ::= */ + { 326, -3 }, /* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 327, 0 }, /* (414) slimit_clause_opt ::= */ + { 327, -2 }, /* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 327, -4 }, /* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 327, -4 }, /* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 328, 0 }, /* (418) limit_clause_opt ::= */ + { 328, -2 }, /* (419) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 328, -4 }, /* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 328, -4 }, /* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 290, -3 }, /* (422) subquery ::= NK_LP query_expression NK_RP */ + { 311, -1 }, /* (423) search_condition ::= common_expression */ + { 330, -1 }, /* (424) sort_specification_list ::= sort_specification */ + { 330, -3 }, /* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 331, -3 }, /* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 332, 0 }, /* (427) ordering_specification_opt ::= */ + { 332, -1 }, /* (428) ordering_specification_opt ::= ASC */ + { 332, -1 }, /* (429) ordering_specification_opt ::= DESC */ + { 333, 0 }, /* (430) null_ordering_opt ::= */ + { 333, -2 }, /* (431) null_ordering_opt ::= NULLS FIRST */ + { 333, -2 }, /* (432) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2728,11 +2720,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,220,&yymsp[0].minor); + yy_destructor(yypParser,221,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,221,&yymsp[0].minor); + yy_destructor(yypParser,222,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -2746,20 +2738,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,220,&yymsp[-2].minor); +{ yy_destructor(yypParser,221,&yymsp[-2].minor); { } - yy_destructor(yypParser,222,&yymsp[0].minor); + yy_destructor(yypParser,223,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,223,&yymsp[0].minor); +{ yy_destructor(yypParser,224,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,221,&yymsp[-1].minor); +{ yy_destructor(yypParser,222,&yymsp[-1].minor); { } - yy_destructor(yypParser,223,&yymsp[0].minor); + yy_destructor(yypParser,224,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -2773,31 +2765,31 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,222,&yymsp[0].minor); + yy_destructor(yypParser,223,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy479, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy537, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy479, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy537, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy537); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy479, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy537, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } break; case 30: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy537); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -2826,12 +2818,13 @@ static YYACTIONTYPE yy_reduce( case 283: /* stream_name ::= NK_ID */ yytestcase(yyruleno==283); case 313: /* noarg_func ::= NOW */ yytestcase(yyruleno==313); case 314: /* noarg_func ::= TODAY */ yytestcase(yyruleno==314); - case 315: /* star_func ::= COUNT */ yytestcase(yyruleno==315); - case 316: /* star_func ::= FIRST */ yytestcase(yyruleno==316); - case 317: /* star_func ::= LAST */ yytestcase(yyruleno==317); - case 318: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==318); -{ yylhsminor.yy479 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy479 = yylhsminor.yy479; + case 315: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==315); + case 316: /* star_func ::= COUNT */ yytestcase(yyruleno==316); + case 317: /* star_func ::= FIRST */ yytestcase(yyruleno==317); + case 318: /* star_func ::= LAST */ yytestcase(yyruleno==318); + case 319: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==319); +{ yylhsminor.yy537 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy537 = yylhsminor.yy537; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -2864,156 +2857,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 49: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy659, &yymsp[-1].minor.yy479, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy649, &yymsp[-1].minor.yy537, yymsp[0].minor.yy456); } break; case 50: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy659, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; case 51: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy537); } break; case 52: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy479, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy537, yymsp[0].minor.yy456); } break; case 53: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy659 = true; } +{ yymsp[-2].minor.yy649 = true; } break; case 54: /* not_exists_opt ::= */ case 56: /* exists_opt ::= */ yytestcase(yyruleno==56); case 222: /* analyze_opt ::= */ yytestcase(yyruleno==222); case 230: /* agg_func_opt ::= */ yytestcase(yyruleno==230); - case 371: /* set_quantifier_opt ::= */ yytestcase(yyruleno==371); -{ yymsp[1].minor.yy659 = false; } + case 372: /* set_quantifier_opt ::= */ yytestcase(yyruleno==372); +{ yymsp[1].minor.yy649 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy659 = true; } +{ yymsp[-1].minor.yy649 = true; } break; case 57: /* db_options ::= */ -{ yymsp[1].minor.yy452 = createDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy456 = createDatabaseOptions(pCxt); } break; case 58: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 59: /* db_options ::= db_options CACHE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 60: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 61: /* db_options ::= db_options COMP NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 62: /* db_options ::= db_options DAYS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 63: /* db_options ::= db_options DAYS NK_VARIABLE */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 64: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 65: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 66: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 67: /* db_options ::= db_options KEEP integer_list */ case 68: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==68); -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pKeep = yymsp[0].minor.yy478; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pKeep = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 69: /* db_options ::= db_options PRECISION NK_STRING */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 70: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 71: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 72: /* db_options ::= db_options TTL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 73: /* db_options ::= db_options WAL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 74: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 75: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 76: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 77: /* db_options ::= db_options RETENTIONS retention_list */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy452)->pRetentions = yymsp[0].minor.yy478; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pRetentions = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 78: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy452 = createDatabaseOptions(pCxt); yylhsminor.yy452 = setDatabaseAlterOption(pCxt, yylhsminor.yy452, &yymsp[0].minor.yy11); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createDatabaseOptions(pCxt); yylhsminor.yy456 = setDatabaseAlterOption(pCxt, yylhsminor.yy456, &yymsp[0].minor.yy29); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 79: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy452 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy452, &yymsp[0].minor.yy11); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy456, &yymsp[0].minor.yy29); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 80: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 81: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 82: /* alter_db_option ::= KEEP integer_list */ case 83: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==83); -{ yymsp[-1].minor.yy11.type = DB_OPTION_KEEP; yymsp[-1].minor.yy11.pList = yymsp[0].minor.yy478; } +{ yymsp[-1].minor.yy29.type = DB_OPTION_KEEP; yymsp[-1].minor.yy29.pList = yymsp[0].minor.yy632; } break; case 84: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_WAL; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_WAL; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 85: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 86: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 87: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 88: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy478 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 89: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 248: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==248); -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-2].minor.yy478, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 90: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy478 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 91: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-2].minor.yy478, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 92: /* retention_list ::= retention */ case 112: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==112); @@ -3023,11 +3016,11 @@ static YYACTIONTYPE yy_reduce( case 203: /* func_name_list ::= func_name */ yytestcase(yyruleno==203); case 212: /* func_list ::= func */ yytestcase(yyruleno==212); case 272: /* literal_list ::= signed_literal */ yytestcase(yyruleno==272); - case 321: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==321); - case 376: /* select_sublist ::= select_item */ yytestcase(yyruleno==376); - case 423: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==423); -{ yylhsminor.yy478 = createNodeList(pCxt, yymsp[0].minor.yy452); } - yymsp[0].minor.yy478 = yylhsminor.yy478; + case 322: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==322); + case 377: /* select_sublist ::= select_item */ yytestcase(yyruleno==377); + case 424: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==424); +{ yylhsminor.yy632 = createNodeList(pCxt, yymsp[0].minor.yy456); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 93: /* retention_list ::= retention_list NK_COMMA retention */ case 123: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==123); @@ -3035,242 +3028,242 @@ static YYACTIONTYPE yy_reduce( case 204: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==204); case 213: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==213); case 273: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==273); - case 322: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==322); - case 377: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==377); - case 424: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==424); -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-2].minor.yy478, yymsp[0].minor.yy452); } - yymsp[-2].minor.yy478 = yylhsminor.yy478; + case 323: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==323); + case 378: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==378); + case 425: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==425); +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, yymsp[0].minor.yy456); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 94: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy452 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 95: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 97: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==97); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy659, yymsp[-5].minor.yy452, yymsp[-3].minor.yy478, yymsp[-1].minor.yy478, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy649, yymsp[-5].minor.yy456, yymsp[-3].minor.yy632, yymsp[-1].minor.yy632, yymsp[0].minor.yy456); } break; case 96: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy478); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy632); } break; case 98: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy478); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy632); } break; case 99: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy659, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy649, yymsp[0].minor.yy456); } break; case 100: /* cmd ::= ALTER TABLE alter_table_clause */ case 101: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==101); case 250: /* cmd ::= query_expression */ yytestcase(yyruleno==250); -{ pCxt->pRootNode = yymsp[0].minor.yy452; } +{ pCxt->pRootNode = yymsp[0].minor.yy456; } break; case 102: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy452 = createAlterTableOption(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableOption(pCxt, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 103: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy479, yymsp[0].minor.yy430); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 104: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy479); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy456, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 105: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy479, yymsp[0].minor.yy430); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 106: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy479, &yymsp[0].minor.yy479); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 107: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy479, yymsp[0].minor.yy430); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 108: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy479); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy456, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 109: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy479, yymsp[0].minor.yy430); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 110: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy479, &yymsp[0].minor.yy479); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 111: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy452 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy452, &yymsp[-2].minor.yy479, yymsp[0].minor.yy452); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy456, &yymsp[-2].minor.yy537, yymsp[0].minor.yy456); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; case 113: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 116: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==116); -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-1].minor.yy478, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 114: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy452 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy659, yymsp[-7].minor.yy452, yymsp[-5].minor.yy452, yymsp[-4].minor.yy478, yymsp[-1].minor.yy478); } - yymsp[-8].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy649, yymsp[-7].minor.yy456, yymsp[-5].minor.yy456, yymsp[-4].minor.yy632, yymsp[-1].minor.yy632); } + yymsp[-8].minor.yy456 = yylhsminor.yy456; break; case 117: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy452 = createDropTableClause(pCxt, yymsp[-1].minor.yy659, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createDropTableClause(pCxt, yymsp[-1].minor.yy649, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 118: /* specific_tags_opt ::= */ case 149: /* tags_def_opt ::= */ yytestcase(yyruleno==149); - case 384: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==384); - case 401: /* group_by_clause_opt ::= */ yytestcase(yyruleno==401); - case 411: /* order_by_clause_opt ::= */ yytestcase(yyruleno==411); -{ yymsp[1].minor.yy478 = NULL; } + case 385: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==385); + case 402: /* group_by_clause_opt ::= */ yytestcase(yyruleno==402); + case 412: /* order_by_clause_opt ::= */ yytestcase(yyruleno==412); +{ yymsp[1].minor.yy632 = NULL; } break; case 119: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy478 = yymsp[-1].minor.yy478; } +{ yymsp[-2].minor.yy632 = yymsp[-1].minor.yy632; } break; case 120: /* full_table_name ::= table_name */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy479, NULL); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy537, NULL); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 121: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy479, NULL); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRealTableNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537, NULL); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 124: /* column_def ::= column_name type_name */ -{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy479, yymsp[0].minor.yy430, NULL); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388, NULL); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 125: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy479, yymsp[-2].minor.yy430, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-2].minor.yy388, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 126: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 127: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 128: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 129: /* type_name ::= INT */ case 130: /* type_name ::= INTEGER */ yytestcase(yyruleno==130); -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_INT); } break; case 131: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 132: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 133: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 134: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy430 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 135: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 136: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy430 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 137: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy430 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 138: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy430 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 139: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy430 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 140: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy430 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 141: /* type_name ::= JSON */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 142: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy430 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 143: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 144: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 145: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy430 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy430 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 147: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy430 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 148: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy430 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 150: /* tags_def_opt ::= tags_def */ - case 320: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==320); - case 375: /* select_list ::= select_sublist */ yytestcase(yyruleno==375); -{ yylhsminor.yy478 = yymsp[0].minor.yy478; } - yymsp[0].minor.yy478 = yylhsminor.yy478; + case 321: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==321); + case 376: /* select_list ::= select_sublist */ yytestcase(yyruleno==376); +{ yylhsminor.yy632 = yymsp[0].minor.yy632; } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 151: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy478 = yymsp[-1].minor.yy478; } +{ yymsp[-3].minor.yy632 = yymsp[-1].minor.yy632; } break; case 152: /* table_options ::= */ -{ yymsp[1].minor.yy452 = createTableOptions(pCxt); } +{ yymsp[1].minor.yy456 = createTableOptions(pCxt); } break; case 153: /* table_options ::= table_options COMMENT NK_STRING */ -{ ((STableOptions*)yymsp[-2].minor.yy452)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 154: /* table_options ::= table_options KEEP integer_list */ case 155: /* table_options ::= table_options KEEP variable_list */ yytestcase(yyruleno==155); -{ ((STableOptions*)yymsp[-2].minor.yy452)->pKeep = yymsp[0].minor.yy478; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pKeep = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 156: /* table_options ::= table_options TTL NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy452)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 157: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy452)->pSma = yymsp[-1].minor.yy478; yylhsminor.yy452 = yymsp[-4].minor.yy452; } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-4].minor.yy456)->pSma = yymsp[-1].minor.yy632; yylhsminor.yy456 = yymsp[-4].minor.yy456; } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 158: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy452)->pFuncs = yymsp[-1].minor.yy478; yylhsminor.yy452 = yymsp[-4].minor.yy452; } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-4].minor.yy456)->pFuncs = yymsp[-1].minor.yy632; yylhsminor.yy456 = yymsp[-4].minor.yy456; } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 159: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ ((STableOptions*)yymsp[-2].minor.yy452)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 160: /* table_options ::= table_options DELAY NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy452)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 161: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy452 = createTableOptions(pCxt); yylhsminor.yy452 = setTableAlterOption(pCxt, yylhsminor.yy452, &yymsp[0].minor.yy11); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createTableOptions(pCxt); yylhsminor.yy456 = setTableAlterOption(pCxt, yylhsminor.yy456, &yymsp[0].minor.yy29); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 162: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy452 = setTableAlterOption(pCxt, yymsp[-1].minor.yy452, &yymsp[0].minor.yy11); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = setTableAlterOption(pCxt, yymsp[-1].minor.yy456, &yymsp[0].minor.yy29); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 163: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy11.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 164: /* alter_table_option ::= KEEP integer_list */ case 165: /* alter_table_option ::= KEEP variable_list */ yytestcase(yyruleno==165); -{ yymsp[-1].minor.yy11.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy11.pList = yymsp[0].minor.yy478; } +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy29.pList = yymsp[0].minor.yy632; } break; case 166: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy11.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy11.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 169: /* col_name ::= column_name */ -{ yylhsminor.yy452 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy479); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy537); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 170: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } @@ -3282,13 +3275,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; case 173: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } break; case 174: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } break; case 175: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy452, NULL); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy456, NULL); } break; case 176: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } @@ -3303,7 +3296,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; case 180: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; case 181: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } @@ -3322,13 +3315,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; case 187: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy537); } break; case 188: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy456); } break; case 189: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy456); } break; case 190: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } @@ -3350,133 +3343,133 @@ static YYACTIONTYPE yy_reduce( break; case 196: /* db_name_cond_opt ::= */ case 201: /* from_db_opt ::= */ yytestcase(yyruleno==201); -{ yymsp[1].minor.yy452 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy456 = createDefaultDatabaseCondValue(pCxt); } break; case 197: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy479); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 198: /* like_pattern_opt ::= */ case 209: /* index_options ::= */ yytestcase(yyruleno==209); case 236: /* into_opt ::= */ yytestcase(yyruleno==236); - case 382: /* where_clause_opt ::= */ yytestcase(yyruleno==382); - case 386: /* twindow_clause_opt ::= */ yytestcase(yyruleno==386); - case 391: /* sliding_opt ::= */ yytestcase(yyruleno==391); - case 393: /* fill_opt ::= */ yytestcase(yyruleno==393); - case 405: /* having_clause_opt ::= */ yytestcase(yyruleno==405); - case 413: /* slimit_clause_opt ::= */ yytestcase(yyruleno==413); - case 417: /* limit_clause_opt ::= */ yytestcase(yyruleno==417); -{ yymsp[1].minor.yy452 = NULL; } + case 383: /* where_clause_opt ::= */ yytestcase(yyruleno==383); + case 387: /* twindow_clause_opt ::= */ yytestcase(yyruleno==387); + case 392: /* sliding_opt ::= */ yytestcase(yyruleno==392); + case 394: /* fill_opt ::= */ yytestcase(yyruleno==394); + case 406: /* having_clause_opt ::= */ yytestcase(yyruleno==406); + case 414: /* slimit_clause_opt ::= */ yytestcase(yyruleno==414); + case 418: /* limit_clause_opt ::= */ yytestcase(yyruleno==418); +{ yymsp[1].minor.yy456 = NULL; } break; case 199: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 200: /* table_name_cond ::= table_name */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy479); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy537); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 202: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy479); } +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy537); } break; case 205: /* func_name ::= function_name */ -{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy479, NULL); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createFunctionNode(pCxt, &yymsp[0].minor.yy537, NULL); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 206: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy659, &yymsp[-3].minor.yy479, &yymsp[-1].minor.yy479, NULL, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy649, &yymsp[-3].minor.yy537, &yymsp[-1].minor.yy537, NULL, yymsp[0].minor.yy456); } break; case 207: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy659, &yymsp[-5].minor.yy479, &yymsp[-3].minor.yy479, yymsp[-1].minor.yy478, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy649, &yymsp[-5].minor.yy537, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632, NULL); } break; case 208: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy659, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537); } break; case 210: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy452 = createIndexOption(pCxt, yymsp[-6].minor.yy478, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), NULL, yymsp[0].minor.yy452); } +{ yymsp[-8].minor.yy456 = createIndexOption(pCxt, yymsp[-6].minor.yy632, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), NULL, yymsp[0].minor.yy456); } break; case 211: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy452 = createIndexOption(pCxt, yymsp[-8].minor.yy478, releaseRawExprNode(pCxt, yymsp[-4].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), yymsp[0].minor.yy452); } +{ yymsp[-10].minor.yy456 = createIndexOption(pCxt, yymsp[-8].minor.yy632, releaseRawExprNode(pCxt, yymsp[-4].minor.yy456), releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), yymsp[0].minor.yy456); } break; case 214: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[-3].minor.yy479, yymsp[-1].minor.yy478); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createFunctionNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 215: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy659, &yymsp[-2].minor.yy479, yymsp[0].minor.yy452, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, yymsp[0].minor.yy456, NULL); } break; case 216: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy659, &yymsp[-2].minor.yy479, NULL, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, NULL, &yymsp[0].minor.yy537); } break; case 217: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy659, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; case 218: /* cmd ::= DESC full_table_name */ case 219: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==219); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy456); } break; case 220: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 221: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy659, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy649, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; case 223: /* analyze_opt ::= ANALYZE */ case 231: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==231); - case 372: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==372); -{ yymsp[0].minor.yy659 = true; } + case 373: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==373); +{ yymsp[0].minor.yy649 = true; } break; case 224: /* explain_options ::= */ -{ yymsp[1].minor.yy452 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy456 = createDefaultExplainOptions(pCxt); } break; case 225: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy452 = setExplainVerbose(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = setExplainVerbose(pCxt, yymsp[-2].minor.yy456, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 226: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy452 = setExplainRatio(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = setExplainRatio(pCxt, yymsp[-2].minor.yy456, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 227: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy478); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy632); } break; case 228: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy659, &yymsp[-5].minor.yy479, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy430, yymsp[0].minor.yy100); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy649, &yymsp[-5].minor.yy537, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy388, yymsp[0].minor.yy652); } break; case 229: /* cmd ::= DROP FUNCTION function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy537); } break; case 232: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy100 = 0; } +{ yymsp[1].minor.yy652 = 0; } break; case 233: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy100 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy652 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 234: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy659, &yymsp[-4].minor.yy479, yymsp[-2].minor.yy452, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy649, &yymsp[-4].minor.yy537, yymsp[-2].minor.yy456, yymsp[-3].minor.yy456, yymsp[0].minor.yy456); } break; case 235: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy659, &yymsp[0].minor.yy479); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; case 237: /* into_opt ::= INTO full_table_name */ - case 353: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==353); - case 383: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==383); - case 406: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==406); -{ yymsp[-1].minor.yy452 = yymsp[0].minor.yy452; } + case 354: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==354); + case 384: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==384); + case 407: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==407); +{ yymsp[-1].minor.yy456 = yymsp[0].minor.yy456; } break; case 238: /* stream_options ::= */ -{ yymsp[1].minor.yy452 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy456 = createStreamOptions(pCxt); } break; case 239: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 240: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 241: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy456); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 242: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -3488,36 +3481,36 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 245: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy478); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy632); } break; case 246: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 247: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy478 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy632 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 249: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy479); } +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy537); } break; case 251: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 252: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 253: /* literal ::= NK_STRING */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 254: /* literal ::= NK_BOOL */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 255: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 256: /* literal ::= duration_literal */ case 266: /* signed_literal ::= signed */ yytestcase(yyruleno==266); @@ -3526,163 +3519,163 @@ static YYACTIONTYPE yy_reduce( case 286: /* expression ::= column_reference */ yytestcase(yyruleno==286); case 287: /* expression ::= function_expression */ yytestcase(yyruleno==287); case 288: /* expression ::= subquery */ yytestcase(yyruleno==288); - case 345: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==345); - case 349: /* boolean_primary ::= predicate */ yytestcase(yyruleno==349); - case 351: /* common_expression ::= expression */ yytestcase(yyruleno==351); - case 352: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==352); - case 354: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==354); - case 356: /* table_reference ::= table_primary */ yytestcase(yyruleno==356); - case 357: /* table_reference ::= joined_table */ yytestcase(yyruleno==357); - case 361: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==361); - case 408: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==408); - case 410: /* query_primary ::= query_specification */ yytestcase(yyruleno==410); -{ yylhsminor.yy452 = yymsp[0].minor.yy452; } - yymsp[0].minor.yy452 = yylhsminor.yy452; + case 346: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==346); + case 350: /* boolean_primary ::= predicate */ yytestcase(yyruleno==350); + case 352: /* common_expression ::= expression */ yytestcase(yyruleno==352); + case 353: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==353); + case 355: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==355); + case 357: /* table_reference ::= table_primary */ yytestcase(yyruleno==357); + case 358: /* table_reference ::= joined_table */ yytestcase(yyruleno==358); + case 362: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==362); + case 409: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==409); + case 411: /* query_primary ::= query_specification */ yytestcase(yyruleno==411); +{ yylhsminor.yy456 = yymsp[0].minor.yy456; } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 257: /* literal ::= NULL */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 258: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 259: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 260: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 261: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 262: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 263: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 264: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; case 265: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 267: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 268: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 269: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 270: /* signed_literal ::= duration_literal */ - case 323: /* star_func_para ::= expression */ yytestcase(yyruleno==323); - case 378: /* select_item ::= common_expression */ yytestcase(yyruleno==378); - case 422: /* search_condition ::= common_expression */ yytestcase(yyruleno==422); -{ yylhsminor.yy452 = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); } - yymsp[0].minor.yy452 = yylhsminor.yy452; + case 324: /* star_func_para ::= expression */ yytestcase(yyruleno==324); + case 379: /* select_item ::= common_expression */ yytestcase(yyruleno==379); + case 423: /* search_condition ::= common_expression */ yytestcase(yyruleno==423); +{ yylhsminor.yy456 = releaseRawExprNode(pCxt, yymsp[0].minor.yy456); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 271: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } +{ yymsp[0].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; case 289: /* expression ::= NK_LP expression NK_RP */ - case 350: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==350); -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 351: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==351); +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 290: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 291: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy456), NULL)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 292: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 293: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 294: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 295: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 296: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 297: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 298: /* expression_list ::= expression */ -{ yylhsminor.yy478 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[0].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 299: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-2].minor.yy478, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[-2].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 300: /* column_reference ::= column_name */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy479, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy479)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy537, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy537)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 301: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy479, createColumnNode(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy479)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537, createColumnNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 302: /* pseudo_column ::= ROWTS */ case 303: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==303); @@ -3691,298 +3684,298 @@ static YYACTIONTYPE yy_reduce( case 306: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==306); case 307: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==307); case 308: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==308); -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 309: /* function_expression ::= function_name NK_LP expression_list NK_RP */ case 310: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==310); -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy479, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy479, yymsp[-1].minor.yy478)); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy537, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632)); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 311: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy430)); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), yymsp[-1].minor.yy388)); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; case 312: /* function_expression ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy479, NULL)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0, createFunctionNodeNoArg(pCxt, &yymsp[-2].minor.yy537)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 319: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy478 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy478 = yylhsminor.yy478; + case 320: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy632 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 324: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 381: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==381); -{ yylhsminor.yy452 = createColumnNode(pCxt, &yymsp[-2].minor.yy479, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 325: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 382: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==382); +{ yylhsminor.yy456 = createColumnNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 325: /* predicate ::= expression compare_op expression */ - case 330: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==330); + case 326: /* predicate ::= expression compare_op expression */ + case 331: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==331); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy218, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 326: /* predicate ::= expression BETWEEN expression AND expression */ + case 327: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy456), releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; - case 327: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 328: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[-5].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; - case 328: /* predicate ::= expression IS NULL */ + case 329: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), NULL)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 329: /* predicate ::= expression IS NOT NULL */ + case 330: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), NULL)); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 331: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy218 = OP_TYPE_LOWER_THAN; } + case 332: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } break; - case 332: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy218 = OP_TYPE_GREATER_THAN; } + case 333: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } break; - case 333: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy218 = OP_TYPE_LOWER_EQUAL; } + case 334: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } break; - case 334: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy218 = OP_TYPE_GREATER_EQUAL; } + case 335: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } break; - case 335: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy218 = OP_TYPE_NOT_EQUAL; } + case 336: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } break; - case 336: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy218 = OP_TYPE_EQUAL; } + case 337: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } break; - case 337: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy218 = OP_TYPE_LIKE; } + case 338: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } break; - case 338: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy218 = OP_TYPE_NOT_LIKE; } + case 339: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } break; - case 339: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy218 = OP_TYPE_MATCH; } + case 340: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } break; - case 340: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy218 = OP_TYPE_NMATCH; } + case 341: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } break; - case 341: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy218 = OP_TYPE_JSON_CONTAINS; } + case 342: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy416 = OP_TYPE_JSON_CONTAINS; } break; - case 342: /* in_op ::= IN */ -{ yymsp[0].minor.yy218 = OP_TYPE_IN; } + case 343: /* in_op ::= IN */ +{ yymsp[0].minor.yy416 = OP_TYPE_IN; } break; - case 343: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy218 = OP_TYPE_NOT_IN; } + case 344: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } break; - case 344: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy478)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 345: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy632)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 346: /* boolean_value_expression ::= NOT boolean_primary */ + case 347: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy456), NULL)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 347: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 348: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 348: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 349: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 355: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy452 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, NULL); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 356: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy456 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy456, yymsp[0].minor.yy456, NULL); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 358: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy479, &yymsp[0].minor.yy479); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 359: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy456 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 359: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-3].minor.yy479, &yymsp[-1].minor.yy479, &yymsp[0].minor.yy479); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + case 360: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy456 = createRealTableNode(pCxt, &yymsp[-3].minor.yy537, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 360: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy452 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy479); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 361: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy456 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 362: /* alias_opt ::= */ -{ yymsp[1].minor.yy479 = nil_token; } + case 363: /* alias_opt ::= */ +{ yymsp[1].minor.yy537 = nil_token; } break; - case 363: /* alias_opt ::= table_alias */ -{ yylhsminor.yy479 = yymsp[0].minor.yy479; } - yymsp[0].minor.yy479 = yylhsminor.yy479; + case 364: /* alias_opt ::= table_alias */ +{ yylhsminor.yy537 = yymsp[0].minor.yy537; } + yymsp[0].minor.yy537 = yylhsminor.yy537; break; - case 364: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy479 = yymsp[0].minor.yy479; } + case 365: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy537 = yymsp[0].minor.yy537; } break; - case 365: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 366: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==366); -{ yymsp[-2].minor.yy452 = yymsp[-1].minor.yy452; } + case 366: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 367: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==367); +{ yymsp[-2].minor.yy456 = yymsp[-1].minor.yy456; } break; - case 367: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy452 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy452, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; + case 368: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy456 = createJoinTableNode(pCxt, yymsp[-4].minor.yy164, yymsp[-5].minor.yy456, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; - case 368: /* join_type ::= */ -{ yymsp[1].minor.yy162 = JOIN_TYPE_INNER; } + case 369: /* join_type ::= */ +{ yymsp[1].minor.yy164 = JOIN_TYPE_INNER; } break; - case 369: /* join_type ::= INNER */ -{ yymsp[0].minor.yy162 = JOIN_TYPE_INNER; } + case 370: /* join_type ::= INNER */ +{ yymsp[0].minor.yy164 = JOIN_TYPE_INNER; } break; - case 370: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 371: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy452 = createSelectStmt(pCxt, yymsp[-7].minor.yy659, yymsp[-6].minor.yy478, yymsp[-5].minor.yy452); - yymsp[-8].minor.yy452 = addWhereClause(pCxt, yymsp[-8].minor.yy452, yymsp[-4].minor.yy452); - yymsp[-8].minor.yy452 = addPartitionByClause(pCxt, yymsp[-8].minor.yy452, yymsp[-3].minor.yy478); - yymsp[-8].minor.yy452 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy452, yymsp[-2].minor.yy452); - yymsp[-8].minor.yy452 = addGroupByClause(pCxt, yymsp[-8].minor.yy452, yymsp[-1].minor.yy478); - yymsp[-8].minor.yy452 = addHavingClause(pCxt, yymsp[-8].minor.yy452, yymsp[0].minor.yy452); + yymsp[-8].minor.yy456 = createSelectStmt(pCxt, yymsp[-7].minor.yy649, yymsp[-6].minor.yy632, yymsp[-5].minor.yy456); + yymsp[-8].minor.yy456 = addWhereClause(pCxt, yymsp[-8].minor.yy456, yymsp[-4].minor.yy456); + yymsp[-8].minor.yy456 = addPartitionByClause(pCxt, yymsp[-8].minor.yy456, yymsp[-3].minor.yy632); + yymsp[-8].minor.yy456 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy456, yymsp[-2].minor.yy456); + yymsp[-8].minor.yy456 = addGroupByClause(pCxt, yymsp[-8].minor.yy456, yymsp[-1].minor.yy632); + yymsp[-8].minor.yy456 = addHavingClause(pCxt, yymsp[-8].minor.yy456, yymsp[0].minor.yy456); } break; - case 373: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy659 = false; } + case 374: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy649 = false; } break; - case 374: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy478 = NULL; } + case 375: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy632 = NULL; } break; - case 379: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy479); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 380: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy456 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 380: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), &yymsp[0].minor.yy479); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 381: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy456 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 385: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 402: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==402); - case 412: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==412); -{ yymsp[-2].minor.yy478 = yymsp[0].minor.yy478; } + case 386: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 403: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==403); + case 413: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==413); +{ yymsp[-2].minor.yy632 = yymsp[0].minor.yy632; } break; - case 387: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy452 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + case 388: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy456 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } break; - case 388: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy452 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + case 389: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy456 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } break; - case 389: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + case 390: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy456 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), NULL, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 390: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + case 391: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy456 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy456), releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 392: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy452 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy452); } + case 393: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy456 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy456); } break; - case 394: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy452 = createFillNode(pCxt, yymsp[-1].minor.yy540, NULL); } + case 395: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy456 = createFillNode(pCxt, yymsp[-1].minor.yy646, NULL); } break; - case 395: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy452 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy478)); } + case 396: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy456 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 396: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy540 = FILL_MODE_NONE; } + case 397: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy646 = FILL_MODE_NONE; } break; - case 397: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy540 = FILL_MODE_PREV; } + case 398: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy646 = FILL_MODE_PREV; } break; - case 398: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy540 = FILL_MODE_NULL; } + case 399: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy646 = FILL_MODE_NULL; } break; - case 399: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy540 = FILL_MODE_LINEAR; } + case 400: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy646 = FILL_MODE_LINEAR; } break; - case 400: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy540 = FILL_MODE_NEXT; } + case 401: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy646 = FILL_MODE_NEXT; } break; - case 403: /* group_by_list ::= expression */ -{ yylhsminor.yy478 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[0].minor.yy478 = yylhsminor.yy478; + case 404: /* group_by_list ::= expression */ +{ yylhsminor.yy632 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 404: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy478 = addNodeToList(pCxt, yymsp[-2].minor.yy478, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy478 = yylhsminor.yy478; + case 405: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 407: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 408: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy452 = addOrderByClause(pCxt, yymsp[-3].minor.yy452, yymsp[-2].minor.yy478); - yylhsminor.yy452 = addSlimitClause(pCxt, yylhsminor.yy452, yymsp[-1].minor.yy452); - yylhsminor.yy452 = addLimitClause(pCxt, yylhsminor.yy452, yymsp[0].minor.yy452); + yylhsminor.yy456 = addOrderByClause(pCxt, yymsp[-3].minor.yy456, yymsp[-2].minor.yy632); + yylhsminor.yy456 = addSlimitClause(pCxt, yylhsminor.yy456, yymsp[-1].minor.yy456); + yylhsminor.yy456 = addLimitClause(pCxt, yylhsminor.yy456, yymsp[0].minor.yy456); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 409: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + case 410: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy456 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 414: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 418: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==418); -{ yymsp[-1].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 415: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 419: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==419); +{ yymsp[-1].minor.yy456 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 415: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 419: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==419); -{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 416: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 420: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==420); +{ yymsp[-3].minor.yy456 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 416: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 420: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==420); -{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 417: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 421: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==421); +{ yymsp[-3].minor.yy456 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 421: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy452); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 422: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy456); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 425: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy452 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), yymsp[-1].minor.yy326, yymsp[0].minor.yy595); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 426: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy456 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), yymsp[-1].minor.yy626, yymsp[0].minor.yy209); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 426: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy326 = ORDER_ASC; } + case 427: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy626 = ORDER_ASC; } break; - case 427: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy326 = ORDER_ASC; } + case 428: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy626 = ORDER_ASC; } break; - case 428: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy326 = ORDER_DESC; } + case 429: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy626 = ORDER_DESC; } break; - case 429: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy595 = NULL_ORDER_DEFAULT; } + case 430: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy209 = NULL_ORDER_DEFAULT; } break; - case 430: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy595 = NULL_ORDER_FIRST; } + case 431: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy209 = NULL_ORDER_FIRST; } break; - case 431: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy595 = NULL_ORDER_LAST; } + case 432: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy209 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserTestUtil.h b/source/libs/parser/test/parserTestUtil.h index f5efed50a8..6db229df7f 100644 --- a/source/libs/parser/test/parserTestUtil.h +++ b/source/libs/parser/test/parserTestUtil.h @@ -13,4 +13,9 @@ * along with this program. If not, see . */ -extern bool g_isDump; \ No newline at end of file +#ifndef PARSER_TEST_UTIL_H +#define PARSER_TEST_UTIL_H + +extern bool g_isDump; + +#endif // PARSER_TEST_UTIL_H diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 656caaf645..6fcfc7df07 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -166,12 +166,24 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) { return dataRequired; } +static void setScanWindowInfo(SScanLogicNode* pScan) { + if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pScan->node.pParent) && + WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pScan->node.pParent)->winType) { + pScan->interval = ((SWindowLogicNode*)pScan->node.pParent)->interval; + pScan->offset = ((SWindowLogicNode*)pScan->node.pParent)->offset; + pScan->sliding = ((SWindowLogicNode*)pScan->node.pParent)->sliding; + pScan->intervalUnit = ((SWindowLogicNode*)pScan->node.pParent)->intervalUnit; + pScan->slidingUnit = ((SWindowLogicNode*)pScan->node.pParent)->slidingUnit; + } +} + static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) { SOsdInfo info = {0}; int32_t code = osdMatch(pCxt, pLogicNode, &info); if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) { info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs); info.pScan->pDynamicScanFuncs = info.pDsoFuncs; + setScanWindowInfo((SScanLogicNode*)info.pScan); OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD); pCxt->optimized = true; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index f9f6d503a1..caeab20970 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -443,6 +443,11 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp nodesDestroyNode(pTableScan); return TSDB_CODE_OUT_OF_MEMORY; } + pTableScan->interval = pScanLogicNode->interval; + pTableScan->offset = pScanLogicNode->offset; + pTableScan->sliding = pScanLogicNode->sliding; + pTableScan->intervalUnit = pScanLogicNode->intervalUnit; + pTableScan->slidingUnit = pScanLogicNode->slidingUnit; return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); } @@ -819,7 +824,6 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil pInterval->sliding = pWindowLogicNode->sliding; pInterval->intervalUnit = pWindowLogicNode->intervalUnit; pInterval->slidingUnit = pWindowLogicNode->slidingUnit; - pInterval->precision = ((SColumnNode*)pWindowLogicNode->pTspk)->node.resType.precision; pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill); if (NULL != pWindowLogicNode->pFill && NULL == pInterval->pFill) { diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index bcea94278e..004f0b18fd 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -17,6 +17,31 @@ #include "planInt.h" +typedef struct SCollectPlaceholderValuesCxt { + int32_t errCode; + SNodeList* pValues; +} SCollectPlaceholderValuesCxt; + +static EDealRes collectPlaceholderValuesImpl(SNode* pNode, void* pContext) { + if (QUERY_NODE_VALUE == nodeType(pNode) && ((SValueNode*)pNode)->placeholderNo > 0) { + SCollectPlaceholderValuesCxt* pCxt = pContext; + pCxt->errCode = nodesListMakeAppend(&pCxt->pValues, pNode); + return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; + } + return DEAL_RES_CONTINUE; +} + +static int32_t collectPlaceholderValues(SPlanContext* pCxt, SQueryPlan* pPlan) { + SCollectPlaceholderValuesCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pValues = NULL }; + nodesWalkPhysiPlan((SNode*)pPlan, collectPlaceholderValuesImpl, &cxt); + if (TSDB_CODE_SUCCESS == cxt.errCode) { + pPlan->pPlaceholderValues = cxt.pValues; + } else { + nodesDestroyList(cxt.pValues); + } + return cxt.errCode; +} + int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNodeList) { SLogicNode* pLogicNode = NULL; SLogicSubplan* pLogicSubplan = NULL; @@ -35,6 +60,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo if (TSDB_CODE_SUCCESS == code) { code = createPhysiPlan(pCxt, pLogicPlan, pPlan, pExecNodeList); } + if (TSDB_CODE_SUCCESS == code && pCxt->isStmtQuery) { + code = collectPlaceholderValues(pCxt, *pPlan); + } nodesDestroyNode(pLogicNode); nodesDestroyNode(pLogicSubplan); @@ -73,6 +101,82 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream return setSubplanExecutionNode(subplan->pNode, groupId, pSource); } +static int32_t setValueByBindParam(SValueNode* pVal, TAOS_BIND_v2* pParam) { + if (1 == *(pParam->is_null)) { + pVal->node.resType.type = TSDB_DATA_TYPE_NULL; + pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; + return TSDB_CODE_SUCCESS; + } + pVal->node.resType.type = pParam->buffer_type; + pVal->node.resType.bytes = *(pParam->length); + switch (pParam->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + pVal->datum.b = *((bool*)pParam->buffer); + break; + case TSDB_DATA_TYPE_TINYINT: + pVal->datum.i = *((int8_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_SMALLINT: + pVal->datum.i = *((int16_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_INT: + pVal->datum.i = *((int32_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_BIGINT: + pVal->datum.i = *((int64_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_FLOAT: + pVal->datum.d = *((float*)pParam->buffer); + break; + case TSDB_DATA_TYPE_DOUBLE: + pVal->datum.d = *((double*)pParam->buffer); + break; + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_VARBINARY: + pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); + if (NULL == pVal->datum.p) { + return TSDB_CODE_OUT_OF_MEMORY; + } + varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); + strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); + break; + case TSDB_DATA_TYPE_TIMESTAMP: + pVal->datum.i = *((int64_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_UTINYINT: + pVal->datum.u = *((uint8_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_USMALLINT: + pVal->datum.u = *((uint16_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_UINT: + pVal->datum.u = *((uint32_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_UBIGINT: + pVal->datum.u = *((uint64_t*)pParam->buffer); + break; + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: + // todo + default: + break; + } + pVal->translate = true; + return TSDB_CODE_SUCCESS; +} + +int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_BIND_v2* pParams) { + int32_t index = 0; + SNode* pNode = NULL; + FOREACH(pNode, pPlan->pPlaceholderValues) { + setValueByBindParam((SValueNode*)pNode, pParams + index); + } + return TSDB_CODE_SUCCESS; +} + int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) { if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType) { SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink; diff --git a/source/libs/planner/test/planStmtTest.cpp b/source/libs/planner/test/planStmtTest.cpp new file mode 100644 index 0000000000..ca206c7843 --- /dev/null +++ b/source/libs/planner/test/planStmtTest.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "planTestUtil.h" +#include "planner.h" + +using namespace std; + +class PlanStmtTest : public PlannerTestBase { +public: + void prepare(const string& sql) { + run(sql); + // todo calloc pBindParams_ + } + + void bindParam(int32_t val) { + TAOS_BIND_v2* pBind = pBindParams_ + paramNo_++; + pBind->buffer_type = TSDB_DATA_TYPE_INT; + pBind->num = 1; + pBind->buffer_length = sizeof(int32_t); + pBind->buffer = taosMemoryCalloc(1, pBind->buffer_length); + pBind->length = (int32_t*)taosMemoryCalloc(1, sizeof(int32_t)); + pBind->is_null = (char*)taosMemoryCalloc(1, sizeof(char)); + *((int32_t*)pBind->buffer) = val; + *(pBind->length) = sizeof(int32_t); + *(pBind->is_null) = 0; + } + + void exec() { + // todo + } + +private: + TAOS_BIND_v2* pBindParams_; + int32_t paramNo_; +}; + +TEST_F(PlanStmtTest, stmt) { + useDb("root", "test"); + + run("SELECT * FROM t1 where c1 = ?"); +} diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp new file mode 100644 index 0000000000..e4c1d41000 --- /dev/null +++ b/source/libs/planner/test/planTestUtil.cpp @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "planTestUtil.h" + +#include + +#include "cmdnodes.h" +#include "parser.h" +#include "planInt.h" + +using namespace std; +using namespace testing; + +#define DO_WITH_THROW(func, ...) \ + do { \ + int32_t code__ = func(__VA_ARGS__); \ + if (TSDB_CODE_SUCCESS != code__) { \ + throw runtime_error("sql:[" + stmtEnv_.sql_ + "] " #func " code:" + to_string(code__) + ", strerror:" + string(tstrerror(code__)) + ", msg:" + string(stmtEnv_.msgBuf_.data())); \ + } \ + } while(0); + +class PlannerTestBaseImpl { +public: + void useDb(const string& acctId, const string& db) { + caseEnv_.acctId_ = acctId; + caseEnv_.db_ = db; + } + + void run(const string& sql) { + reset(); + try { + SQuery* pQuery = nullptr; + doParseSql(sql, &pQuery); + + SPlanContext cxt = {0}; + setPlanContext(pQuery, &cxt); + + SLogicNode* pLogicNode = nullptr; + doCreateLogicPlan(&cxt, &pLogicNode); + + doOptimizeLogicPlan(&cxt, pLogicNode); + + SLogicSubplan* pLogicSubplan = nullptr; + doSplitLogicPlan(&cxt, pLogicNode, &pLogicSubplan); + + SQueryLogicPlan* pLogicPlan = nullptr; + doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan); + + SQueryPlan* pPlan = nullptr; + doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan, NULL); + } catch (...) { + dump(); + throw; + } + } + +private: + struct caseEnv { + string acctId_; + string db_; + }; + + struct stmtEnv { + string sql_; + array msgBuf_; + }; + + struct stmtRes { + string ast_; + string rawLogicPlan_; + string optimizedLogicPlan_; + string splitLogicPlan_; + string scaledLogicPlan_; + string physiPlan_; + }; + + void reset() { + stmtEnv_.sql_.clear(); + stmtEnv_.msgBuf_.fill(0); + + res_.ast_.clear(); + res_.rawLogicPlan_.clear(); + res_.optimizedLogicPlan_.clear(); + res_.splitLogicPlan_.clear(); + res_.scaledLogicPlan_.clear(); + res_.physiPlan_.clear(); + } + + void dump() { + cout << "==========================================sql : [" << stmtEnv_.sql_ << "]" << endl; + cout << "syntax tree : " << endl; + cout << res_.ast_ << endl; + cout << "raw logic plan : " << endl; + cout << res_.rawLogicPlan_ << endl; + cout << "optimized logic plan : " << endl; + cout << res_.optimizedLogicPlan_ << endl; + cout << "split logic plan : " << endl; + cout << res_.splitLogicPlan_ << endl; + cout << "scaled logic plan : " << endl; + cout << res_.scaledLogicPlan_ << endl; + cout << "physical plan : " << endl; + cout << res_.physiPlan_ << endl; + } + + void doParseSql(const string& sql, SQuery** pQuery) { + stmtEnv_.sql_ = sql; + transform(stmtEnv_.sql_.begin(), stmtEnv_.sql_.end(), stmtEnv_.sql_.begin(), ::tolower); + + SParseContext cxt = {0}; + cxt.acctId = atoi(caseEnv_.acctId_.c_str()); + cxt.db = caseEnv_.db_.c_str(); + cxt.pSql = stmtEnv_.sql_.c_str(); + cxt.sqlLen = stmtEnv_.sql_.length(); + cxt.pMsg = stmtEnv_.msgBuf_.data(); + cxt.msgLen = stmtEnv_.msgBuf_.max_size(); + + DO_WITH_THROW(qParseQuerySql, &cxt, pQuery); + res_.ast_ = toString((*pQuery)->pRoot); + } + + void doCreateLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { + DO_WITH_THROW(createLogicPlan, pCxt, pLogicNode); + res_.rawLogicPlan_ = toString((SNode*)(*pLogicNode)); + } + + void doOptimizeLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode) { + DO_WITH_THROW(optimizeLogicPlan, pCxt, pLogicNode); + res_.optimizedLogicPlan_ = toString((SNode*)pLogicNode); + } + + void doSplitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan** pLogicSubplan) { + DO_WITH_THROW(splitLogicPlan, pCxt, pLogicNode, pLogicSubplan); + res_.splitLogicPlan_ = toString((SNode*)(*pLogicSubplan)); + } + + void doScaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQueryLogicPlan** pLogicPlan) { + DO_WITH_THROW(scaleOutLogicPlan, pCxt, pLogicSubplan, pLogicPlan); + res_.scaledLogicPlan_ = toString((SNode*)(*pLogicPlan)); + } + + void doCreatePhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan, SArray* pExecNodeList) { + DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, pExecNodeList); + res_.physiPlan_ = toString((SNode*)(*pPlan)); + } + + void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) { + if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) { + pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery; + pCxt->topicQuery = true; + } else if (QUERY_NODE_CREATE_INDEX_STMT == nodeType(pQuery->pRoot)) { + SMCreateSmaReq req = {0}; + tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req); + nodesStringToNode(req.ast, &pCxt->pAstRoot); + pCxt->streamQuery = true; + } else if (QUERY_NODE_CREATE_STREAM_STMT == nodeType(pQuery->pRoot)) { + SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot; + pCxt->pAstRoot = pStmt->pQuery; + pCxt->streamQuery = true; + pCxt->triggerType = pStmt->pOptions->triggerType; + pCxt->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); + } else { + pCxt->pAstRoot = pQuery->pRoot; + } + } + + string toString(const SNode* pRoot) { + char* pStr = NULL; + int32_t len = 0; + DO_WITH_THROW(nodesNodeToString, pRoot, false, &pStr, &len) + string str(pStr); + taosMemoryFreeClear(pStr); + return str; + } + + caseEnv caseEnv_; + stmtEnv stmtEnv_; + stmtRes res_; +}; + +PlannerTestBase::PlannerTestBase() : impl_(new PlannerTestBaseImpl()) { +} + +PlannerTestBase::~PlannerTestBase() { +} + +void PlannerTestBase::useDb(const std::string& acctId, const std::string& db) { + impl_->useDb(acctId, db); +} + +void PlannerTestBase::run(const std::string& sql) { + return impl_->run(sql); +} diff --git a/source/dnode/vnode/src/meta/metaTbUid.c b/source/libs/planner/test/planTestUtil.h similarity index 61% rename from source/dnode/vnode/src/meta/metaTbUid.c rename to source/libs/planner/test/planTestUtil.h index 27a2ecfb19..71039082f9 100644 --- a/source/dnode/vnode/src/meta/metaTbUid.c +++ b/source/libs/planner/test/planTestUtil.h @@ -13,18 +13,23 @@ * along with this program. If not, see . */ -#include "vnodeInt.h" +#ifndef PLAN_TEST_UTIL_H +#define PLAN_TEST_UTIL_H -int metaOpenUidGnrt(SMeta *pMeta) { - // Init a generator - pMeta->uidGnrt.nextUid = IVLD_TB_UID; - return 0; -} +#include -void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */ -} +class PlannerTestBaseImpl; -tb_uid_t metaGenerateUid(SMeta *pMeta) { - // Generate a new table UID - return tGenIdPI64(); -} +class PlannerTestBase : public testing::Test { +public: + PlannerTestBase(); + virtual ~PlannerTestBase(); + + void useDb(const std::string& acctId, const std::string& db); + void run(const std::string& sql); + +private: + std::unique_ptr impl_; +}; + +#endif // PLAN_TEST_UTIL_H diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 291b4c9cc7..7ab61a8daa 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -90,17 +90,16 @@ protected: return false; } - SQueryPlan* pPlan = nullptr; - code = createPhysiPlan(&cxt, pLogicPlan, &pPlan, NULL); + code = createPhysiPlan(&cxt, pLogicPlan, &plan_, NULL); if (code != TSDB_CODE_SUCCESS) { cout << "sql:[" << cxt_.pSql << "] createPhysiPlan code:" << code << ", strerror:" << tstrerror(code) << endl; return false; } cout << "unformatted physical plan : " << endl; - cout << toString((const SNode*)pPlan, false) << endl; + cout << toString((const SNode*)plan_, false) << endl; SNode* pNode; - FOREACH(pNode, pPlan->pSubplans) { + FOREACH(pNode, plan_->pSubplans) { SNode* pSubplan; FOREACH(pSubplan, ((SNodeListNode*)pNode)->pNodeList) { cout << "unformatted physical subplan : " << endl; @@ -160,6 +159,7 @@ private: string sqlBuf_; SParseContext cxt_; SQuery* query_; + SQueryPlan* plan_; }; TEST_F(PlannerTest, selectBasic) { diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index a9a360e03e..f97d7ffae0 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -1470,6 +1470,9 @@ void qWorkerDestroy(void **qWorkerMgmt) { //TODO FREE ALL + taosHashCleanup(mgmt->ctxHash); + taosHashCleanup(mgmt->schHash); + taosMemoryFreeClear(*qWorkerMgmt); } diff --git a/source/libs/scalar/inc/sclvector.h b/source/libs/scalar/inc/sclvector.h index e51115e9c0..f15116bdb7 100644 --- a/source/libs/scalar/inc/sclvector.h +++ b/source/libs/scalar/inc/sclvector.h @@ -52,6 +52,9 @@ static FORCE_INLINE double getVectorDoubleValue_FLOAT(void *src, int32_t index) static FORCE_INLINE double getVectorDoubleValue_DOUBLE(void *src, int32_t index) { return (double)*((double *)src + index); } +static FORCE_INLINE double getVectorDoubleValue_BOOL(void *src, int32_t index) { + return (double)*((bool *)src + index); +} static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { _getDoubleValue_fn_t p = NULL; @@ -77,6 +80,8 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) p = getVectorDoubleValue_DOUBLE; } else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) { p = getVectorDoubleValue_BIGINT; + } else if (srcType == TSDB_DATA_TYPE_BOOL) { + p = getVectorDoubleValue_BOOL; } else { assert(0); } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 116dfdd5d5..0432ae1df8 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -398,7 +398,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp SScalarParam *params = NULL; int32_t rowNum = 0; int32_t code = 0; - + SCL_ERR_RET(sclInitOperatorParams(¶ms, node, ctx, &rowNum)); output->columnData = createColumnInfoData(&node->node.resType, rowNum); if (output->columnData == NULL) { @@ -411,7 +411,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp int32_t paramNum = scalarGetOperatorParamNum(node->opType); SScalarParam* pLeft = ¶ms[0]; SScalarParam* pRight = paramNum > 1 ? ¶ms[1] : NULL; - + OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC); _return: @@ -426,7 +426,7 @@ _return: EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { SFunctionNode *node = (SFunctionNode *)*pNode; SScalarParam output = {0}; - + ctx->code = sclExecFunction(node, ctx, &output); if (ctx->code) { return DEAL_RES_ERROR; @@ -440,16 +440,19 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } - res->node.resType = node->node.resType; - - int32_t type = output.columnData->info.type; - if (IS_VAR_DATA_TYPE(type)) { - res->datum.p = output.columnData->pData; - output.columnData->pData = NULL; + if (colDataIsNull_s(output.columnData, 0)) { + res->node.resType.type = TSDB_DATA_TYPE_NULL; } else { - memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); + res->node.resType = node->node.resType; + int32_t type = output.columnData->info.type; + if (IS_VAR_DATA_TYPE(type)) { + res->datum.p = output.columnData->pData; + output.columnData->pData = NULL; + } else { + memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); + } } - + nodesDestroyNode(*pNode); *pNode = (SNode*)res; @@ -469,7 +472,7 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) { SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { sclError("make value node failed"); - sclFreeParam(&output); + sclFreeParam(&output); ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return DEAL_RES_ERROR; } diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 97cc80b946..e7ff0bde91 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -313,8 +313,8 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP return TSDB_CODE_SUCCESS; } -static int32_t concatCopyHelper(const char *input, char *output, bool hasNcharCol, int32_t type, int16_t *dataLen) { - if (hasNcharCol && type == TSDB_DATA_TYPE_VARCHAR) { +static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, int32_t type, int16_t *dataLen) { + if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) { TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1); bool ret = taosMbsToUcs4(varDataVal(input), varDataLen(input), newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, NULL); if (!ret) { @@ -345,10 +345,6 @@ static int32_t getNumOfNullEntries(SColumnInfoData *pColumnInfoData, int32_t num } int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum < 2 || inputNum > 8) { // concat accpet 2-8 input strings - return TSDB_CODE_FAILED; - } - SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *)); SColumnInfoData *pOutputData = pOutput->columnData; char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); @@ -356,15 +352,8 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu int32_t inputLen = 0; int32_t numOfRows = 0; - bool hasNcharCol = false; + bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; for (int32_t i = 0; i < inputNum; ++i) { - int32_t type = GET_PARAM_TYPE(&pInput[i]); - if (!IS_VAR_DATA_TYPE(type)) { - return TSDB_CODE_FAILED; - } - if (type == TSDB_DATA_TYPE_NCHAR) { - hasNcharCol = true; - } if (pInput[i].numOfRows > numOfRows) { numOfRows = pInput[i].numOfRows; } @@ -373,7 +362,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu pInputData[i] = pInput[i].columnData; input[i] = pInputData[i]->pData + pInputData[i]->varmeta.offset[0]; int32_t factor = 1; - if (hasNcharCol && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) { + if (hasNchar && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) { factor = TSDB_NCHAR_SIZE; } @@ -405,7 +394,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu int16_t dataLen = 0; for (int32_t i = 0; i < inputNum; ++i) { - int32_t ret = concatCopyHelper(input[i], output, hasNcharCol, GET_PARAM_TYPE(&pInput[i]), &dataLen); + int32_t ret = concatCopyHelper(input[i], output, hasNchar, GET_PARAM_TYPE(&pInput[i]), &dataLen); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -428,10 +417,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum < 3 || inputNum > 9) { // concat accpet 3-9 input strings including the separator - return TSDB_CODE_FAILED; - } - SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *)); SColumnInfoData *pOutputData = pOutput->columnData; char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); @@ -439,15 +424,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p int32_t inputLen = 0; int32_t numOfRows = 0; - bool hasNcharCol = false; + bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; for (int32_t i = 1; i < inputNum; ++i) { - int32_t type = GET_PARAM_TYPE(&pInput[i]); - if (!IS_VAR_DATA_TYPE(GET_PARAM_TYPE(&pInput[i]))) { - return TSDB_CODE_FAILED; - } - if (type == TSDB_DATA_TYPE_NCHAR) { - hasNcharCol = true; - } if (pInput[i].numOfRows > numOfRows) { numOfRows = pInput[i].numOfRows; } @@ -456,7 +434,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p pInputData[i] = pInput[i].columnData; input[i] = pInputData[i]->pData + pInputData[i]->varmeta.offset[0]; int32_t factor = 1; - if (hasNcharCol && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) { + if (hasNchar && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) { factor = TSDB_NCHAR_SIZE; } @@ -487,7 +465,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p continue; } - int32_t ret = concatCopyHelper(input[i], output, hasNcharCol, GET_PARAM_TYPE(&pInput[i]), &dataLen); + int32_t ret = concatCopyHelper(input[i], output, hasNchar, GET_PARAM_TYPE(&pInput[i]), &dataLen); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -499,7 +477,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p if (i < inputNum - 1) { //insert the separator char *sep = pInputData[0]->pData; - int32_t ret = concatCopyHelper(sep, output, hasNcharCol, GET_PARAM_TYPE(&pInput[0]), &dataLen); + int32_t ret = concatCopyHelper(sep, output, hasNchar, GET_PARAM_TYPE(&pInput[0]), &dataLen); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -666,18 +644,14 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu } int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum!= 3) { - return TSDB_CODE_FAILED; - } - int16_t inputType = pInput[0].columnData->info.type; - int16_t outputType = *(int16_t *)pInput[1].columnData->pData; + int16_t outputType = pOutput[0].columnData->info.type; if (outputType != TSDB_DATA_TYPE_BIGINT && outputType != TSDB_DATA_TYPE_UBIGINT && outputType != TSDB_DATA_TYPE_VARCHAR && outputType != TSDB_DATA_TYPE_NCHAR && outputType != TSDB_DATA_TYPE_TIMESTAMP) { return TSDB_CODE_FAILED; } - int64_t outputLen = *(int64_t *)pInput[2].columnData->pData; + int64_t outputLen = pOutput[0].columnData->info.bytes; char *input = NULL; char *outputBuf = taosMemoryCalloc(outputLen * pInput[0].numOfRows, 1); @@ -821,13 +795,6 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(pInput); - if (type != TSDB_DATA_TYPE_BIGINT && type != TSDB_DATA_TYPE_TIMESTAMP) { - return TSDB_CODE_FAILED; - } - - if (inputNum != 1) { - return TSDB_CODE_FAILED; - } char *input = pInput[0].columnData->pData; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { @@ -893,13 +860,6 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(pInput); int32_t timePrec = GET_PARAM_PRECISON(pInput); - if (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR) { - return TSDB_CODE_FAILED; - } - - if (inputNum != 1) { - return TSDB_CODE_FAILED; - } char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[0]; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { @@ -909,7 +869,11 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP } int64_t timeVal = 0; - convertStringToTimestamp(type, input, timePrec, &timeVal); + int32_t ret = convertStringToTimestamp(type, input, timePrec, &timeVal); + if (ret != TSDB_CODE_SUCCESS) { + colDataAppendNULL(pOutput->columnData, i); + continue; + } colDataAppend(pOutput->columnData, i, (char *)&timeVal, false); input += varDataTLen(input); @@ -923,18 +887,6 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(&pInput[0]); int32_t timePrec = GET_PARAM_PRECISON(&pInput[0]); - if (inputNum != 2) { - return TSDB_CODE_FAILED; - } - - if (type != TSDB_DATA_TYPE_BIGINT && type != TSDB_DATA_TYPE_TIMESTAMP && - type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR) { - return TSDB_CODE_FAILED; - } - - if (GET_PARAM_TYPE(&pInput[1]) != TSDB_DATA_TYPE_BIGINT) { //time_unit - return TSDB_CODE_FAILED; - } int64_t timeUnit, timeVal = 0; GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData); @@ -956,7 +908,11 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } if (IS_VAR_DATA_TYPE(type)) { /* datetime format strings */ - convertStringToTimestamp(type, input, TSDB_TIME_PRECISION_NANO, &timeVal); + int32_t ret = convertStringToTimestamp(type, input, TSDB_TIME_PRECISION_NANO, &timeVal); + if (ret != TSDB_CODE_SUCCESS) { + colDataAppendNULL(pOutput->columnData, i); + continue; + } //If converted value is less than 10digits in second, use value in second instead int64_t timeValSec = timeVal / 1000000000; if (timeValSec < 1000000000) { @@ -1122,16 +1078,9 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - if (inputNum != 2 && inputNum != 3) { - return TSDB_CODE_FAILED; - } - int32_t timePrec = GET_PARAM_PRECISON(&pInput[0]); int64_t timeUnit = -1, timeVal[2] = {0}; if (inputNum == 3) { - if (GET_PARAM_TYPE(&pInput[2]) != TSDB_DATA_TYPE_BIGINT) { - return TSDB_CODE_FAILED; - } GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); } @@ -1159,7 +1108,11 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p int32_t type = GET_PARAM_TYPE(&pInput[k]); if (IS_VAR_DATA_TYPE(type)) { /* datetime format strings */ - convertStringToTimestamp(type, input[k], TSDB_TIME_PRECISION_NANO, &timeVal[k]); + int32_t ret = convertStringToTimestamp(type, input[k], TSDB_TIME_PRECISION_NANO, &timeVal[k]); + if (ret != TSDB_CODE_SUCCESS) { + colDataAppendNULL(pOutput->columnData, i); + continue; + } } else if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_TIMESTAMP) { /* unix timestamp or ts column*/ GET_TYPED_DATA(timeVal[k], int64_t, type, input[k]); if (type == TSDB_DATA_TYPE_TIMESTAMP) { @@ -1275,6 +1228,14 @@ int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut return TSDB_CODE_SUCCESS; } +int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + if (inputNum != 1) { + return TSDB_CODE_FAILED; + } + colDataAppend(pOutput->columnData, pOutput->numOfRows, (char *)colDataGetData(pInput->columnData, 0), false); + return TSDB_CODE_SUCCESS; +} + int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { return doScalarFunctionUnique(pInput, inputNum, pOutput, atan); } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 05456790a5..0131a94fec 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -57,6 +57,10 @@ int64_t getVectorBigintValue_FLOAT(void *src, int32_t index) { int64_t getVectorBigintValue_DOUBLE(void *src, int32_t index) { return (int64_t)*((double *)src + index); } +int64_t getVectorBigintValue_BOOL(void *src, int32_t index) { + return (int64_t)*((bool *)src + index); +} + _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { _getBigintValue_fn_t p = NULL; if(srcType==TSDB_DATA_TYPE_TINYINT) { @@ -79,6 +83,10 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { p = getVectorBigintValue_FLOAT; }else if(srcType==TSDB_DATA_TYPE_DOUBLE) { p = getVectorBigintValue_DOUBLE; + }else if(srcType==TSDB_DATA_TYPE_TIMESTAMP) { + p = getVectorBigintValue_BIGINT; + }else if(srcType==TSDB_DATA_TYPE_BOOL) { + p = getVectorBigintValue_BOOL; }else { assert(0); } @@ -565,6 +573,25 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig } } +static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); + + int64_t *output = (int64_t *)pOutputCol->pData; + + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + colDataAppendNNULL(pOutputCol, 0, numOfRows); + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, 0); + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } + } +} + static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) { SScalarParam convertParam = {0}; @@ -599,27 +626,55 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pRight))) || + (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pLeft))) || + (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BOOL) || + (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BOOL)) { //timestamp plus duration + int64_t *output = (int64_t *)pOutputCol->pData; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); - double *output = (double *)pOutputCol->pData; - if (pLeft->numOfRows == pRight->numOfRows) { - for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { - *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i); - } - - pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); - if (pOutputCol->hasNull) { - int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); - for (int32_t j = 0; j < numOfBitLen; ++j) { - pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i); } - } - } else if (pLeft->numOfRows == 1) { - vectorMathAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); - } else if (pRight->numOfRows == 1) { - vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathBigintAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorMathBigintAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); + } + } else { + double *output = (double *)pOutputCol->pData; + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i); + } + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i); + } else if (pRight->numOfRows == 1) { + vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); + } } doReleaseVec(pLeftCol, leftConvert); @@ -646,6 +701,25 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig } } +static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); + + int64_t *output = (int64_t *)pOutputCol->pData; + + if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + colDataAppendNNULL(pOutputCol, 0, numOfRows); + } else { + for (; i >= 0 && i < numOfRows; i += step, output += 1) { + *output = (getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, 0)) * factor; + } + pOutputCol->hasNull = pLeftCol->hasNull; + if (pOutputCol->hasNull) { + memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows)); + } + } +} + void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; @@ -658,27 +732,53 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); - _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) || + (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp minus duration + int64_t *output = (int64_t *)pOutputCol->pData; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); - double *output = (double *)pOutputCol->pData; - if (pLeft->numOfRows == pRight->numOfRows) { - for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { - *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i); - } - - pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); - if (pOutputCol->hasNull) { - int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); - for (int32_t j = 0; j < numOfBitLen; ++j) { - pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, i); } - } - } else if (pLeft->numOfRows == 1) { - vectorMathSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i); - } else if (pRight->numOfRows == 1) { - vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i); + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathBigintSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i); + } else if (pRight->numOfRows == 1) { + vectorMathBigintSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i); + } + } else { + double *output = (double *)pOutputCol->pData; + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); + + if (pLeft->numOfRows == pRight->numOfRows) { + for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { + *output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i); + } + + pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull); + if (pOutputCol->hasNull) { + int32_t numOfBitLen = BitmapLen(pLeft->numOfRows); + for (int32_t j = 0; j < numOfBitLen; ++j) { + pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j]; + } + } + + } else if (pLeft->numOfRows == 1) { + vectorMathSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i); + } else if (pRight->numOfRows == 1) { + vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i); + } } doReleaseVec(pLeftCol, leftConvert); diff --git a/source/libs/scheduler/test/CMakeLists.txt b/source/libs/scheduler/test/CMakeLists.txt index 4018f73ee2..0b0aafebb9 100644 --- a/source/libs/scheduler/test/CMakeLists.txt +++ b/source/libs/scheduler/test/CMakeLists.txt @@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST}) TARGET_LINK_LIBRARIES( schedulerTest - PUBLIC os util common catalog transport gtest qcom taos planner scheduler + PUBLIC os util common catalog transport gtest qcom taos_static planner scheduler ) TARGET_INCLUDE_DIRECTORIES( diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 4b55d4912c..c2c4af18e5 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -772,6 +772,9 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) { if (pFile == NULL) { return -1; } + if (*ptrBuf != NULL) { + taosMemoryFreeClear(*ptrBuf); + } assert(pFile->fp != NULL); size_t len = 0; diff --git a/source/os/src/osThread.c b/source/os/src/osThread.c index 436614ad6a..656871fd3c 100644 --- a/source/os/src/osThread.c +++ b/source/os/src/osThread.c @@ -77,34 +77,6 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) { return pthread_attr_setstacksize(attr, stacksize); } -int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier) { - return pthread_barrier_destroy(barrier); -} - -int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count) { - return pthread_barrier_init(barrier, attr, count); -} - -int32_t taosThreadBarrierWait(TdThreadBarrier * barrier) { - return pthread_barrier_wait(barrier); -} - -int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr) { - return pthread_barrierattr_destroy(attr); -} - -int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared) { - return pthread_barrierattr_getpshared(attr, pshared); -} - -int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr) { - return pthread_barrierattr_init(attr); -} - -int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared) { - return pthread_barrierattr_setpshared(attr, pshared); -} - int32_t taosThreadCancel(TdThread thread) { return pthread_cancel(thread); } @@ -322,23 +294,43 @@ int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { } int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock) { - return pthread_spin_destroy(lock); +#ifndef __USE_XOPEN2K + return pthread_mutex_destroy((pthread_mutex_t*)lock); +#else + return pthread_spin_destroy((pthread_spinlock_t*)lock); +#endif } int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared) { - return pthread_spin_init(lock, pshared); +#ifndef __USE_XOPEN2K + return pthread_mutex_init((pthread_mutex_t*)lock, pshared); +#else + return pthread_spin_init((pthread_spinlock_t*)lock, pshared); +#endif } int32_t taosThreadSpinLock(TdThreadSpinlock * lock) { - return pthread_spin_lock(lock); +#ifndef __USE_XOPEN2K + return pthread_mutex_lock((pthread_mutex_t*)lock); +#else + return pthread_spin_lock((pthread_spinlock_t*)lock); +#endif } int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock) { - return pthread_spin_trylock(lock); +#ifndef __USE_XOPEN2K + return pthread_mutex_trylock((pthread_mutex_t*)lock); +#else + return pthread_spin_trylock((pthread_spinlock_t*)lock); +#endif } int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) { - return pthread_spin_unlock(lock); +#ifndef __USE_XOPEN2K + return pthread_mutex_unlock((pthread_mutex_t*)lock); +#else + return pthread_spin_unlock((pthread_spinlock_t*)lock); +#endif } void taosThreadTestCancel(void) { diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index c4e85a425e..a69f11f285 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -910,6 +910,8 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1) void taosStopCacheRefreshWorker(void) { stopRefreshWorker = true; + taosThreadJoin(cacheRefreshWorker, NULL); + taosArrayDestroy(pCacheArrayList); } size_t taosCacheGetNumOfObj(const SCacheObj* pCacheObj) { diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 74d7c15e78..06a6b8317d 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -591,12 +591,12 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } int32_t cfgLoadFromEnvVar(SConfig *pConfig) { - uInfo("load from env variables not implemented yet"); + uDebug("load from env variables not implemented yet"); return 0; } int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) { - uInfo("load from env file not implemented yet"); + uDebug("load from env file not implemented yet"); return 0; } @@ -655,6 +655,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { } int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { - uInfo("load from apoll url not implemented yet"); + uDebug("load from apoll url not implemented yet"); return 0; } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index b37b1b2f69..3dce260b10 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -38,27 +38,26 @@ #define LOG_BUF_MUTEX(x) ((x)->buffMutex) typedef struct { - char *buffer; - int32_t buffStart; - int32_t buffEnd; - int32_t buffSize; - int32_t minBuffSize; - TdFilePtr pFile; - int32_t stop; - TdThread asyncThread; + char *buffer; + int32_t buffStart; + int32_t buffEnd; + int32_t buffSize; + int32_t minBuffSize; + TdFilePtr pFile; + int32_t stop; + TdThread asyncThread; TdThreadMutex buffMutex; - tsem_t buffNotEmpty; } SLogBuff; typedef struct { - int32_t fileNum; - int32_t maxLines; - int32_t lines; - int32_t flag; - int32_t openInProgress; - pid_t pid; - char logName[LOG_FILE_NAME_LEN]; - SLogBuff *logHandle; + int32_t fileNum; + int32_t maxLines; + int32_t lines; + int32_t flag; + int32_t openInProgress; + pid_t pid; + char logName[LOG_FILE_NAME_LEN]; + SLogBuff *logHandle; TdThreadMutex logMutex; } SLogObj; @@ -100,7 +99,7 @@ int64_t dbgBigWN = 0; int64_t dbgWSize = 0; static void *taosAsyncOutputLog(void *param); -static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen); +static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen); static SLogBuff *taosLogBuffNew(int32_t bufSize); static void taosCloseLogByFd(TdFilePtr pFile); static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum); @@ -136,16 +135,24 @@ static void taosStopLog() { } } +static void taosLogBuffDestroy() { + taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex); + taosCloseFile(&tsLogObj.logHandle->pFile); + taosMemoryFreeClear(tsLogObj.logHandle->buffer); + memset(&tsLogObj.logHandle->buffer, 0, sizeof(tsLogObj.logHandle->buffer)); + taosThreadMutexDestroy(&tsLogObj.logMutex); + taosMemoryFreeClear(tsLogObj.logHandle); + memset(&tsLogObj.logHandle, 0, sizeof(tsLogObj.logHandle)); + tsLogObj.logHandle = NULL; +} + void taosCloseLog() { taosStopLog(); if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) { taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL); } tsLogInited = 0; - // In case that other threads still use log resources causing invalid write in valgrind - // we comment two lines below. - // taosLogBuffDestroy(tsLogObj.logHandle); - // taosCloseLog(); + taosLogBuffDestroy(tsLogObj.logHandle); } static bool taosLockLogFile(TdFilePtr pFile) { @@ -231,7 +238,7 @@ static int32_t taosOpenNewLogFile() { tsLogObj.openInProgress = 1; uInfo("open new log file ......"); - TdThread thread; + TdThread thread; TdThreadAttr attr; taosThreadAttrInit(&attr); taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED); @@ -506,45 +513,45 @@ static void taosCloseLogByFd(TdFilePtr pFile) { } static SLogBuff *taosLogBuffNew(int32_t bufSize) { - SLogBuff *tLogBuff = NULL; + SLogBuff *pLogBuf = NULL; - tLogBuff = taosMemoryCalloc(1, sizeof(SLogBuff)); - if (tLogBuff == NULL) return NULL; + pLogBuf = taosMemoryCalloc(1, sizeof(SLogBuff)); + if (pLogBuf == NULL) return NULL; - LOG_BUF_BUFFER(tLogBuff) = taosMemoryMalloc(bufSize); - if (LOG_BUF_BUFFER(tLogBuff) == NULL) goto _err; + LOG_BUF_BUFFER(pLogBuf) = taosMemoryMalloc(bufSize); + if (LOG_BUF_BUFFER(pLogBuf) == NULL) goto _err; - LOG_BUF_START(tLogBuff) = LOG_BUF_END(tLogBuff) = 0; - LOG_BUF_SIZE(tLogBuff) = bufSize; - tLogBuff->minBuffSize = bufSize / 10; - tLogBuff->stop = 0; + LOG_BUF_START(pLogBuf) = LOG_BUF_END(pLogBuf) = 0; + LOG_BUF_SIZE(pLogBuf) = bufSize; + pLogBuf->minBuffSize = bufSize / 10; + pLogBuf->stop = 0; - if (taosThreadMutexInit(&LOG_BUF_MUTEX(tLogBuff), NULL) < 0) goto _err; - // tsem_init(&(tLogBuff->buffNotEmpty), 0, 0); + if (taosThreadMutexInit(&LOG_BUF_MUTEX(pLogBuf), NULL) < 0) goto _err; + // tsem_init(&(pLogBuf->buffNotEmpty), 0, 0); - return tLogBuff; + return pLogBuf; _err: - taosMemoryFreeClear(LOG_BUF_BUFFER(tLogBuff)); - taosMemoryFreeClear(tLogBuff); + taosMemoryFreeClear(LOG_BUF_BUFFER(pLogBuf)); + taosMemoryFreeClear(pLogBuf); return NULL; } -static void taosCopyLogBuffer(SLogBuff *tLogBuff, int32_t start, int32_t end, const char *msg, int32_t msgLen) { +static void taosCopyLogBuffer(SLogBuff *pLogBuf, int32_t start, int32_t end, const char *msg, int32_t msgLen) { if (start > end) { - memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen); + memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen); } else { - if (LOG_BUF_SIZE(tLogBuff) - end < msgLen) { - memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, LOG_BUF_SIZE(tLogBuff) - end); - memcpy(LOG_BUF_BUFFER(tLogBuff), msg + LOG_BUF_SIZE(tLogBuff) - end, msgLen - LOG_BUF_SIZE(tLogBuff) + end); + if (LOG_BUF_SIZE(pLogBuf) - end < msgLen) { + memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, LOG_BUF_SIZE(pLogBuf) - end); + memcpy(LOG_BUF_BUFFER(pLogBuf), msg + LOG_BUF_SIZE(pLogBuf) - end, msgLen - LOG_BUF_SIZE(pLogBuf) + end); } else { - memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen); + memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen); } } - LOG_BUF_END(tLogBuff) = (LOG_BUF_END(tLogBuff) + msgLen) % LOG_BUF_SIZE(tLogBuff); + LOG_BUF_END(pLogBuf) = (LOG_BUF_END(pLogBuf) + msgLen) % LOG_BUF_SIZE(pLogBuf); } -static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen) { +static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen) { int32_t start = 0; int32_t end = 0; int32_t remainSize = 0; @@ -552,13 +559,13 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms char tmpBuf[40] = {0}; int32_t tmpBufLen = 0; - if (tLogBuff == NULL || tLogBuff->stop) return -1; + if (pLogBuf == NULL || pLogBuf->stop) return -1; - taosThreadMutexLock(&LOG_BUF_MUTEX(tLogBuff)); - start = LOG_BUF_START(tLogBuff); - end = LOG_BUF_END(tLogBuff); + taosThreadMutexLock(&LOG_BUF_MUTEX(pLogBuf)); + start = LOG_BUF_START(pLogBuf); + end = LOG_BUF_END(pLogBuf); - remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(tLogBuff) - end - 1); + remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(pLogBuf) - end - 1); if (lostLine > 0) { sprintf(tmpBuf, "...Lost %" PRId64 " lines here...\n", lostLine); @@ -568,47 +575,47 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) { lostLine++; tsAsyncLogLostLines++; - taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff)); + taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); return -1; } if (lostLine > 0) { - taosCopyLogBuffer(tLogBuff, start, end, tmpBuf, tmpBufLen); + taosCopyLogBuffer(pLogBuf, start, end, tmpBuf, tmpBufLen); lostLine = 0; } - taosCopyLogBuffer(tLogBuff, LOG_BUF_START(tLogBuff), LOG_BUF_END(tLogBuff), msg, msgLen); + taosCopyLogBuffer(pLogBuf, LOG_BUF_START(pLogBuf), LOG_BUF_END(pLogBuf), msg, msgLen); // int32_t w = atomic_sub_fetch_32(&waitLock, 1); /* - if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(tLogBuff) * 4 /5))) { - tsem_post(&(tLogBuff->buffNotEmpty)); + if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(pLogBuf) * 4 /5))) { + tsem_post(&(pLogBuf->buffNotEmpty)); dbgPostN++; } else { dbgNoPostN++; } */ - taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff)); + taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); return 0; } -static int32_t taosGetLogRemainSize(SLogBuff *tLogBuff, int32_t start, int32_t end) { +static int32_t taosGetLogRemainSize(SLogBuff *pLogBuf, int32_t start, int32_t end) { int32_t rSize = end - start; - return rSize >= 0 ? rSize : LOG_BUF_SIZE(tLogBuff) + rSize; + return rSize >= 0 ? rSize : LOG_BUF_SIZE(pLogBuf) + rSize; } -static void taosWriteLog(SLogBuff *tLogBuff) { +static void taosWriteLog(SLogBuff *pLogBuf) { static int32_t lastDuration = 0; int32_t remainChecked = 0; int32_t start, end, pollSize; do { if (remainChecked == 0) { - start = LOG_BUF_START(tLogBuff); - end = LOG_BUF_END(tLogBuff); + start = LOG_BUF_START(pLogBuf); + end = LOG_BUF_END(pLogBuf); if (start == end) { dbgEmptyW++; @@ -616,8 +623,8 @@ static void taosWriteLog(SLogBuff *tLogBuff) { return; } - pollSize = taosGetLogRemainSize(tLogBuff, start, end); - if (pollSize < tLogBuff->minBuffSize) { + pollSize = taosGetLogRemainSize(pLogBuf, start, end); + if (pollSize < pLogBuf->minBuffSize) { lastDuration += tsWriteInterval; if (lastDuration < LOG_MAX_WAIT_MSEC) { break; @@ -628,38 +635,38 @@ static void taosWriteLog(SLogBuff *tLogBuff) { } if (start < end) { - taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, pollSize); + taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, pollSize); } else { - int32_t tsize = LOG_BUF_SIZE(tLogBuff) - start; - taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, tsize); + int32_t tsize = LOG_BUF_SIZE(pLogBuf) - start; + taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, tsize); - taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff), end); + taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf), end); } dbgWN++; dbgWSize += pollSize; - if (pollSize < tLogBuff->minBuffSize) { + if (pollSize < pLogBuf->minBuffSize) { dbgSmallWN++; if (tsWriteInterval < LOG_MAX_INTERVAL) { tsWriteInterval += LOG_INTERVAL_STEP; } - } else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 3) { + } else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 3) { dbgBigWN++; tsWriteInterval = LOG_MIN_INTERVAL; - } else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 4) { + } else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 4) { if (tsWriteInterval > LOG_MIN_INTERVAL) { tsWriteInterval -= LOG_INTERVAL_STEP; } } - LOG_BUF_START(tLogBuff) = (LOG_BUF_START(tLogBuff) + pollSize) % LOG_BUF_SIZE(tLogBuff); + LOG_BUF_START(pLogBuf) = (LOG_BUF_START(pLogBuf) + pollSize) % LOG_BUF_SIZE(pLogBuf); - start = LOG_BUF_START(tLogBuff); - end = LOG_BUF_END(tLogBuff); + start = LOG_BUF_START(pLogBuf); + end = LOG_BUF_END(pLogBuf); - pollSize = taosGetLogRemainSize(tLogBuff, start, end); - if (pollSize < tLogBuff->minBuffSize) { + pollSize = taosGetLogRemainSize(pLogBuf, start, end); + if (pollSize < pLogBuf->minBuffSize) { break; } @@ -670,16 +677,16 @@ static void taosWriteLog(SLogBuff *tLogBuff) { } static void *taosAsyncOutputLog(void *param) { - SLogBuff *tLogBuff = (SLogBuff *)param; + SLogBuff *pLogBuf = (SLogBuff *)param; setThreadName("log"); while (1) { taosMsleep(tsWriteInterval); // Polling the buffer - taosWriteLog(tLogBuff); + taosWriteLog(pLogBuf); - if (tLogBuff->stop) break; + if (pLogBuf->stop) break; } return NULL; diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim index faac5b2828..92fc9dccc9 100644 --- a/tests/script/tmp/data.sim +++ b/tests/script/tmp/data.sim @@ -3,6 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect +return sql create database db sql create table db.tb (ts timestamp, i int) sql insert into db.tb values(now, 1) diff --git a/tests/script/tsim/bnode/basic1.sim b/tests/script/tsim/bnode/basic1.sim index 0ce0c2bc5d..b1db6efc72 100644 --- a/tests/script/tsim/bnode/basic1.sim +++ b/tests/script/tsim/bnode/basic1.sim @@ -24,7 +24,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi @@ -71,7 +71,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index e9795bd8d2..525de9c5c4 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -72,7 +72,7 @@ print rows: $rows print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 print ====> dataX_db -print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db +print $data(db)[0] $data(db)[1] $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db if $rows != 3 then return -1 diff --git a/tests/script/tsim/db/basic6.sim b/tests/script/tsim/db/basic6.sim index 4d0a1e9ee9..f682dcc816 100644 --- a/tests/script/tsim/db/basic6.sim +++ b/tests/script/tsim/db/basic6.sim @@ -17,7 +17,6 @@ print =============== step1 # quorum presicion sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' sql show databases -print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 if $rows != 3 then diff --git a/tests/script/tsim/dnode/basic1.sim b/tests/script/tsim/dnode/basic1.sim index 51399e9050..d49dba60f3 100644 --- a/tests/script/tsim/dnode/basic1.sim +++ b/tests/script/tsim/dnode/basic1.sim @@ -29,7 +29,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi @@ -76,7 +76,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi diff --git a/tests/script/tsim/mnode/basic1.sim b/tests/script/tsim/mnode/basic1.sim index e3d27d0c13..235889ece6 100644 --- a/tests/script/tsim/mnode/basic1.sim +++ b/tests/script/tsim/mnode/basic1.sim @@ -24,7 +24,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi @@ -71,7 +71,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi diff --git a/tests/script/tsim/parser/fourArithmetic-basic.sim b/tests/script/tsim/parser/fourArithmetic-basic.sim index eee294dc80..dde451279d 100644 --- a/tests/script/tsim/parser/fourArithmetic-basic.sim +++ b/tests/script/tsim/parser/fourArithmetic-basic.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/qnode/basic1.sim b/tests/script/tsim/qnode/basic1.sim index 3b478cfa46..2351403909 100644 --- a/tests/script/tsim/qnode/basic1.sim +++ b/tests/script/tsim/qnode/basic1.sim @@ -24,7 +24,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi @@ -71,7 +71,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi diff --git a/tests/script/tsim/query/charScalarFunction.sim b/tests/script/tsim/query/charScalarFunction.sim index 18ee93f610..f1575d7293 100644 --- a/tests/script/tsim/query/charScalarFunction.sim +++ b/tests/script/tsim/query/charScalarFunction.sim @@ -2,7 +2,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim index 3358b24e83..638109d510 100644 --- a/tests/script/tsim/query/explain.sim +++ b/tests/script/tsim/query/explain.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 -print ========= start dnode1 as master +print ========= start dnode1 as LEADER system sh/exec.sh -n dnode1 -s start sleep 2000 sql connect @@ -45,8 +45,8 @@ sql explain select * from information_schema.user_stables; sql explain select count(*),sum(f1) from tb1; sql explain select count(*),sum(f1) from st1; sql explain select count(*),sum(f1) from st1 group by f1; -sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); -sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n); +sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev); +sql explain select min(f1) from st1 interval(1m, 2a) sliding(30s); print ======== step3 sql explain verbose true select * from st1 where -2; @@ -65,8 +65,8 @@ sql explain analyze select * from information_schema.user_stables; sql explain analyze select count(*),sum(f1) from tb1; sql explain analyze select count(*),sum(f1) from st1; sql explain analyze select count(*),sum(f1) from st1 group by f1; -sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); -sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n); +sql explain analyze select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev); +sql explain analyze select min(f1) from st1 interval(3m, 2a) sliding(1m); print ======== step5 sql explain analyze verbose true select ts from st1 where -2; @@ -78,20 +78,20 @@ sql explain analyze verbose true select * from information_schema.user_stables; sql explain analyze verbose true select count(*),sum(f1) from tb1; sql explain analyze verbose true select count(*),sum(f1) from st1; sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1; -sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain analyze verbose true select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev); sql explain analyze verbose true select ts from tb1 where f1 > 0; sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00'; sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0; -sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n); +sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m); sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0; #not pass case #sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa; #sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts; #sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts; -#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1s, 2d) sliding(3s) order by ts; -#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(3n) fill(linear) order by ts; +#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(10s, 2s) sliding(3s) order by ts; +#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(30s) fill(linear) order by ts; #sql explain select max(f1) from tb1 SESSION(ts, 1s); #sql explain select max(f1) from st1 SESSION(ts, 1s); #sql explain select * from tb1, tb2 where tb1.ts=tb2.ts; diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index 6c736e9daa..68860dc2cb 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -200,43 +200,8 @@ if $data02 != 2678400000 then return -1 endi -sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) -print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) -print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -if $rows != 4 then - return -1 -endi -if $data00 != @21-11-30 08:00:00.000@ then - return -1 -endi -if $data01 != NULL then - print expect null, actual: $data01 - return -1 -endi -if $data31 != $data34 then - return -1 -endi - -sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) -print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) -print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -if $rows != 4 then - return -1 -endi -if $data01 != NULL then - return -1 -endi -if $data04 != 1 then - return -1 -endi +sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) +sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) @@ -254,37 +219,8 @@ if $data04 != 2 then return -1 endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) -print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -if $rows != 3 then - return -1 -endi -if $data00 != 2 then - return -1 -endi -if $data04 != 2 then - return -1 -endi - -sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) -print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) -print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -if $rows != 3 then - return -1 -endi -if $data01 != 2 then - return -1 -endi -if $data04 != 2 then - return -1 -endi +sql_error select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) +sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) #================================================= print =============== stop and restart taosd diff --git a/tests/script/tsim/query/scalarFunction.sim b/tests/script/tsim/query/scalarFunction.sim index be75e1a21c..80d2dafa84 100644 --- a/tests/script/tsim/query/scalarFunction.sim +++ b/tests/script/tsim/query/scalarFunction.sim @@ -2,7 +2,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 5062c556a5..d5e77c7b28 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -2,7 +2,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 @@ -27,14 +26,6 @@ sql connect $vgroups = 4 $dbNamme = d0 -print ====> create database d1 precision 'us' -sql create database d1 precision 'us' -sql use d1 -sql create table dev_001 (ts timestamp ,i timestamp ,j int) -sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) -sql create table secondts(ts timestamp,t2 timestamp,i int) -sql insert into secondts values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) - print ====> create database $dbNamme vgroups $vgroups sql create database $dbNamme vgroups $vgroups sql show databases @@ -290,36 +281,38 @@ print ================> syntax error check not active ================> reactive sql_error select * from dev_001 session(ts,1w) sql_error select count(*) from st session(ts,1w) sql_error select count(*) from dev_001 group by tagtype session(ts,1w) -sql select count(*) from dev_001 session(ts,1n) -sql select count(*) from dev_001 session(ts,1y) -sql select count(*) from dev_001 session(ts,0s) +sql_error sql select count(*) from dev_001 session(ts,1n) +sql_error sql select count(*) from dev_001 session(ts,1y) +sql_error sql select count(*) from dev_001 session(ts,0s) sql_error select count(*) from dev_001 session(i,1y) sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0' +# vnode does not return the precision of the table print ====> create database d1 precision 'us' sql create database d1 precision 'us' sql use d1 sql create table dev_001 (ts timestamp ,i timestamp ,j int) sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) -print ====> select count(*) from dev_001 session(ts,1u) -sql select _wstartts, count(*) from dev_001 session(ts,1u) -print rows: $rows -print $data00 $data01 $data02 $data03 -print $data10 $data11 $data12 $data13 -print $data20 $data21 $data22 $data23 -print $data30 $data31 $data32 $data33 -if $rows != 4 then - print expect 2, actual: $rows - return -1 -endi - -if $data01 != 1 then - return -1 -endi - -#sql_error select count(*) from dev_001 session(i,1s) sql create table secondts(ts timestamp,t2 timestamp,i int) -#sql_error select count(*) from secondts session(t2,2s) +sql insert into secondts values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) + +#print ====> select count(*) from dev_001 session(ts,1u) +#sql select _wstartts, count(*) from dev_001 session(ts,1u) +#print rows: $rows +#print $data00 $data01 $data02 $data03 +#print $data10 $data11 $data12 $data13 +#print $data20 $data21 $data22 $data23 +#print $data30 $data31 $data32 $data33 +#if $rows != 4 then +# print expect 2, actual: $rows +# return -1 +#endi +#if $data01 != 1 then +# return -1 +#endi + +sql_error select count(*) from dev_001 session(i,1s) +sql_error select count(*) from secondts session(t2,2s) if $loop_test == 0 then print =============== stop and restart taosd diff --git a/tests/script/tsim/query/time_process.sim b/tests/script/tsim/query/time_process.sim new file mode 100644 index 0000000000..0b77c41bb2 --- /dev/null +++ b/tests/script/tsim/query/time_process.sim @@ -0,0 +1,133 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 3 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +sql create table t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2019-01-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2019-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2019-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2020-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2020-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2020-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2020-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2021-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2021-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2021-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-02-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) +sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + +print =============== insert data into child table t1 +sql insert into t1 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into t1 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into t1 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into t1 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into t1 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into t1 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into t1 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into t1 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into t1 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== + +print =============== step1 +print =====sql : select timediff(ts , c10) from ct4 +sql select cast(c1 as bigint) as b from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + + +#================================================= +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =============== step2 after wal + + +print =============== clear +sql drop database db +sql show databases +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/snode/basic1.sim b/tests/script/tsim/snode/basic1.sim index 3b478cfa46..2351403909 100644 --- a/tests/script/tsim/snode/basic1.sim +++ b/tests/script/tsim/snode/basic1.sim @@ -24,7 +24,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi @@ -71,7 +71,7 @@ if $data00 != 1 then return -1 endi -if $data02 != master then +if $data02 != LEADER then return -1 endi diff --git a/tests/script/tsim/stable/disk.sim b/tests/script/tsim/stable/disk.sim index 9f445cb6a8..97ef779ff2 100644 --- a/tests/script/tsim/stable/disk.sim +++ b/tests/script/tsim/stable/disk.sim @@ -132,11 +132,13 @@ print =============== step7 # return -1 # endi -sql select count(tbcol) from $mt -print ===> $data00 -if $data00 != $totalNum then - return -1 -endi +# TODO +# print ==========> block opt will cause this crash, table scan need to fix this during plan gen ===============> +#sql select count(tbcol) from $mt +#print ===> $data00 +#if $data00 != $totalNum then +# return -1 +#endi print =============== step8 # TODO diff --git a/tests/script/tsim/table/basic1.sim b/tests/script/tsim/table/basic1.sim index 75cd0c8744..be3b718fae 100644 --- a/tests/script/tsim/table/basic1.sim +++ b/tests/script/tsim/table/basic1.sim @@ -205,7 +205,8 @@ endi print =============== query data from st print ==============select * against super will cause crash. sql select ts from st -if $rows != 21 then +if $rows != 21 then + print expect 21, actual $rows return -1 endi diff --git a/tests/script/tsim/tmq/basic1.sim b/tests/script/tsim/tmq/basic1.sim index 84927c83a0..f7bd273624 100644 --- a/tests/script/tsim/tmq/basic1.sim +++ b/tests/script/tsim/tmq/basic1.sim @@ -11,7 +11,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim index 4fd4e60648..cf53cc7bcd 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim index 3f199836f4..fe37ffffcb 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim index 818a87a5a1..76f3c93e27 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim index 1789a6bef3..86e0b32980 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim index e0c463df65..d846632da4 100644 --- a/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim +++ b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/mainConsumerInOneTopic.sim b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim index 985237e34b..f6fccee5e5 100644 --- a/tests/script/tsim/tmq/mainConsumerInOneTopic.sim +++ b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/multiTopic.sim b/tests/script/tsim/tmq/multiTopic.sim index 4ad2df38f8..3795e82e86 100644 --- a/tests/script/tsim/tmq/multiTopic.sim +++ b/tests/script/tsim/tmq/multiTopic.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/oneTopic.sim b/tests/script/tsim/tmq/oneTopic.sim index dbe6dbcb27..d4353f60c9 100644 --- a/tests/script/tsim/tmq/oneTopic.sim +++ b/tests/script/tsim/tmq/oneTopic.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim b/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim index 2bad16fbaa..01bf91fd9f 100644 --- a/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim +++ b/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim @@ -14,7 +14,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 diff --git a/tests/script/tsim/user/basic1.sim b/tests/script/tsim/user/basic1.sim index 7af5ba8d00..06a52c6604 100644 --- a/tests/script/tsim/user/basic1.sim +++ b/tests/script/tsim/user/basic1.sim @@ -9,9 +9,9 @@ if $rows != 1 then return -1 endi -print $data00 $data01 $data02 -print $data10 $data11 $data22 -print $data20 $data11 $data22 +print $data[0][0] $data[0][1] $data[0][2] +print $data[1][0] $data[1][1] $data[1][2] +print $data[2][0] $data[1][2] $data[2][2] sql_error show accounts; sql_error create account a pass "a" @@ -25,10 +25,10 @@ if $rows != 2 then return -1 endi -print $data00 $data01 $data02 -print $data10 $data11 $data12 -print $data20 $data11 $data22 -print $data30 $data31 $data32 +print $data[0][0] $data[0][1] $data[0][2] +print $data[1][0] $data[1][1] $data[1][2] +print $data[2][0] $data[1][2] $data[2][2] +print $data[3][0] $data[3][1] $data[3][2] print =============== create user2 sql create user user2 PASS 'user2' @@ -37,10 +37,10 @@ if $rows != 3 then return -1 endi -print $data00 $data01 $data02 -print $data10 $data11 $data12 -print $data20 $data11 $data22 -print $data30 $data31 $data32 +print $data[0][0] $data[0][1] $data[0][2] +print $data[1][0] $data[1][1] $data[1][2] +print $data[2][0] $data[1][2] $data[2][2] +print $data[3][0] $data[3][1] $data[3][2] print $data40 $data41 $data42 print =============== drop user1 @@ -50,10 +50,10 @@ if $rows != 2 then return -1 endi -print $data00 $data01 $data02 -print $data10 $data11 $data22 -print $data20 $data11 $data22 -print $data30 $data31 $data32 +print $data[0][0] $data[0][1] $data[0][2] +print $data[1][0] $data[1][1] $data[1][2] +print $data[2][0] $data[1][2] $data[2][2] +print $data[3][0] $data[3][1] $data[3][2] print =============== restart taosd system sh/exec.sh -n dnode1 -s stop @@ -66,9 +66,9 @@ if $rows != 2 then return -1 endi -print $data00 $data01 $data02 -print $data10 $data11 $data22 -print $data20 $data11 $data22 -print $data30 $data31 $data32 +print $data[0][0] $data[0][1] $data[0][2] +print $data[1][0] $data[1][1] $data[1][2] +print $data[2][0] $data[1][2] $data[2][2] +print $data[3][0] $data[3][1] $data[3][2] system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/2-query/between.py b/tests/system-test/2-query/between.py new file mode 100644 index 0000000000..e8bde3c11c --- /dev/null +++ b/tests/system-test/2-query/between.py @@ -0,0 +1,205 @@ +import taos +import sys + +from util.log import * +from util.sql import * +from util.cases import * + + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def run(self): # sourcery skip: extract-duplicate-method + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + tdSql.execute( + '''create table if not exists supt + (ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint) + tags(location binary(64), type int, isused bool , family nchar(64))''' + ) + tdSql.execute("create table t1 using supt tags('beijing', 1, 1, 'nchar1')") + tdSql.execute("create table t2 using supt tags('shanghai', 2, 0, 'nchar2')") + + tdLog.printNoPrefix("==========step2:insert data") + for i in range(10): + tdSql.execute( + f"insert into t1 values (now()+{i}m, {32767+i}, {20.0+i/10}, {2**31+i}, {3.4*10**38+i/10}, {127+i}, {i})" + ) + tdSql.execute( + f"insert into t2 values (now()-{i}m, {-32767-i}, {20.0-i/10}, {-i-2**31}, {-i/10-3.4*10**38}, {-127-i}, {-i})" + ) + tdSql.execute( + f"insert into t1 values (now()+11m, {2**31-1}, {pow(10,37)*34}, {pow(2,63)-1}, {1.7*10**308}, 32767, 127)" + ) + tdSql.execute( + f"insert into t2 values (now()-11m, {1-2**31}, {-3.4*10**38}, {1-2**63}, {-1.7*10**308}, -32767, -127)" + ) + tdSql.execute( + f"insert into t2 values (now()-12m, null , {-3.4*10**38}, null , {-1.7*10**308}, null , null)" + ) + + tdLog.printNoPrefix("==========step3:query timestamp type") + + # tdSql.query("select * from t1 where ts between now()-1m and now()+10m") + # tdSql.checkRows(10) + # tdSql.query("select * from t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'") + # tdSql.checkRows(11) + # tdSql.query("select * from t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'") + # tdSql.checkRows(0) + # tdSql.query("select * from t1 where ts between -2793600 and 31507199") + # tdSql.checkRows(0) + # tdSql.query("select * from t1 where ts between 1609430400000 and 4765104000000") + # tdSql.checkRows(11) + + tdLog.printNoPrefix("==========step4:query int type") + + tdSql.query("select * from t1 where c1 between 32767 and 32776") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c1 between 32766.9 and 32776.1") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c1 between 32776 and 32767") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c1 between 'a' and 'e'") + tdSql.checkRows(0) + # tdSql.query("select * from t1 where c1 between 0x64 and 0x69") + # tdSql.checkRows(6) + # tdSql.query("select * from t1 where c1 not between 100 and 106") + # tdSql.checkRows(11) + tdSql.query(f"select * from t1 where c1 between {2**31-2} and {2**31+1}") + tdSql.checkRows(1) + tdSql.error(f"select * from t2 where c1 between null and {1-2**31}") + # tdSql.checkRows(3) + tdSql.query(f"select * from t2 where c1 between {-2**31} and {1-2**31}") + tdSql.checkRows(1) + + tdLog.printNoPrefix("==========step5:query float type") + + tdSql.query("select * from t1 where c2 between 20.0 and 21.0") + tdSql.checkRows(10) + tdSql.query(f"select * from t1 where c2 between {-3.4*10**38-1} and {3.4*10**38+1}") + tdSql.checkRows(11) + tdSql.query("select * from t1 where c2 between 21.0 and 20.0") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c2 between 'DC3' and 'SYN'") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c2 not between 0.1 and 0.2") + # tdSql.checkRows(11) + tdSql.query(f"select * from t1 where c2 between {pow(10,38)*3.4} and {pow(10,38)*3.4+1}") + # tdSql.checkRows(1) + tdSql.query(f"select * from t2 where c2 between {-3.4*10**38-1} and {-3.4*10**38}") + # tdSql.checkRows(2) + tdSql.error(f"select * from t2 where c2 between null and {-3.4*10**38}") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step6:query bigint type") + + tdSql.query(f"select * from t1 where c3 between {2**31} and {2**31+10}") + tdSql.checkRows(10) + tdSql.query(f"select * from t1 where c3 between {-2**63} and {2**63}") + # tdSql.checkRows(11) + tdSql.query(f"select * from t1 where c3 between {2**31+10} and {2**31}") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c3 between 'a' and 'z'") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c3 not between 1 and 2") + # tdSql.checkRows(0) + tdSql.query(f"select * from t1 where c3 between {2**63-2} and {2**63-1}") + tdSql.checkRows(1) + tdSql.query(f"select * from t2 where c3 between {-2**63} and {1-2**63}") + # tdSql.checkRows(3) + tdSql.error(f"select * from t2 where c3 between null and {1-2**63}") + # tdSql.checkRows(2) + + tdLog.printNoPrefix("==========step7:query double type") + + tdSql.query(f"select * from t1 where c4 between {3.4*10**38} and {3.4*10**38+10}") + tdSql.checkRows(10) + tdSql.query(f"select * from t1 where c4 between {1.7*10**308+1} and {1.7*10**308+2}") + # 因为精度原因,在超出bigint边界后,数值不能进行准确的判断 + # tdSql.checkRows(0) + tdSql.query(f"select * from t1 where c4 between {3.4*10**38+10} and {3.4*10**38}") + # tdSql.checkRows(0) + tdSql.query("select * from t1 where c4 between 'a' and 'z'") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c4 not between 1 and 2") + # tdSql.checkRows(0) + tdSql.query(f"select * from t1 where c4 between {1.7*10**308} and {1.7*10**308+1}") + # tdSql.checkRows(1) + tdSql.query(f"select * from t2 where c4 between {-1.7*10**308-1} and {-1.7*10**308}") + # tdSql.checkRows(3) + tdSql.error(f"select * from t2 where c4 between null and {-1.7*10**308}") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step8:query smallint type") + + tdSql.query("select * from t1 where c5 between 127 and 136") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c5 between 126.9 and 135.9") + tdSql.checkRows(9) + tdSql.query("select * from t1 where c5 between 136 and 127") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c5 between '~' and 'ˆ'") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c5 not between 1 and 2") + # tdSql.checkRows(0) + tdSql.query("select * from t1 where c5 between 32767 and 32768") + tdSql.checkRows(1) + tdSql.query("select * from t2 where c5 between -32768 and -32767") + tdSql.checkRows(1) + tdSql.error("select * from t2 where c5 between null and -32767") + # tdSql.checkRows(1) + + tdLog.printNoPrefix("==========step9:query tinyint type") + + tdSql.query("select * from t1 where c6 between 0 and 9") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c6 between -1.1 and 8.9") + tdSql.checkRows(9) + tdSql.query("select * from t1 where c6 between 9 and 0") + tdSql.checkRows(0) + tdSql.query("select * from t1 where c6 between 'NUL' and 'HT'") + tdSql.checkRows(1) + tdSql.query("select * from t1 where c6 not between 1 and 2") + # tdSql.checkRows(1) + tdSql.query("select * from t1 where c6 between 127 and 128") + tdSql.checkRows(1) + tdSql.query("select * from t2 where c6 between -128 and -127") + tdSql.checkRows(1) + tdSql.error("select * from t2 where c6 between null and -127") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step10:invalid query type") + + # tdSql.query("select * from supt where location between 'beijing' and 'shanghai'") + # tdSql.checkRows(23) + # # 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0" + # tdSql.query("select * from supt where isused between 0 and 1") + # tdSql.checkRows(23) + # tdSql.query("select * from supt where isused between -1 and 0") + # tdSql.checkRows(0) + # tdSql.error("select * from supt where isused between false and true") + # tdSql.query("select * from supt where family between '拖拉机' and '自行车'") + # tdSql.checkRows(23) + + tdLog.printNoPrefix("==========step11:query HEX/OCT/BIN type") + + tdSql.error("select * from t1 where c6 between 0x7f and 0x80") # check filter HEX + tdSql.error("select * from t1 where c6 between 0b1 and 0b11111") # check filter BIN + tdSql.error("select * from t1 where c6 between 0b1 and 0x80") + tdSql.error("select * from t1 where c6=0b1") + tdSql.error("select * from t1 where c6=0x1") + # 八进制数据会按照十进制数据进行判定 + tdSql.query("select * from t1 where c6 between 01 and 0200") # check filter OCT + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh new file mode 100755 index 0000000000..0b8bbd24b2 --- /dev/null +++ b/tests/system-test/fulltest.sh @@ -0,0 +1,17 @@ +python3 ./test.py -f 2-query/between.py + + + + + + + + + + + + + + + + diff --git a/tests/system-test/test.py b/tests/system-test/test.py new file mode 100644 index 0000000000..31afd027ec --- /dev/null +++ b/tests/system-test/test.py @@ -0,0 +1,198 @@ +#!/usr/bin/python +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +import time +from distutils.log import warn as printf +from fabric2 import Connection +sys.path.append("../pytest") +from util.log import * +from util.dnodes import * +from util.cases import * + +import taos + + +if __name__ == "__main__": + + fileName = "all" + deployPath = "" + masterIp = "" + testCluster = False + valgrind = 0 + logSql = True + stop = 0 + restart = False + windows = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-f Name of test case file written by Python') + tdLog.printNoPrefix('-p Deploy Path for Simulator') + tdLog.printNoPrefix('-m Master Ip for Simulator') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-g valgrind Test Flag') + tdLog.printNoPrefix('-r taosd restart test') + tdLog.printNoPrefix('-w taos on windows') + sys.exit(0) + + if key in ['-r', '--restart']: + restart = True + + if key in ['-f', '--file']: + fileName = value + + if key in ['-p', '--path']: + deployPath = value + + if key in ['-m', '--master']: + masterIp = value + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-c', '--cluster']: + testCluster = True + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if key in ['-w', '--windows']: + windows = 1 + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + tdLog.info('stop All dnodes') + + if masterIp == "": + host = '127.0.0.1' + else: + host = masterIp + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + if windows: + tdCases.logSql(logSql) + tdLog.info("Procedures for testing self-deployment") + td_clinet = TDSimClient("C:\\TDengine") + td_clinet.deploy() + remote_conn = Connection("root@%s"%host) + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + remote_conn.run("python3 ./test.py") + conn = taos.connect( + host="%s"%(host), + config=td_clinet.cfgDir) + tdCases.runOneWindows(conn, fileName) + else: + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addLinux' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace("/", ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + tdDnodes.deploy(1,ucase.updatecfgDict) + except : + tdDnodes.deploy(1,{}) + else: + pass + tdDnodes.deploy(1,{}) + tdDnodes.start(1) + + + + tdCases.logSql(logSql) + + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + if fileName == "all": + tdCases.runAllLinux(conn) + else: + tdCases.runOneLinux(conn, fileName) + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + else: + tdLog.info("not need to query") + conn.close() diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 804894a69d..41e9382379 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -3,21 +3,21 @@ add_executable(tmq_demo tmqDemo.c) add_executable(tmq_sim tmqSim.c) target_link_libraries( create_table - PUBLIC taos + PUBLIC taos_static PUBLIC util PUBLIC common PUBLIC os ) target_link_libraries( tmq_demo - PUBLIC taos + PUBLIC taos_static PUBLIC util PUBLIC common PUBLIC os ) target_link_libraries( tmq_sim - PUBLIC taos + PUBLIC taos_static PUBLIC util PUBLIC common PUBLIC os diff --git a/tests/tsim/CMakeLists.txt b/tests/tsim/CMakeLists.txt index 81737809d9..c2cf7ac3c5 100644 --- a/tests/tsim/CMakeLists.txt +++ b/tests/tsim/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src TSIM_SRC) add_executable(tsim ${TSIM_SRC}) target_link_libraries( tsim - PUBLIC taos + PUBLIC taos_static PUBLIC util PUBLIC common PUBLIC os diff --git a/tests/tsim/inc/simInt.h b/tests/tsim/inc/simInt.h index c8b13736c7..f9e96fc67b 100644 --- a/tests/tsim/inc/simInt.h +++ b/tests/tsim/inc/simInt.h @@ -33,9 +33,9 @@ #define MAX_BACKGROUND_SCRIPT_NUM 10 #define MAX_FILE_NAME_LEN 256 #define MAX_ERROR_LEN 1024 -#define MAX_QUERY_VALUE_LEN 40 -#define MAX_QUERY_COL_NUM 20 -#define MAX_QUERY_ROW_NUM 20 +#define MAX_QUERY_VALUE_LEN 1024 +#define MAX_QUERY_COL_NUM 100 +#define MAX_QUERY_ROW_NUM 100 #define MAX_SYSTEM_RESULT_LEN 2048 #define MAX_VAR_LEN 100 #define MAX_VAR_NAME_LEN 32 diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 5a18084fff..8b3edb6035 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -18,7 +18,7 @@ void simLogSql(char *sql, bool useSharp) { static TdFilePtr pFile = NULL; - char filename[256]; + char filename[256]; sprintf(filename, "%s/sim.sql", simScriptDir); if (pFile == NULL) { // fp = fopen(filename, "w"); @@ -49,6 +49,41 @@ char *simParseHostName(char *varName) { return hostName; } +static void simFindFirstNum(const char *begin, int32_t beginLen, int32_t *num) { + if (beginLen <= 5) { + *num = 0; + } else { + *num = atoi(begin + 5); + } +} + +static void simFindSecondNum(const char *begin, int32_t beginLen, int32_t *num) { + const char *number = strstr(begin, "]["); + if (number == NULL) { + *num = 0; + } else { + *num = atoi(number + 2); + } +} + +static void simFindFirstKeyVal(const char *begin, int32_t beginLen, char *key, int32_t keyLen) { + key[0] = 0; + for (int32_t i = 5; i < beginLen && i - 5 < keyLen; ++i) { + if (begin[i] != 0 && begin[i] != ']' && begin[i] != ')') { + key[i - 5] = begin[i]; + } + } +} + +static void simFindSecondKeyNum(const char *begin, int32_t beginLen, int32_t *num) { + const char *number = strstr(begin, ")["); + if (number == NULL) { + *num = 0; + } else { + *num = atoi(number + 2); + } +} + char *simGetVariable(SScript *script, char *varName, int32_t varLen) { if (strncmp(varName, "hostname", 8) == 0) { return simParseHostName(varName); @@ -66,13 +101,40 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { if (strncmp(varName, "system_content", varLen) == 0) return script->system_ret_content; - // variable like data2_192.168.0.1 if (strncmp(varName, "data", 4) == 0) { if (varLen < 6) { return "null"; } - if (varName[5] == '_') { + int32_t row = 0; + int32_t col = 0; + char keyVal[1024] = {0}; + int32_t keyLen = 1024; + + if (varName[4] == '[') { + // $data[0][1] + simFindFirstNum(varName, varLen, &row); + simFindSecondNum(varName, varLen, &col); + if (row < 0 || row >= MAX_QUERY_ROW_NUM) { + return "null"; + } + if (col < 0 || col >= MAX_QUERY_COL_NUM) { + return "null"; + } + simDebug("script:%s, data[%d][%d]=%s", script->fileName, row, col, script->data[row][col]); + return script->data[row][col]; + } else if (varName[4] == '(') { + // $data(db)[0] + simFindFirstKeyVal(varName, varLen, keyVal, keyLen); + simFindSecondKeyNum(varName, varLen, &col); + for (int32_t i = 0; i < MAX_QUERY_ROW_NUM; ++i) { + if (strncmp(keyVal, script->data[i][0], keyLen) == 0) { + simDebug("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]); + return script->data[i][col]; + } + } + } else if (varName[5] == '_') { + // data2_db int32_t col = varName[4] - '0'; if (col < 0 || col >= MAX_QUERY_COL_NUM) { return "null"; @@ -90,6 +152,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { } return "null"; } else if (varName[6] == '_') { + // data21_db int32_t col = (varName[4] - '0') * 10 + (varName[5] - '0'); if (col < 0 || col >= MAX_QUERY_COL_NUM) { return "null"; @@ -107,6 +170,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { } return "null"; } else { + // $data00 int32_t row = varName[4] - '0'; int32_t col = varName[5] - '0'; if (row < 0 || row >= MAX_QUERY_ROW_NUM) { @@ -119,6 +183,8 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { simDebug("script:%s, data[%d][%d]=%s", script->fileName, row, col, script->data[row][col]); return script->data[row][col]; } + + return "null"; } for (int32_t i = 0; i < script->varLen; ++i) { @@ -127,9 +193,6 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { continue; } if (strncmp(varName, var->varName, varLen) == 0) { - // if (strlen(var->varValue) != 0) - // simDebug("script:%s, var:%s, value:%s", script->fileName, - // var->varName, var->varValue); return var->varValue; } } @@ -305,7 +368,8 @@ bool simExecuteRunBackCmd(SScript *script, char *option) { return true; } -void simReplaceStr(char *buf, char *src, char *dst) { +bool simReplaceStr(char *buf, char *src, char *dst) { + bool replaced = false; char *begin = strstr(buf, src); if (begin != NULL) { int32_t srcLen = (int32_t)strlen(src); @@ -320,13 +384,16 @@ void simReplaceStr(char *buf, char *src, char *dst) { } memcpy(begin, dst, dstLen); + replaced = true; } simInfo("system cmd is %s", buf); + return replaced; } bool simExecuteSystemCmd(SScript *script, char *option) { char buf[4096] = {0}; + bool replaced = false; #ifndef WINDOWS sprintf(buf, "cd %s; ", simScriptDir); @@ -341,7 +408,7 @@ bool simExecuteSystemCmd(SScript *script, char *option) { } if (useValgrind) { - simReplaceStr(buf, "exec.sh", "exec.sh -v"); + replaced = simReplaceStr(buf, "exec.sh", "exec.sh -v"); } simLogSql(buf, true); @@ -359,6 +426,11 @@ bool simExecuteSystemCmd(SScript *script, char *option) { sprintf(script->system_exit_code, "%d", code); script->linePos++; + if (replaced && strstr(buf, "start") != NULL) { + simInfo("====> startup is slow in valgrind mode, so sleep 5 seconds after exec.sh -s start"); + taosMsleep(5000); + } + return true; } @@ -774,7 +846,7 @@ bool simExecuteSqlSlowCmd(SScript *script, char *rest) { bool simExecuteRestfulCmd(SScript *script, char *rest) { TdFilePtr pFile = NULL; - char filename[256]; + char filename[256]; sprintf(filename, "%s/tmp.sql", simScriptDir); // fp = fopen(filename, "w"); pFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 284693795e..3b22b30852 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) target_link_libraries( shell - PUBLIC taos + PUBLIC taos_static PRIVATE os common transport util ) target_include_directories( diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index ac2010efa3..548d2169b1 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -91,11 +91,6 @@ TAOS *shellInit(SShellArguments *_args) { _args->user = TSDB_DEFAULT_USER; } - SConfig *pCfg = cfgInit(); - if (NULL == pCfg) return NULL; - - if (0 != taosAddClientLogCfg(pCfg)) return NULL; - // Connect to the database. TAOS *con = NULL; if (_args->auth == NULL) { diff --git a/tools/shell/src/shellMain.c b/tools/shell/src/shellMain.c index 70563c79e6..8ca8142eca 100644 --- a/tools/shell/src/shellMain.c +++ b/tools/shell/src/shellMain.c @@ -45,7 +45,7 @@ static tsem_t cancelSem; static struct argp_option options[] = { {"host", 'h', "HOST", 0, "TDengine server FQDN to connect. The default host is localhost."}, - {"password", 'p', 0, 0, "The password to use when connecting to the server."}, + {"password", 'p', 0, 0, "The password to use when connecting to the server."}, {"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."}, {"user", 'u', "USER", 0, "The user name to use when connecting to the server."}, {"auth", 'A', "Auth", 0, "The auth string to use when connecting to the server."},