From 6743b544e9757b3c5cdf285e74e5bf525cc1e4fe Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 17 Jun 2022 18:32:08 +0800 Subject: [PATCH 01/81] fix: error in json --- source/client/src/clientImpl.c | 2 +- source/libs/executor/inc/executorimpl.h | 1 - source/libs/executor/src/executorimpl.c | 3 +-- source/libs/executor/src/scanoperator.c | 5 +---- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 10c2161478..7e2557b048 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1346,7 +1346,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int if (jsonInnerType == TSDB_DATA_TYPE_NULL) { sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L); varDataSetLen(dst, strlen(varDataVal(dst))); - } else if (jsonInnerType == TD_TAG_JSON) { + } else if (jsonInnerType & TD_TAG_JSON) { char* jsonString = parseTagDatatoJson(pStart); STR_TO_VARSTR(dst, jsonString); taosMemoryFree(jsonString); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 034e2893df..5a1ba28082 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -347,7 +347,6 @@ typedef struct STagScanInfo { int32_t curPos; SReadHandle readHandle; STableListInfo *pTableList; - SNode* pFilterNode; // filter info, } STagScanInfo; typedef enum EStreamScanMode { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 40b019eb5d..f21c5361f8 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4587,8 +4587,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) { STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode; - int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo, - pScanPhyNode->node.pConditions); + int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo, pTagCond); if (code != TSDB_CODE_SUCCESS) { return NULL; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 80276007de..d8d1d652a9 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1796,9 +1796,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { } pRes->info.rows = count; - doFilter(pInfo->pFilterNode, pRes); - - pOperator->resultInfo.totalRows += pRes->info.rows; + pOperator->resultInfo.totalRows += count; return (pRes->info.rows == 0) ? NULL : pInfo->pRes; } @@ -1830,7 +1828,6 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi ; pInfo->readHandle = *pReadHandle; pInfo->curPos = 0; - pInfo->pFilterNode = pPhyNode->node.pConditions; pOperator->name = "TagScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN; pOperator->blocking = false; From 8494bf17becd760c487d113d71f6d1872bdb075f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 21 Jun 2022 10:52:09 +0800 Subject: [PATCH 02/81] opt:partition by tag --- source/dnode/vnode/src/meta/metaTable.c | 4 +- source/libs/executor/src/executorimpl.c | 169 ++++++++++++++++-------- source/libs/nodes/src/nodesUtilFuncs.c | 2 + 3 files changed, 122 insertions(+), 53 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index bf5d5912f9..273129c631 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -976,7 +976,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { SDecoder dc = {0}; // get super table - tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData); + if(tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData) != 0){ + return -1; + } tbDbKey.uid = pCtbEntry->ctbEntry.suid; tbDbKey.version = *(int64_t *)pData; tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 01a1dbed5b..8d30781852 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3915,24 +3915,100 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI return TSDB_CODE_SUCCESS; } -int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey) { - if (groupKey == NULL) { +static EDealRes doTranslateGroupExpr(SNode** pNode, void* pContext) { + SMetaReader* mr = (SMetaReader*)pContext; + if(nodeType(*pNode) == QUERY_NODE_COLUMN){ + SColumnNode* pSColumnNode = *(SColumnNode**)pNode; + + SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == res) { + return DEAL_RES_ERROR; + } + + res->translate = true; + + if (strcmp(pSColumnNode->colName, "tbname") == 0) { + int32_t len = strlen(mr->me.name); + res->datum.p = taosMemoryCalloc(len + VARSTR_HEADER_SIZE + 1, 1); + memcpy(varDataVal(res->datum.p), mr->me.name, len); + varDataSetLen(res->datum.p, len); + } else { + STagVal tagVal = {0}; + tagVal.cid = pSColumnNode->colId; + const char* p = metaGetTableTagVal(&mr->me, pSColumnNode->node.resType.type, &tagVal); + if (p == NULL) { + res->node.resType.type = TSDB_DATA_TYPE_NULL; + }else if (pSColumnNode->node.resType.type == TSDB_DATA_TYPE_JSON) { + int32_t len = ((const STag*)p) -> len; + res->datum.p = taosMemoryCalloc(len + 1, 1); + memcpy(res->datum.p, p, len); + } else if (IS_VAR_DATA_TYPE(pSColumnNode->node.resType.type)) { + res->datum.p = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1); + memcpy(varDataVal(res->datum.p), tagVal.pData, tagVal.nData); + varDataSetLen(res->datum.p, tagVal.nData); + } else { + nodesSetValueNodeValue(res, &(tagVal.i64)); + } + } + nodesDestroyNode(*pNode); + *pNode = (SNode*)res; + } + + return DEAL_RES_CONTINUE; +} + +int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group) { + if (group == NULL) { return TDB_CODE_SUCCESS; } +// SSDataBlock data = {0}; +// data.info.numOfCols = 3; +// data.info.rows = rowNum; +// data.pDataBlock = taosArrayInit(3, sizeof(SColumnInfoData)); +// for (int32_t i = 0; i < 2; ++i) { +// SColumnInfoData idata = {{0}}; +// idata.info.type = TSDB_DATA_TYPE_NULL; +// idata.info.bytes = 10; +// idata.info.colId = i + 1; +// +// int32_t size = idata.info.bytes * rowNum; +// idata.pData = (char *)taosMemoryCalloc(1, size); +// taosArrayPush(res->pDataBlock, &idata); +// } +// +// SArray* pBlockList = taosArrayInit(4, POINTER_BYTES); +// taosArrayPush(pBlockList, &src); +// +// SColumnInfoData* pResColData = taosArrayGet(pResult->pDataBlock, outputSlotId); +// SColumnInfoData idata = {.info = pResColData->info, .hasNull = true}; +// +// SScalarParam dest = {.columnData = &idata}; +// int32_t code = scalarCalculate(group, pBlockList, &dest); +// if (code != TSDB_CODE_SUCCESS) { +// taosArrayDestroy(pBlockList); +// return code; +// } +// +// +// numOfRows = dest.numOfRows; +// taosArrayDestroy(pBlockList); + + pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (pTableListInfo->map == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } int32_t keyLen = 0; void* keyBuf = NULL; - int32_t numOfGroupCols = taosArrayGetSize(groupKey); - for (int32_t j = 0; j < numOfGroupCols; ++j) { - SColumn* pCol = taosArrayGet(groupKey, j); - keyLen += pCol->bytes; // actual data + null_flag + + SNode* node; + FOREACH(node, group) { + SExprNode *pExpr = (SExprNode *)node; + keyLen += pExpr->resType.bytes; } - int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols; + int32_t nullFlagSize = sizeof(int8_t) * LIST_LENGTH(group); keyLen += nullFlagSize; keyBuf = taosMemoryCalloc(1, keyLen); @@ -3946,35 +4022,39 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, metaReaderInit(&mr, pHandle->meta, 0); metaGetTableEntryByUid(&mr, info->uid); - char* isNull = (char*)keyBuf; - char* pStart = (char*)keyBuf + sizeof(int8_t) * numOfGroupCols; - for (int32_t j = 0; j < numOfGroupCols; ++j) { - SColumn* pCol = taosArrayGet(groupKey, j); + SNodeList *groupNew = nodesCloneList(group); - if (strcmp(pCol->name, "tbname") == 0) { - isNull[i] = 0; - memcpy(pStart, mr.me.name, strlen(mr.me.name)); - pStart += strlen(mr.me.name); + nodesRewriteExprsPostOrder(groupNew, doTranslateGroupExpr, &mr); + char* isNull = (char*)keyBuf; + char* pStart = (char*)keyBuf + nullFlagSize; + + SNode* pNode; + int32_t index = 0; + FOREACH(pNode, groupNew){ + SNode* pNew = NULL; + int32_t code = scalarCalculateConstants(pNode, &pNew); + if (TSDB_CODE_SUCCESS == code) { + REPLACE_NODE(pNew); } else { - STagVal tagVal = {0}; - tagVal.cid = pCol->colId; - const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal); - if (p == NULL) { - isNull[j] = 1; - continue; - } - isNull[i] = 0; - if (pCol->type == TSDB_DATA_TYPE_JSON) { - // int32_t dataLen = getJsonValueLen(pkey->pData); - // memcpy(pStart, (pkey->pData), dataLen); - // pStart += dataLen; - } else if (IS_VAR_DATA_TYPE(pCol->type)) { - memcpy(pStart, tagVal.pData, tagVal.nData); - pStart += tagVal.nData; - ASSERT(tagVal.nData <= pCol->bytes); + nodesClearList(groupNew); + return code; + } + + ASSERT(nodeType(pNew) == QUERY_NODE_VALUE); + SValueNode *pValue = (SValueNode *)pNew; + + if (pValue->node.resType.type == TSDB_DATA_TYPE_NULL) { + isNull[index++] = 1; + continue; + } else { + isNull[index++] = 0; + char* data = nodesGetValueFromNode(pValue); + if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { + memcpy(pStart, data, varDataTLen(data)); + pStart += varDataTLen(data); } else { - memcpy(pStart, &(tagVal.i64), pCol->bytes); - pStart += pCol->bytes; + memcpy(pStart, data, pValue->node.resType.bytes); + pStart += pValue->node.resType.bytes; } } } @@ -3987,7 +4067,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, uint64_t tmpId = calcGroupId(keyBuf, len); taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t)); } - + nodesClearList(groupNew); metaReaderClear(&mr); } taosMemoryFree(keyBuf); @@ -4016,14 +4096,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); - code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json - taosArrayDestroy(groupKeys); - if (code) { - tsdbCleanupReadHandle(pDataReader); - pTaskInfo->code = terrno; - return NULL; - } + generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; @@ -4035,9 +4108,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SArray* dataReaders = taosArrayInit(8, POINTER_BYTES); createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond); extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); - SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); - generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json - taosArrayDestroy(groupKeys); + generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; @@ -4063,13 +4134,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo)); } - SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); - int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json - taosArrayDestroy(groupKeys); - if (code) { - tsdbCleanupReadHandle(pDataReader); - return NULL; - } + generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index a48071ef52..e2fff65f17 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1121,6 +1121,7 @@ void* nodesGetValueFromNode(SValueNode* pNode) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_JSON: return (void*)pNode->datum.p; default: break; @@ -1182,6 +1183,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_JSON: pNode->datum.p = (char*)value; break; default: From 9883d670c64c5f54eaba3643eb605cbaae4e09b5 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 21 Jun 2022 13:52:07 +0800 Subject: [PATCH 03/81] opti: patition by tag --- source/libs/executor/src/executorimpl.c | 78 +++++++++++++++++-------- source/libs/planner/src/planOptimizer.c | 14 ++++- 2 files changed, 64 insertions(+), 28 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 3c90626e82..63d9ed683d 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3916,32 +3916,44 @@ static EDealRes doTranslateGroupExpr(SNode** pNode, void* pContext) { } res->translate = true; + res->node.resType = pSColumnNode->node.resType; + + STagVal tagVal = {0}; + tagVal.cid = pSColumnNode->colId; + const char* p = metaGetTableTagVal(&mr->me, pSColumnNode->node.resType.type, &tagVal); + if (p == NULL) { + res->node.resType.type = TSDB_DATA_TYPE_NULL; + }else if (pSColumnNode->node.resType.type == TSDB_DATA_TYPE_JSON) { + int32_t len = ((const STag*)p) -> len; + res->datum.p = taosMemoryCalloc(len + 1, 1); + memcpy(res->datum.p, p, len); + } else if (IS_VAR_DATA_TYPE(pSColumnNode->node.resType.type)) { + res->datum.p = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1); + memcpy(varDataVal(res->datum.p), tagVal.pData, tagVal.nData); + varDataSetLen(res->datum.p, tagVal.nData); + } else { + nodesSetValueNodeValue(res, &(tagVal.i64)); + } + nodesDestroyNode(*pNode); + *pNode = (SNode*)res; + }else if (nodeType(*pNode) == QUERY_NODE_FUNCTION){ + SFunctionNode * pFuncNode = *(SFunctionNode**)pNode; + if(pFuncNode->funcType == FUNCTION_TYPE_TBNAME){ + SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == res) { + return DEAL_RES_ERROR; + } + + res->translate = true; + res->node.resType = pFuncNode->node.resType; - if (strcmp(pSColumnNode->colName, "tbname") == 0) { int32_t len = strlen(mr->me.name); res->datum.p = taosMemoryCalloc(len + VARSTR_HEADER_SIZE + 1, 1); memcpy(varDataVal(res->datum.p), mr->me.name, len); varDataSetLen(res->datum.p, len); - } else { - STagVal tagVal = {0}; - tagVal.cid = pSColumnNode->colId; - const char* p = metaGetTableTagVal(&mr->me, pSColumnNode->node.resType.type, &tagVal); - if (p == NULL) { - res->node.resType.type = TSDB_DATA_TYPE_NULL; - }else if (pSColumnNode->node.resType.type == TSDB_DATA_TYPE_JSON) { - int32_t len = ((const STag*)p) -> len; - res->datum.p = taosMemoryCalloc(len + 1, 1); - memcpy(res->datum.p, p, len); - } else if (IS_VAR_DATA_TYPE(pSColumnNode->node.resType.type)) { - res->datum.p = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1); - memcpy(varDataVal(res->datum.p), tagVal.pData, tagVal.nData); - varDataSetLen(res->datum.p, tagVal.nData); - } else { - nodesSetValueNodeValue(res, &(tagVal.i64)); - } + nodesDestroyNode(*pNode); + *pNode = (SNode*)res; } - nodesDestroyNode(*pNode); - *pNode = (SNode*)res; } return DEAL_RES_CONTINUE; @@ -4039,7 +4051,11 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } else { isNull[index++] = 0; char* data = nodesGetValueFromNode(pValue); - if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { + if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON){ + int32_t len = ((const STag*)data) -> len; + memcpy(pStart, data, len); + pStart += len; + } else if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { memcpy(pStart, data, varDataTLen(data)); pStart += varDataTLen(data); } else { @@ -4086,7 +4102,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + if (code) { + tsdbCleanupReadHandle(pDataReader); + pTaskInfo->code = code; + return NULL; + } SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; @@ -4098,7 +4119,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SArray* dataReaders = taosArrayInit(8, POINTER_BYTES); createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond); extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); - generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + int32_t code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + if(code){ + taosArrayDestroy(dataReaders); + return NULL; + } SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; @@ -4133,8 +4158,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo)); } - generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); - + int32_t code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); + if (code) { + tsdbCleanupReadHandle(pDataReader); + return NULL; + } SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup); return pOperator; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 5249bd913d..e63977286f 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1057,9 +1057,9 @@ static bool partTagsOptHasCol(SNodeList* pPartKeys) { } static bool partTagsIsOptimizableNode(SLogicNode* pNode) { - return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) /*|| + return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) || (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys && - NULL != ((SAggLogicNode*)pNode)->pAggFuncs)*/) && + NULL != ((SAggLogicNode*)pNode)->pAggFuncs)) && 1 == LIST_LENGTH(pNode->pChildren) && QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0))); } @@ -1096,7 +1096,15 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub nodesDestroyNode((SNode*)pNode); } } else { - TSWAP(((SAggLogicNode*)pNode)->pGroupKeys, pScan->pPartTags); + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, ((SAggLogicNode*)pNode)->pGroupKeys) { + code = nodesListMakeStrictAppend( + &pScan->pPartTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0))); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); } return code; } From 41593ae07bbb74e91fe1d092c8f440817c6a4519 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 22 Jun 2022 17:34:16 +0800 Subject: [PATCH 04/81] refactor: nodesClone interface refactor --- source/libs/nodes/src/nodesCloneFuncs.c | 329 ++++++++++++------------ 1 file changed, 163 insertions(+), 166 deletions(-) diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 0bde0d0581..34695004df 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -41,8 +41,7 @@ } \ (pDst)->fldname = strdup((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -53,8 +52,7 @@ } \ (pDst)->fldname = nodesCloneNode((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -65,8 +63,7 @@ } \ (pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -77,8 +74,7 @@ } \ (pDst)->fldname = nodesCloneList((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -89,27 +85,25 @@ } \ (pDst)->fldname = cloneFunc((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) -#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ - do { \ - if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ - } \ +#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ + do { \ + if (TSDB_CODE_SUCCESS != copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ + return TSDB_CODE_OUT_OF_MEMORY; \ + } \ } while (0) -static SNode* exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { +static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { +static int32_t columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(tableId); COPY_SCALAR_FIELD(tableType); @@ -122,10 +116,10 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { COPY_CHAR_ARRAY_FIELD(colName); COPY_SCALAR_FIELD(dataBlockId); COPY_SCALAR_FIELD(slotId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { +static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_POINT_FIELD(literal); COPY_SCALAR_FIELD(isDuration); @@ -135,7 +129,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { COPY_SCALAR_FIELD(typeData); COPY_SCALAR_FIELD(unit); if (!pSrc->translate) { - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } switch (pSrc->node.resType.type) { case TSDB_DATA_TYPE_BOOL: @@ -164,8 +158,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = varDataTLen(pSrc->datum.p) + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - nodesDestroyNode((SNode*)pDst); - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; @@ -177,42 +170,42 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { default: break; } - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) { +static int32_t operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(opType); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) { +static int32_t logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(condType); CLONE_NODE_LIST_FIELD(pParameterList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) { +static int32_t functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_ARRAY_FIELD(functionName); COPY_SCALAR_FIELD(funcId); COPY_SCALAR_FIELD(funcType); CLONE_NODE_LIST_FIELD(pParameterList); COPY_SCALAR_FIELD(udfBufSize); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { +static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_ARRAY_FIELD(dbName); COPY_CHAR_ARRAY_FIELD(tableName); COPY_CHAR_ARRAY_FIELD(tableAlias); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(singleTable); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } static STableMeta* tableMetaClone(const STableMeta* pSrc) { @@ -235,101 +228,101 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) { return pDst; } -static SNode* realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) { +static int32_t realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); CLONE_OBJECT_FIELD(pMeta, tableMetaClone); CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone); COPY_CHAR_ARRAY_FIELD(qualDbName); COPY_SCALAR_FIELD(ratio); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) { +static int32_t tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); CLONE_NODE_FIELD(pSubquery); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) { +static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); COPY_SCALAR_FIELD(joinType); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); CLONE_NODE_FIELD(pOnCond); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) { +static int32_t targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) { COPY_SCALAR_FIELD(dataBlockId); COPY_SCALAR_FIELD(slotId); CLONE_NODE_FIELD(pExpr); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) { +static int32_t groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) { COPY_SCALAR_FIELD(groupingSetType); CLONE_NODE_LIST_FIELD(pParameterList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) { +static int32_t orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) { CLONE_NODE_FIELD(pExpr); COPY_SCALAR_FIELD(order); COPY_SCALAR_FIELD(nullOrder); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) { +static int32_t limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) { COPY_SCALAR_FIELD(limit); COPY_SCALAR_FIELD(offset); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) { +static int32_t stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) { CLONE_NODE_FIELD(pCol); CLONE_NODE_FIELD(pExpr); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { +static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { CLONE_NODE_FIELD_EX(pCol, SColumnNode*); CLONE_NODE_FIELD_EX(pGap, SValueNode*); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) { +static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) { CLONE_NODE_FIELD(pCol); CLONE_NODE_FIELD(pInterval); CLONE_NODE_FIELD(pOffset); CLONE_NODE_FIELD(pSliding); CLONE_NODE_FIELD(pFill); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) { +static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) { COPY_OBJECT_FIELD(dataType, sizeof(SDataType)); CLONE_NODE_LIST_FIELD(pNodeList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { +static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { COPY_SCALAR_FIELD(mode); CLONE_NODE_FIELD(pValues); CLONE_NODE_FIELD(pWStartTs); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { +static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { CLONE_NODE_LIST_FIELD(pTargets); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); COPY_SCALAR_FIELD(optimizedFlag); COPY_SCALAR_FIELD(precision); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { +static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pScanCols); CLONE_NODE_LIST_FIELD(pScanPseudoCols); @@ -356,25 +349,25 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(tsColId); COPY_SCALAR_FIELD(filesFactor); CLONE_NODE_LIST_FIELD(pPartTags); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { +static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(joinType); CLONE_NODE_FIELD(pOnConditions); COPY_SCALAR_FIELD(isSingleTableJoin); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { +static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pGroupKeys); CLONE_NODE_LIST_FIELD(pAggFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) { +static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pProjections); COPY_CHAR_ARRAY_FIELD(stmtName); @@ -382,10 +375,10 @@ static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* COPY_SCALAR_FIELD(offset); COPY_SCALAR_FIELD(slimit); COPY_SCALAR_FIELD(soffset); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) { +static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(modifyType); COPY_SCALAR_FIELD(msgType); @@ -394,25 +387,25 @@ static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModif COPY_SCALAR_FIELD(tableType); COPY_CHAR_ARRAY_FIELD(tableFName); COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) { +static int32_t logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(srcGroupId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) { +static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pMergeKeys); CLONE_NODE_LIST_FIELD(pInputs); COPY_SCALAR_FIELD(numOfChannels); COPY_SCALAR_FIELD(srcGroupId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) { +static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(winType); CLONE_NODE_LIST_FIELD(pFuncs); @@ -429,37 +422,37 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(filesFactor); COPY_SCALAR_FIELD(windowAlgo); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { +static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(mode); CLONE_NODE_FIELD(pWStartTs); CLONE_NODE_FIELD(pValues); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { +static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pSortKeys); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) { +static int32_t logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pPartitionKeys); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) { +static int32_t logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) { +static int32_t logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pFuncs); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); @@ -467,26 +460,26 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL COPY_SCALAR_FIELD(fillMode); CLONE_NODE_FIELD(pFillValues); CLONE_NODE_FIELD(pTimeSeries); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { +static int32_t logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { COPY_OBJECT_FIELD(id, sizeof(SSubplanId)); CLONE_NODE_FIELD_EX(pNode, SLogicNode*); COPY_SCALAR_FIELD(subplanType); COPY_SCALAR_FIELD(level); COPY_SCALAR_FIELD(splitFlag); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { +static int32_t physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { +static int32_t physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pScanCols); CLONE_NODE_LIST_FIELD(pScanPseudoCols); @@ -494,14 +487,14 @@ static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { COPY_SCALAR_FIELD(suid); COPY_SCALAR_FIELD(tableType); COPY_OBJECT_FIELD(tableName, sizeof(SName)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) { +static int32_t physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) { return physiScanCopy(pSrc, pDst); } -static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) { +static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(scan, physiScanCopy); COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2); COPY_OBJECT_FIELD(scanRange, sizeof(STimeWindow)); @@ -518,18 +511,18 @@ static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhys COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(tsColId); COPY_SCALAR_FIELD(filesFactor); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) { +static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(scan, physiScanCopy); COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet)); COPY_SCALAR_FIELD(showRewrite); COPY_SCALAR_FIELD(accountId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) { +static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pExprs); CLONE_NODE_LIST_FIELD(pFuncs); @@ -538,59 +531,59 @@ static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pD COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(filesFactor); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) { +static int32_t physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(window, physiWindowCopy); COPY_SCALAR_FIELD(interval); COPY_SCALAR_FIELD(offset); COPY_SCALAR_FIELD(sliding); COPY_SCALAR_FIELD(intervalUnit); COPY_SCALAR_FIELD(slidingUnit); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) { +static int32_t physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(window, physiWindowCopy); COPY_SCALAR_FIELD(gap); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) { +static int32_t physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pExprs); CLONE_NODE_LIST_FIELD(pPartitionKeys); CLONE_NODE_LIST_FIELD(pTargets); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { +static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { COPY_SCALAR_FIELD(dataBlockId); CLONE_NODE_LIST_FIELD(pSlots); COPY_SCALAR_FIELD(totalRowSize); COPY_SCALAR_FIELD(outputRowSize); COPY_SCALAR_FIELD(precision); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) { +static int32_t slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) { COPY_SCALAR_FIELD(slotId); COPY_OBJECT_FIELD(dataType, sizeof(SDataType)); COPY_SCALAR_FIELD(reserve); COPY_SCALAR_FIELD(output); COPY_SCALAR_FIELD(tag); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) { +static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) { COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr)); COPY_SCALAR_FIELD(taskId); COPY_SCALAR_FIELD(schedId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { +static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_SCALAR_FIELD(isDistinct); CLONE_NODE_LIST_FIELD(pProjectionList); CLONE_NODE_FIELD(pFromTable); @@ -608,116 +601,124 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_SCALAR_FIELD(isTimeOrderQuery); COPY_SCALAR_FIELD(hasAggFuncs); COPY_SCALAR_FIELD(hasRepeatScanFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } SNode* nodesCloneNode(const SNode* pNode) { if (NULL == pNode) { return NULL; } + SNode* pDst = nodesMakeNode(nodeType(pNode)); if (NULL == pDst) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + + int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: - return columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); + code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); case QUERY_NODE_VALUE: - return valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); + code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); case QUERY_NODE_OPERATOR: - return operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); + code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); case QUERY_NODE_LOGIC_CONDITION: - return logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); + code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); case QUERY_NODE_FUNCTION: - return functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); + code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); case QUERY_NODE_REAL_TABLE: - return realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); + code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); case QUERY_NODE_TEMP_TABLE: - return tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); + code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); case QUERY_NODE_JOIN_TABLE: - return joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); + code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); case QUERY_NODE_GROUPING_SET: - return groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); + code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); case QUERY_NODE_ORDER_BY_EXPR: - return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); + code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); case QUERY_NODE_LIMIT: - return limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); + code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); case QUERY_NODE_STATE_WINDOW: - return stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); + code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); case QUERY_NODE_SESSION_WINDOW: - return sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); + code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); case QUERY_NODE_INTERVAL_WINDOW: - return intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); + code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); case QUERY_NODE_NODE_LIST: - return nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); + code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); case QUERY_NODE_FILL: - return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); + code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); case QUERY_NODE_TARGET: - return targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); + code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); case QUERY_NODE_DATABLOCK_DESC: - return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); + code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); case QUERY_NODE_SLOT_DESC: - return slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); + code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); case QUERY_NODE_DOWNSTREAM_SOURCE: - return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); + code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); case QUERY_NODE_LEFT_VALUE: - return pDst; + code = TSDB_CODE_SUCCESS; case QUERY_NODE_SELECT_STMT: - return selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); + code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); case QUERY_NODE_LOGIC_PLAN_SCAN: - return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); + code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_JOIN: - return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); + code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_AGG: - return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); + code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_PROJECT: - return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); + code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY: - return logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); + code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_EXCHANGE: - return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); + code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_MERGE: - return logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); + code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_WINDOW: - return logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); + code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_FILL: - return logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); + code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_SORT: - return logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); + code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_PARTITION: - return logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); + code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: - return logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); + code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC: - return logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); + code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); case QUERY_NODE_LOGIC_SUBPLAN: - return logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); + code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: - return physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); + code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - return physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); + code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: - return physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); + code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: - return physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); + code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: - return physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); + code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - return physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); + code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); default: break; } - nodesDestroyNode(pDst); - nodesError("nodesCloneNode unknown node = %s", nodesNodeName(nodeType(pNode))); - return NULL; + + if (TSDB_CODE_SUCCESS != code) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + nodesDestroyNode(pDst); + nodesError("nodesCloneNode failed node = %s", nodesNodeName(nodeType(pNode))); + return NULL; + } + return pDst; } SNodeList* nodesCloneList(const SNodeList* pList) { @@ -725,19 +726,15 @@ SNodeList* nodesCloneList(const SNodeList* pList) { return NULL; } - SNodeList* pDst = nodesMakeList(); - if (NULL == pDst) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - SNode* pNode; + SNodeList* pDst = NULL; + SNode* pNode; FOREACH(pNode, pList) { - SNode* pNewNode = nodesCloneNode(pNode); - if (NULL == pNewNode) { + int32_t code = nodesListMakeStrictAppend(&pDst, nodesCloneNode(pNode)); + if (TSDB_CODE_SUCCESS != code) { + terrno = TSDB_CODE_OUT_OF_MEMORY; nodesDestroyList(pDst); return NULL; } - nodesListAppend(pDst, pNewNode); } return pDst; } From 607a73baf6de5cb1f52af67cd9f98ae3b7918463 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Wed, 30 Nov 2022 22:39:29 +0800 Subject: [PATCH 05/81] update sqlset.py --- tests/pytest/util/sqlset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/util/sqlset.py b/tests/pytest/util/sqlset.py index 939f53154a..1897b3cf23 100644 --- a/tests/pytest/util/sqlset.py +++ b/tests/pytest/util/sqlset.py @@ -15,7 +15,7 @@ from util.sql import tdSql class TDSetSql: def init(self, conn, logSql): - tdSql.init(conn.cursor(), logSql) + self.stbname = 'stb' def set_create_normaltable_sql(self, ntbname='ntb', From 00fb421b02dcb32d793273251ca425619166a432 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Wed, 30 Nov 2022 22:42:53 +0800 Subject: [PATCH 06/81] update first.py --- tests/system-test/2-query/first.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index e9a8cc950b..71d44bac8c 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -125,10 +125,10 @@ class TDTestCase: tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) #!bug TD-16561 - # for i in [f'{stbname}', f'{dbname}.{stbname}']: - # tdSql.query(f"select first(*) from {i}") - # tdSql.checkRows(1) - # tdSql.checkData(0, 1, None) + for i in [f'{stbname}', f'{dbname}.{stbname}']: + tdSql.query(f"select first(*) from {i}") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) tdSql.query('show tables') vgroup_list = [] for i in range(len(tdSql.queryResult)): @@ -170,8 +170,8 @@ class TDTestCase: elif 'nchar' in v: tdSql.checkData(0, 0, f'{self.nchar_str}1') #!bug TD-16569 - # tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)") - # tdSql.checkRows(0) + tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + tdSql.checkRows(0) tdSql.execute(f'drop database {dbname}') From 4e7aff05868bfa7d7db14545943827c984629d78 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 1 Dec 2022 03:10:52 +0800 Subject: [PATCH 07/81] update test case --- tests/system-test/2-query/first.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 71d44bac8c..830b19d8ac 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -60,10 +60,10 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 1, None) #!bug TD-16561 - # for i in ['stb','db.stb']: - # tdSql.query(f"select first(*) from {i}") - # tdSql.checkRows(1) - # tdSql.checkData(0, 1, None) + for i in ['stb','db.stb']: + tdSql.query(f"select first(*) from {i}") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) for i in column_list: for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: tdSql.query(f"select first({i}) from {j}") From f967cff0fafbad6a177e1e3da31b23ec6f084fd8 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 22 Jun 2022 18:14:26 +0800 Subject: [PATCH 08/81] feat: add table group info if need sort table by group --- include/common/tcommon.h | 2 + source/libs/executor/src/executorimpl.c | 99 +++++++++++++++---------- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index a05287761e..a5217d6b2b 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -47,8 +47,10 @@ typedef enum EStreamType { } EStreamType; typedef struct { + SArray *pGroupList; SArray* pTableList; SHashObj* map; // speedup acquire the tableQueryInfo by table uid + bool needSortTableByGroupId; } STableListInfo; typedef struct SColumnDataAgg { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 63d9ed683d..2fedac4112 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3964,39 +3964,6 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, return TDB_CODE_SUCCESS; } -// SSDataBlock data = {0}; -// data.info.numOfCols = 3; -// data.info.rows = rowNum; -// data.pDataBlock = taosArrayInit(3, sizeof(SColumnInfoData)); -// for (int32_t i = 0; i < 2; ++i) { -// SColumnInfoData idata = {{0}}; -// idata.info.type = TSDB_DATA_TYPE_NULL; -// idata.info.bytes = 10; -// idata.info.colId = i + 1; -// -// int32_t size = idata.info.bytes * rowNum; -// idata.pData = (char *)taosMemoryCalloc(1, size); -// taosArrayPush(res->pDataBlock, &idata); -// } -// -// SArray* pBlockList = taosArrayInit(4, POINTER_BYTES); -// taosArrayPush(pBlockList, &src); -// -// SColumnInfoData* pResColData = taosArrayGet(pResult->pDataBlock, outputSlotId); -// SColumnInfoData idata = {.info = pResColData->info, .hasNull = true}; -// -// SScalarParam dest = {.columnData = &idata}; -// int32_t code = scalarCalculate(group, pBlockList, &dest); -// if (code != TSDB_CODE_SUCCESS) { -// taosArrayDestroy(pBlockList); -// return code; -// } -// -// -// numOfRows = dest.numOfRows; -// taosArrayDestroy(pBlockList); - - pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (pTableListInfo->map == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -4018,6 +3985,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, return TSDB_CODE_OUT_OF_MEMORY; } + int32_t groupNum = 0; for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); SMetaReader mr = {0}; @@ -4038,6 +4006,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, if (TSDB_CODE_SUCCESS == code) { REPLACE_NODE(pNew); } else { + taosMemoryFree(keyBuf); nodesClearList(groupNew); return code; } @@ -4066,17 +4035,67 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } int32_t len = (int32_t)(pStart - (char*)keyBuf); - uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len); - if (groupId) { - taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t)); - } else { - uint64_t tmpId = calcGroupId(keyBuf, len); - taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t)); - } + uint64_t groupId = calcGroupId(keyBuf, len); + taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &groupId, sizeof(uint64_t)); + groupNum++; + nodesClearList(groupNew); metaReaderClear(&mr); } taosMemoryFree(keyBuf); + + if(pTableListInfo->needSortTableByGroupId){ + pTableListInfo->pGroupList = taosArrayInit(groupNum, POINTER_BYTES); + SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); + if(pTableListInfo->pGroupList == NULL || sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; + for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { + STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); + uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); + + int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ); + if (index == -1){ + void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); + SArray *tGroup = taosArrayInit(8, sizeof(uint64_t)); + if(tGroup == NULL) { + taosArrayDestroy(sortSupport); + return TSDB_CODE_OUT_OF_MEMORY; + } + if(p == NULL){ + if(taosArrayPush(sortSupport, groupId) != NULL){ + qError("taos push support array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + if(taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL){ + qError("taos push group array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + }else{ + int32_t pos = TARRAY_ELEM_IDX(sortSupport, p); + if(taosArrayInsert(sortSupport, pos, groupId) == NULL){ + qError("taos insert support array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + if(taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL){ + qError("taos insert group array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + } + }else{ + SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index); + if(taosArrayPush(tGroup, &info->uid) == NULL){ + qError("taos push uid array error"); + return TSDB_CODE_QRY_APP_ERROR; + } + } + + } + taosArrayDestroy(sortSupport); + } + return TDB_CODE_SUCCESS; } From 33452da7bdadce1dd283722b27324bedc6db906f Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 22 Jun 2022 19:45:41 +0800 Subject: [PATCH 09/81] feat: alter local command --- include/util/tconfig.h | 3 ++- source/libs/command/src/command.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/util/tconfig.h b/include/util/tconfig.h index fd6360aaf6..102656da2b 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -33,7 +33,8 @@ typedef enum { CFG_STYPE_ENV_CMD, CFG_STYPE_APOLLO_URL, CFG_STYPE_ARG_LIST, - CFG_STYPE_TAOS_OPTIONS + CFG_STYPE_TAOS_OPTIONS, + CFG_STYPE_ALTER_CMD, } ECfgSrcType; typedef enum { diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 6b0a84a37e..8869e679ae 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -550,7 +550,13 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR return execShowCreateTable(pStmt, pRsp); } -static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { return TSDB_CODE_FAILED; } +static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { + if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) { + return terrno; + } + + return TSDB_CODE_SUCCESS; +} static SSDataBlock* buildLocalVariablesResultDataBlock() { SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); From e347528cc6fb7bd6226a94af773324d4ee91270d Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 23 Jun 2022 15:55:18 +0800 Subject: [PATCH 10/81] test: add test case for tmq --- tests/system-test/7-tmq/tmq3mnodeSwitch.py | 273 +++++++++++++++++++++ tests/system-test/7-tmq/tmqCommon.py | 40 +++ tests/system-test/7-tmq/tmqUdf.py | 2 +- tests/test/c/tmqSim.c | 21 +- 4 files changed, 330 insertions(+), 6 deletions(-) create mode 100644 tests/system-test/7-tmq/tmq3mnodeSwitch.py diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py new file mode 100644 index 0000000000..8aab6db1a4 --- /dev/null +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -0,0 +1,273 @@ + +from ntpath import join +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +from util.cluster import * +from test import tdDnodes + +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.dnodes = 5 + self.mnodes = 3 + self.idIndex = 0 + self.roleIndex = 2 + self.mnodeStatusIndex = 3 + self.mnodeEpIndex = 1 + self.dnodeStatusIndex = 4 + self.mnodeCheckCnt = 10 + self.host = socket.gethostname() + self.startPort = 6030 + self.portStep = 100 + self.dnodeOfLeader = 0 + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkDnodesStatusAndCreateMnode(self,dnodeNumbers): + count=0 + while count < dnodeNumbers: + tdSql.query("show dnodes") + # tdLog.debug(tdSql.queryResult) + dCnt = 0 + for i in range(dnodeNumbers): + if tdSql.queryResult[i][self.dnodeStatusIndex] != "ready": + break + else: + dCnt += 1 + if dCnt == dnodeNumbers: + break + time.sleep(1) + tdLog.debug("............... waiting for all dnodes ready!") + + tdLog.info("==============create two new mnodes ========") + tdSql.execute("create mnode on dnode 2") + tdSql.execute("create mnode on dnode 3") + self.check3mnode() + return + + def check3mnode(self): + count=0 + while count < self.mnodeCheckCnt: + time.sleep(1) + tdSql.query("show mnodes;") + if tdSql.checkRows(self.mnodes) : + tdLog.debug("mnode is three nodes") + else: + tdLog.exit("mnode number is correct") + + roleOfMnode0 = tdSql.queryResult[0][self.roleIndex] + roleOfMnode1 = tdSql.queryResult[1][self.roleIndex] + roleOfMnode2 = tdSql.queryResult[2][self.roleIndex] + + if roleOfMnode0=='leader' and roleOfMnode1=='follower' and roleOfMnode2 == 'follower' : + self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex] + break + elif roleOfMnode0=='follower' and roleOfMnode1=='leader' and roleOfMnode2 == 'follower' : + self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex] + break + elif roleOfMnode0=='follower' and roleOfMnode1=='follower' and roleOfMnode2 == 'leader' : + self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] + break + else: + count+=1 + else: + tdLog.exit("three mnodes is not ready in 10s ") + + tdSql.query("show mnodes;") + tdSql.checkRows(self.mnodes) + tdSql.checkData(0,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort)) + tdSql.checkData(0,self.mnodeStatusIndex,'ready') + tdSql.checkData(1,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort+self.portStep)) + tdSql.checkData(1,self.mnodeStatusIndex,'ready') + tdSql.checkData(2,self.mnodeEpIndex,'%s:%d'%(self.host,self.startPort+self.portStep*2)) + tdSql.checkData(2,self.mnodeStatusIndex,'ready') + + def check3mnode1off(self): + count=0 + while count < self.mnodeCheckCnt: + time.sleep(1) + tdSql.query("show mnodes") + tdLog.debug(tdSql.queryResult) + # if tdSql.checkRows(self.mnodes) : + # tdLog.debug("mnode is three nodes") + # else: + # tdLog.exit("mnode number is correct") + + roleOfMnode0 = tdSql.queryResult[0][self.roleIndex] + roleOfMnode1 = tdSql.queryResult[1][self.roleIndex] + roleOfMnode2 = tdSql.queryResult[2][self.roleIndex] + + if roleOfMnode0=='offline' : + if roleOfMnode1=='leader' and roleOfMnode2 == 'follower' : + self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex] + break + elif roleOfMnode1=='follower' and roleOfMnode2 == 'leader' : + self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] + break + elif roleOfMnode1=='offline' : + if roleOfMnode0=='leader' and roleOfMnode2 == 'follower' : + self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex] + break + elif roleOfMnode0=='follower' and roleOfMnode2 == 'leader' : + self.dnodeOfLeader = tdSql.queryResult[2][self.idIndex] + break + elif roleOfMnode2=='offline' : + if roleOfMnode0=='leader' and roleOfMnode1 == 'follower' : + self.dnodeOfLeader = tdSql.queryResult[0][self.idIndex] + break + elif roleOfMnode0=='follower' and roleOfMnode1 == 'leader' : + self.dnodeOfLeader = tdSql.queryResult[1][self.idIndex] + break + + count+=1 + else: + tdLog.exit("three mnodes is not ready in 10s ") + + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) + else: + break + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}, {'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 100000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("async insert data") + pThread = tmqCom.asyncInsertData(paraDict) + + tdLog.info("create topics from stb with filter") + queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the notify info of start consume") + tmqCom.getStartConsumeNotifyFromTmqsim() + + tdLog.info("start switch mnode ................") + tdDnodes = cluster.dnodes + + tdLog.info("1. stop dnode 0") + tdDnodes[0].stoptaosd() + time.sleep(10) + self.check3mnode1off() + + tdLog.info("2. start dnode 0") + tdDnodes[0].starttaosd() + self.check3mnode() + + tdLog.info("3. stop dnode 1") + tdDnodes[1].stoptaosd() + time.sleep(10) + self.check3mnode1off() + + tdLog.info("switch end and wait insert data end ................") + pThread.join() + + tdLog.info("check the consume result") + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdLog.printNoPrefix("======== Notes: must add '-N 5' for run the script ========") + self.checkDnodesStatusAndCreateMnode(self.dnodes) + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 9b23056546..d17e36fc97 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -204,6 +204,35 @@ class TMQCom: tdLog.debug("insert data ............ [OK]") return + def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + t = time.time() + startTs = int(round(t * 1000)) + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + for i in range(ctbNum): + sql += " %s%d values "%(ctbPrefix,i) + for j in range(rowsPerTbl): + if (j % 2 == 0): + sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, j, j) + else: + sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, -j, j) + if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + if j < rowsPerTbl - 1: + sql = "insert into %s%d values " %(ctbPrefix,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + def insert_data_interlaceByMultiTbl(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs=0): tdLog.debug("start to insert data ............") tsql.execute("use %s" %dbName) @@ -291,6 +320,17 @@ class TMQCom: pThread.start() return pThread + def threadFunctionForInsert(self, **paraDict): + # create new connector for new tdSql instance in my thread + newTdSql = tdCom.newTdSql() + self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + return + + def asyncInsertData(self, paraDict): + pThread = threading.Thread(target=self.threadFunctionForInsert, kwargs=paraDict) + pThread.start() + return pThread + def close(self): self.cursor.close() diff --git a/tests/system-test/7-tmq/tmqUdf.py b/tests/system-test/7-tmq/tmqUdf.py index f1c451de85..d241a97e0c 100644 --- a/tests/system-test/7-tmq/tmqUdf.py +++ b/tests/system-test/7-tmq/tmqUdf.py @@ -113,7 +113,7 @@ class TDTestCase: tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) tdLog.info("create topics from stb with filter") - queryString = "select ts, c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) + queryString = "select ts,c1,udf1(c1),c2,udf1(c2) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index c28c676a87..d369c68deb 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -449,6 +449,15 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex) int32_t precision = taos_result_precision(msg); const char* tbName = tmq_get_table_name(msg); + #if 0 + // get schema + //============================== stub =================================================// + for (int32_t i = 0; i < numOfFields; i++) { + taosFprintfFile(g_fp, "%02d: name: %s, type: %d, len: %d\n", i, fields[i].name, fields[i].type, fields[i].bytes); + } + //============================== stub =================================================// + #endif + dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); taos_print_row(buf, row, fields, numOfFields); @@ -651,12 +660,13 @@ void* consumeThreadFunc(void* param) { pInfo->taos = taos_connect(NULL, "root", "taosdata", NULL, 0); if (pInfo->taos == NULL) { taosFprintfFile(g_fp, "taos_connect() fail, can not notify and save consume result to main scripte\n"); - exit(-1); + return NULL; } build_consumer(pInfo); build_topic_list(pInfo); if ((NULL == pInfo->tmq) || (NULL == pInfo->topicList)) { + taosFprintfFile(g_fp, "create consumer fail! tmq is null or topicList is null\n"); assert(0); return NULL; } @@ -664,7 +674,9 @@ void* consumeThreadFunc(void* param) { int32_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList); if (err != 0) { pError("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err)); - exit(-1); + taosFprintfFile(g_fp, "tmq_subscribe()! reason: %s\n", tmq_err2str(err)); + assert(0); + return NULL; } tmq_list_destroy(pInfo->topicList); @@ -683,14 +695,13 @@ void* consumeThreadFunc(void* param) { err = tmq_unsubscribe(pInfo->tmq); if (err != 0) { pError("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err)); - /*pInfo->consumeMsgCnt = -1;*/ - /*return NULL;*/ + taosFprintfFile(g_fp, "tmq_unsubscribe()! reason: %s\n", tmq_err2str(err)); } err = tmq_consumer_close(pInfo->tmq); if (err != 0) { pError("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err)); - /*exit(-1);*/ + taosFprintfFile(g_fp, "tmq_consumer_close()! reason: %s\n", tmq_err2str(err)); } pInfo->tmq = NULL; From 2f81fd608dcc977f2250c2fc2f6b8e6a33c47046 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 23 Jun 2022 16:01:42 +0800 Subject: [PATCH 11/81] test: add test case into CI --- tests/system-test/fulltest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 19a67e924c..074756add6 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -134,3 +134,4 @@ python3 ./test.py -f 7-tmq/schema.py python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py python3 ./test.py -f 7-tmq/tmqUdf.py +python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py From 1c37c77fd48f10abf061fa586ebfd21b49dbb912 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 23 Jun 2022 17:03:33 +0800 Subject: [PATCH 12/81] test: add test case into CI --- tests/system-test/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 074756add6..fe4c162054 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -134,4 +134,4 @@ python3 ./test.py -f 7-tmq/schema.py python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py python3 ./test.py -f 7-tmq/tmqUdf.py -python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py +python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 From 4639a04cec91be27ebb9480ad6f251c2ef7af49f Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 23 Jun 2022 17:11:46 +0800 Subject: [PATCH 13/81] update test case --- tests/system-test/2-query/To_unixtimestamp.py | 30 +++ tests/system-test/2-query/timezone.py | 206 ++++++++---------- 2 files changed, 117 insertions(+), 119 deletions(-) diff --git a/tests/system-test/2-query/To_unixtimestamp.py b/tests/system-test/2-query/To_unixtimestamp.py index 43315ff0d8..8dc995b178 100644 --- a/tests/system-test/2-query/To_unixtimestamp.py +++ b/tests/system-test/2-query/To_unixtimestamp.py @@ -12,7 +12,37 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) + # name of normal table + self.ntbname = 'ntb' + # name of stable + self.stbname = 'stb' + # structure of column + self.column_dict = { + 'ts':'timestamp', + 'c1':'int', + 'c2':'float', + 'c3':'binary(20)', + 'c4':'nchar(20)' + } + # structure of tag + self.tag_dict = { + 't0':'int' + } + # number of child tables + self.tbnum = 2 + # values of tag,the number of values should equal to tbnum + self.tag_values = [ + f'10', + f'100' + ] + # values of rows, structure should be same as column + self.values_list = [ + f'now,10,99.99,"2020-1-1 00:00:00"', + f'today(),100,11.111,22.222222' + ] + self.error_param = [1,'now()'] + def run(self): # sourcery skip: extract-duplicate-method tdSql.prepare() tdLog.printNoPrefix("==========step1:create tables==========") diff --git a/tests/system-test/2-query/timezone.py b/tests/system-test/2-query/timezone.py index 20ee58feac..ce2cdc062e 100644 --- a/tests/system-test/2-query/timezone.py +++ b/tests/system-test/2-query/timezone.py @@ -2,7 +2,7 @@ from util.log import * from util.sql import * from util.cases import * - +from util.sqlset import * import platform import os if platform.system().lower() == 'windows': @@ -14,10 +14,39 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + self.arithmetic_operators = ['+','-','*','/'] + self.arithmetic_values = [0,1,100,15.5] + # name of normal table + self.ntbname = 'ntb' + # name of stable + self.stbname = 'stb' + # structure of column + self.column_dict = { + 'ts':'timestamp', + 'c1':'int', + 'c2':'float', + 'c3':'double' + } + # structure of tag + self.tag_dict = { + 't0':'int' + } + # number of child tables + self.tbnum = 2 + # values of tag,the number of values should equal to tbnum + self.tag_values = [ + f'10', + f'100' + ] + # values of rows, structure should be same as column + self.values_list = [ + f'now,10,99.99,11.111111', + f'today(),100,11.111,22.222222' - def run(self): # sourcery skip: extract-duplicate-method - tdSql.prepare() - # get system timezone + ] + self.error_param = [1,'now()'] + def get_system_timezone(self): if platform.system().lower() == 'windows': time_zone_1 = tzlocal.get_localzone_name() time_zone_2 = time.strftime('(UTC, %z)') @@ -32,122 +61,61 @@ class TDTestCase: time_zone_2 = os.popen('date "+(%Z, %z)"').read().strip() time_zone = time_zone_1 + " " + time_zone_2 print("expected time zone: " + time_zone) - - tdLog.printNoPrefix("==========step1:create tables==========") - tdSql.execute( - '''create table if not exists ntb - (ts timestamp, c1 int, c2 float,c3 double) - ''' - ) - tdSql.execute( - '''create table if not exists stb - (ts timestamp, c1 int, c2 float,c3 double) tags(t0 int) - ''' - ) - tdSql.execute( - '''create table if not exists stb_1 using stb tags(100) - ''' - ) - - tdLog.printNoPrefix("==========step2:insert data==========") - tdSql.execute( - "insert into ntb values(now,10,99.99,11.111111)(today(),100,11.111,22.222222)") - tdSql.execute( - "insert into stb_1 values(now,111,99.99,11.111111)(today(),1,11.111,22.222222)") - - tdLog.printNoPrefix("==========step3:query data==========") + return time_zone + + def tb_type_check(self,tb_type): + if tb_type in ['normal_table','child_table']: + tdSql.checkRows(len(self.values_list)) + elif tb_type == 'stable': + tdSql.checkRows(len(self.values_list*self.tbnum)) + def data_check(self,timezone,tbname,tb_type): + tdSql.query(f"select timezone() from {tbname}") + self.tb_type_check(tb_type) + tdSql.checkData(0,0,timezone) + for symbol in self.arithmetic_operators: + tdSql.query(f"select timezone(){symbol}null from {tbname}") + self.tb_type_check(tb_type) + tdSql.checkData(0,0,None) + for i in self.arithmetic_values: + for symbol in self.arithmetic_operators: + tdSql.query(f"select timezone(){symbol}{i} from {tbname}") + self.tb_type_check(tb_type) + if symbol == '+': + tdSql.checkData(0,0,i) + elif symbol == '-': + tdSql.checkData(0,0,-i) + elif symbol in ['*','/','%']: + if i == 0 and symbol == '/': + tdSql.checkData(0,0,None) + else: + tdSql.checkData(0,0,0) + for param in self.error_param: + tdSql.error(f'select timezone({param}) from {tbname}') + tdSql.query(f"select * from {tbname} where timezone()='{timezone}'") + self.tb_type_check(tb_type) + def timezone_check_ntb(self,timezone): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + for value in self.values_list: + tdSql.execute( + f'insert into {self.ntbname} values({value})') + self.data_check(timezone,self.ntbname,'normal_table') + tdSql.execute('drop database db') + def timezone_check_stb(self,timezone): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f'create table if not exists {self.stbname}_{i} using {self.stbname} tags({self.tag_values[i]})') + for j in self.values_list: + tdSql.execute(f'insert into {self.stbname}_{i} values({j})') + self.data_check(timezone,self.stbname,'stable') + for i in range(self.tbnum): + self.data_check(timezone,f'{self.stbname}_{i}','child_table') + def run(self): # sourcery skip: extract-duplicate-method + timezone = self.get_system_timezone() + self.timezone_check_ntb(timezone) + self.timezone_check_stb(timezone) - tdSql.query("select timezone() from ntb") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - tdSql.query("select timezone() from db.ntb") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - tdSql.query("select timezone() from stb") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - tdSql.query("select timezone() from db.stb") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - tdSql.query("select timezone() from stb_1") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - tdSql.query("select timezone() from db.stb_1 ") - tdSql.checkRows(2) - tdSql.checkData(0, 0, time_zone) - - tdSql.error("select timezone(1) from stb") - tdSql.error("select timezone(1) from db.stb") - tdSql.error("select timezone(1) from ntb") - tdSql.error("select timezone(1) from db.ntb") - tdSql.error("select timezone(1) from stb_1") - tdSql.error("select timezone(1) from db.stb_1") - tdSql.error("select timezone(now()) from stb") - tdSql.error("select timezone(now()) from db.stb") - - tdSql.query(f"select * from ntb where timezone()='{time_zone}'") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from db.ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from stb") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from db.stb") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from stb_1") - tdSql.checkRows(2) - tdSql.query("select timezone()+1 from db.stb_1") - tdSql.checkRows(2) - tdSql.query("select timezone()+1.5 from ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()+1.5 from db.ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()-100 from ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()*100 from ntb") - tdSql.checkRows(2) - tdSql.query("select timezone()/10 from ntb") - # tdSql.query("select timezone()/0 from ntb") - - - tdSql.query("select timezone()+null from ntb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()-null from ntb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()*null from ntb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()/null from ntb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - # tdSql.query("select timezone()") - tdSql.query("select timezone()+null from stb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()-null from stb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()*null from stb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()/null from stb") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()+null from stb_1") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()-null from stb_1") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()*null from stb_1") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) - tdSql.query("select timezone()/null from stb_1") - tdSql.checkRows(2) - tdSql.checkData(0,0,None) def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") From d01e4031bd31d4c81a216ef022390f3c7d7f5098 Mon Sep 17 00:00:00 2001 From: tomchon Date: Thu, 23 Jun 2022 18:01:49 +0800 Subject: [PATCH 14/81] test: modify testcase of muti-mnodes --- tests/pytest/util/cluster.py | 264 ++---------------- .../system-test/6-cluster/5dnode3mnodeStop.py | 10 - tests/system-test/fulltest.sh | 2 +- tests/system-test/test.py | 18 +- 4 files changed, 40 insertions(+), 254 deletions(-) diff --git a/tests/pytest/util/cluster.py b/tests/pytest/util/cluster.py index 5debfab2c4..6d3be8c7a9 100644 --- a/tests/pytest/util/cluster.py +++ b/tests/pytest/util/cluster.py @@ -21,45 +21,41 @@ class ClusterDnodes(TDDnodes): self.testCluster = False self.valgrind = 0 self.killValgrind = 1 - self.independent = True - self.dnodeNums = 5 - - # def getTDDnodes(dnodeNums): - - # return class ConfigureyCluster: - """configure dnodes and return TDDnodes list, it can """ + """This will create defined number of dnodes and create a cluset. + at the same time, it will return TDDnodes list: dnodes, """ + hostname= socket.gethostname() def __init__(self): - self.dnodes = None - self.dnodes_nums = 5 + self.dnodes = [] + self.dnodeNums = 5 self.independent = True - self.start_port = 6030 + self.startPort = 6030 self.portStep = 100 - hostname1= socket.gethostname() + self.mnodeNums = 0 - def configure_cluster(self ,dnodes_nums=5,independent=True,start_port=6030,portStep=100,hostname="%s"%hostname1): - self.start_port=int(start_port) + def configure_cluster(self ,dnodeNums=5,mnodeNums=0,startPort=6030,portStep=100,hostname="%s"%hostname): + self.startPort=int(startPort) self.portStep=int(portStep) self.hostname=hostname - self.dnodes_nums = int(dnodes_nums) - self.independent = independent + self.dnodeNums = int(dnodeNums) + self.mnodeNums = int(mnodeNums) self.dnodes = [] - start_port_sec = 6130 - for num in range(1, (self.dnodes_nums+1)): + startPort_sec = int(startPort+portStep) + for num in range(1, (self.dnodeNums+1)): dnode = TDDnode(num) - dnode.addExtraCfg("firstEp", f"{hostname}:{self.start_port}") + dnode.addExtraCfg("firstEp", f"{hostname}:{self.startPort}") dnode.addExtraCfg("fqdn", f"{hostname}") - dnode.addExtraCfg("serverPort", f"{self.start_port + (num-1)*self.portStep}") - # dnode.addExtraCfg("monitorFqdn", hostname) - # dnode.addExtraCfg("monitorPort", 7043) - dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") - # configure three dnoe don't support vnodes - if self.dnodes_nums > 4 : - if self.independent and (num < 4): - dnode.addExtraCfg("supportVnodes", 0) + dnode.addExtraCfg("serverPort", f"{self.startPort + (num-1)*self.portStep}") + dnode.addExtraCfg("secondEp", f"{hostname}:{startPort_sec}") + print(num,self.mnodeNums) + + # configure dnoe of independent mnodes + if num <= self.mnodeNums and self.mnodeNums != 0 : + dnode.addExtraCfg("supportVnodes", 0) + print("-----------------88888123131231320999999") # print(dnode) self.dnodes.append(dnode) return self.dnodes @@ -69,24 +65,7 @@ class ConfigureyCluster: for dnode in self.dnodes[1:]: # print(dnode.cfgDict) dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] - print(dnode_id) tdSql.execute(" create dnode '%s';"%dnode_id) - # count=0 - # while count < 10: - # time.sleep(1) - # tdSql.query("show dnodes;") - # if tdSql.checkRows(self.dnodes_nums) : - # print("mnode is three nodes") - # if tdSql.queryResult[0][4]=='leader' : - # if tdSql.queryResult[2][4]=='offline': - # if tdSql.queryResult[1][2]=='follower': - # print("stop mnodes on dnode 3 successfully in 10s") - # break - # count+=1 - # else: - # print("stop mnodes on dnode 3 failed in 10s") - # return -1 - checkstatus=False @@ -97,206 +76,19 @@ class ConfigureyCluster: tdSql.query("show dnodes") # tdLog.debug(tdSql.queryResult) status=0 - for i in range(self.dnodes_nums): + for i in range(self.dnodeNums): if tdSql.queryResult[i][4] == "ready": status+=1 - tdLog.debug(status) + # tdLog.debug(status) - if status == self.dnodes_nums: - tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodes_nums) + if status == self.dnodeNums: + tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodeNums) break count+=1 time.sleep(1) else: - tdLog.debug("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodes_nums) + tdLog.debug("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodeNums) return -1 -cluster = ConfigureyCluster() - - # def start(self ,dnodes_nums): - - # self.TDDnodes = ClusterDnodes(dnodes) - # self.TDDnodes.init("") - # self.TDDnodes.setTestCluster(testCluster) - # self.TDDnodes.setValgrind(valgrind) - # self.TDDnodes.stopAll() - # for dnode in self.TDDnodes.dnodes: - # self.TDDnodes.deploy(dnode.index,{}) - - # for dnode in self.TDDnodes.dnodes: - # self.TDDnodes.starttaosd(dnode.index) - - # # create cluster - # for dnode in self.TDDnodes.dnodes[1:]: - # # print(dnode.cfgDict) - # dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] - # dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0] - # dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1] - # cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" - # print(cmd) - # os.system(cmd) - - # time.sleep(2) - # tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) - - # def buildcluster(self,dnodenumber): - # self.depoly_cluster(dnodenumber) - # self.master_dnode = self.TDDnodes.dnodes[0] - # self.host=self.master_dnode.cfgDict["fqdn"] - # conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) - # tdSql.init(conn1.cursor()) - - # def checkdnodes(self,dnodenumber): - # count=0 - # while count < 10: - # time.sleep(1) - # statusReadyBumber=0 - # tdSql.query("show dnodes;") - # if tdSql.checkRows(dnodenumber) : - # print("dnode is %d nodes"%dnodenumber) - # for i in range(dnodenumber): - # if tdSql.queryResult[i][4] !='ready' : - # status=tdSql.queryResult[i][4] - # print("dnode:%d status is %s "%(i,status)) - # break - # else: - # statusReadyBumber+=1 - # print(statusReadyBumber) - # if statusReadyBumber == dnodenumber : - # print("all of %d mnodes is ready in 10s "%dnodenumber) - # return True - # break - # count+=1 - # else: - # print("%d mnodes is not ready in 10s "%dnodenumber) - # return False - - - # def check3mnode(self): - # count=0 - # while count < 10: - # time.sleep(1) - # tdSql.query("show mnodes;") - # if tdSql.checkRows(3) : - # print("mnode is three nodes") - # if tdSql.queryResult[0][2]=='leader' : - # if tdSql.queryResult[1][2]=='follower': - # if tdSql.queryResult[2][2]=='follower': - # print("three mnodes is ready in 10s") - # break - # elif tdSql.queryResult[0][2]=='follower' : - # if tdSql.queryResult[1][2]=='leader': - # if tdSql.queryResult[2][2]=='follower': - # print("three mnodes is ready in 10s") - # break - # elif tdSql.queryResult[0][2]=='follower' : - # if tdSql.queryResult[1][2]=='follower': - # if tdSql.queryResult[2][2]=='leader': - # print("three mnodes is ready in 10s") - # break - # count+=1 - # else: - # print("three mnodes is not ready in 10s ") - # return -1 - - # tdSql.query("show mnodes;") - # tdSql.checkRows(3) - # tdSql.checkData(0,1,'%s:6030'%self.host) - # tdSql.checkData(0,3,'ready') - # tdSql.checkData(1,1,'%s:6130'%self.host) - # tdSql.checkData(1,3,'ready') - # tdSql.checkData(2,1,'%s:6230'%self.host) - # tdSql.checkData(2,3,'ready') - - # def check3mnode1off(self): - # count=0 - # while count < 10: - # time.sleep(1) - # tdSql.query("show mnodes;") - # if tdSql.checkRows(3) : - # print("mnode is three nodes") - # if tdSql.queryResult[0][2]=='offline' : - # if tdSql.queryResult[1][2]=='leader': - # if tdSql.queryResult[2][2]=='follower': - # print("stop mnodes on dnode 2 successfully in 10s") - # break - # elif tdSql.queryResult[1][2]=='follower': - # if tdSql.queryResult[2][2]=='leader': - # print("stop mnodes on dnode 2 successfully in 10s") - # break - # count+=1 - # else: - # print("stop mnodes on dnode 2 failed in 10s ") - # return -1 - # tdSql.error("drop mnode on dnode 1;") - - # tdSql.query("show mnodes;") - # tdSql.checkRows(3) - # tdSql.checkData(0,1,'%s:6030'%self.host) - # tdSql.checkData(0,2,'offline') - # tdSql.checkData(0,3,'ready') - # tdSql.checkData(1,1,'%s:6130'%self.host) - # tdSql.checkData(1,3,'ready') - # tdSql.checkData(2,1,'%s:6230'%self.host) - # tdSql.checkData(2,3,'ready') - - # def check3mnode2off(self): - # count=0 - # while count < 40: - # time.sleep(1) - # tdSql.query("show mnodes;") - # if tdSql.checkRows(3) : - # print("mnode is three nodes") - # if tdSql.queryResult[0][2]=='leader' : - # if tdSql.queryResult[1][2]=='offline': - # if tdSql.queryResult[2][2]=='follower': - # print("stop mnodes on dnode 2 successfully in 10s") - # break - # count+=1 - # else: - # print("stop mnodes on dnode 2 failed in 10s ") - # return -1 - # tdSql.error("drop mnode on dnode 2;") - - # tdSql.query("show mnodes;") - # tdSql.checkRows(3) - # tdSql.checkData(0,1,'%s:6030'%self.host) - # tdSql.checkData(0,2,'leader') - # tdSql.checkData(0,3,'ready') - # tdSql.checkData(1,1,'%s:6130'%self.host) - # tdSql.checkData(1,2,'offline') - # tdSql.checkData(1,3,'ready') - # tdSql.checkData(2,1,'%s:6230'%self.host) - # tdSql.checkData(2,2,'follower') - # tdSql.checkData(2,3,'ready') - - # def check3mnode3off(self): - # count=0 - # while count < 10: - # time.sleep(1) - # tdSql.query("show mnodes;") - # if tdSql.checkRows(3) : - # print("mnode is three nodes") - # if tdSql.queryResult[0][2]=='leader' : - # if tdSql.queryResult[2][2]=='offline': - # if tdSql.queryResult[1][2]=='follower': - # print("stop mnodes on dnode 3 successfully in 10s") - # break - # count+=1 - # else: - # print("stop mnodes on dnode 3 failed in 10s") - # return -1 - # tdSql.error("drop mnode on dnode 3;") - # tdSql.query("show mnodes;") - # tdSql.checkRows(3) - # tdSql.checkData(0,1,'%s:6030'%self.host) - # tdSql.checkData(0,2,'leader') - # tdSql.checkData(0,3,'ready') - # tdSql.checkData(1,1,'%s:6130'%self.host) - # tdSql.checkData(1,2,'follower') - # tdSql.checkData(1,3,'ready') - # tdSql.checkData(2,1,'%s:6230'%self.host) - # tdSql.checkData(2,2,'offline') - # tdSql.checkData(2,3,'ready') - +cluster = ConfigureyCluster() \ No newline at end of file diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index e1f66ceacb..69b9c3d879 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -159,13 +159,10 @@ class TDTestCase: tdSql.query("show mnodes;") tdSql.checkRows(3) tdSql.checkData(0,1,'%s:6030'%self.host) - tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') tdSql.checkData(1,1,'%s:6130'%self.host) - tdSql.checkData(1,2,'offline') tdSql.checkData(1,3,'ready') tdSql.checkData(2,1,'%s:6230'%self.host) - tdSql.checkData(2,2,'follower') tdSql.checkData(2,3,'ready') def check3mnode3off(self): @@ -265,13 +262,6 @@ class TDTestCase: while stopcount <= 2: for i in range(dnodenumber): tdDnodes[i].stoptaosd() - # if i == 1 : - # self.check3mnode2off() - # elif i == 2 : - # self.check3mnode3off() - # elif i == 0: - # self.check3mnode1off() - tdDnodes[i].starttaosd() # self.check3mnode() stopcount+=1 diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 19a67e924c..7d9c8ba633 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -112,7 +112,7 @@ python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 +python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 4ca16e7a57..4414265811 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -59,11 +59,12 @@ if __name__ == "__main__": logSql = True stop = 0 restart = False - dnodeNums = 1 + dnodeNums = 5 + mnodeNums = 0 updateCfgDict = {} execCmd = "" - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:', [ - 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums']) + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums']) for key, value in opts: if key in ['-h', '--help']: tdLog.printNoPrefix( @@ -79,7 +80,8 @@ if __name__ == "__main__": tdLog.printNoPrefix('-d update cfg dict, base64 json str') tdLog.printNoPrefix('-k not kill valgrind processer') tdLog.printNoPrefix('-e eval str to run') - tdLog.printNoPrefix('-N create dnodes numbers clusters') + tdLog.printNoPrefix('-N create dnodes numbers in clusters') + tdLog.printNoPrefix('-M create mnode numbers in clusters') sys.exit(0) @@ -133,6 +135,9 @@ if __name__ == "__main__": if key in ['-N', '--dnodeNums']: dnodeNums = value + if key in ['-M', '--mnodeNums']: + mnodeNums = value + if not execCmd == "": tdDnodes.init(deployPath) print(execCmd) @@ -244,9 +249,8 @@ if __name__ == "__main__": tdDnodes.start(1) tdCases.logSql(logSql) else : - print("start cluster and dnodes number") - - dnodeslist = cluster.configure_cluster(dnodes_nums=dnodeNums,independent=True) + tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) + dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums) tdDnodes = ClusterDnodes(dnodeslist) tdDnodes.init(deployPath, masterIp) tdDnodes.setTestCluster(testCluster) From 4fcd667bf6a446559950a77f0b89f6e29f9e8671 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 18:03:15 +0800 Subject: [PATCH 15/81] feat: sql command 'show consumers' and 'show subscriptions' --- include/common/tmsg.h | 12 +- include/common/ttokendef.h | 204 +- include/libs/function/functionMgt.h | 1 + include/libs/nodes/cmdnodes.h | 14 +- include/libs/nodes/nodes.h | 1 + include/libs/nodes/plannodes.h | 14 +- source/common/src/tmsg.c | 24 +- source/libs/executor/src/executorimpl.c | 10 +- source/libs/function/src/builtins.c | 12 +- source/libs/nodes/src/nodesCloneFuncs.c | 48 +- source/libs/nodes/src/nodesCodeFuncs.c | 113 +- source/libs/nodes/src/nodesUtilFuncs.c | 4 +- source/libs/parser/inc/parAst.h | 3 +- source/libs/parser/inc/sql.y | 12 +- source/libs/parser/src/parAstCreater.c | 5 +- source/libs/parser/src/parAstParser.c | 14 + source/libs/parser/src/parCalcConst.c | 19 + source/libs/parser/src/parTokenizer.c | 2 + source/libs/parser/src/parTranslater.c | 45 +- source/libs/parser/src/sql.c | 4915 +++++++++-------- source/libs/parser/test/mockCatalog.cpp | 149 +- source/libs/parser/test/parSelectTest.cpp | 18 +- source/libs/parser/test/parShowToUse.cpp | 18 + source/libs/planner/src/planLogicCreater.c | 91 +- source/libs/planner/src/planOptimizer.c | 3 +- source/libs/planner/src/planPhysiCreater.c | 8 +- source/libs/planner/src/planSpliter.c | 1 + source/libs/planner/test/planBasicTest.cpp | 7 - source/libs/planner/test/planOrderByTest.cpp | 2 + source/libs/planner/test/planSetOpTest.cpp | 16 + source/libs/planner/test/planSubqueryTest.cpp | 4 +- 31 files changed, 2989 insertions(+), 2800 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f654d523f3..4787edc434 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -696,12 +696,12 @@ typedef struct { typedef STableCfg STableCfgRsp; -int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq); -int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq); +int32_t tSerializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq); +int32_t tDeserializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq); -int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp); -int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp); -void tFreeSTableCfgRsp(STableCfgRsp *pRsp); +int32_t tSerializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp); +int32_t tDeserializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp); +void tFreeSTableCfgRsp(STableCfgRsp* pRsp); typedef struct { char db[TSDB_DB_FNAME_LEN]; @@ -2443,6 +2443,8 @@ typedef struct { int64_t interval; int64_t offset; int64_t sliding; + int64_t maxDelay; + int64_t watermark; int32_t exprLen; // strlen + 1 int32_t tagsFilterLen; // strlen + 1 int32_t sqlLen; // strlen + 1 diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 8e00119876..6ace51f58e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -158,107 +158,109 @@ #define TK_CLUSTER 140 #define TK_TRANSACTIONS 141 #define TK_DISTRIBUTED 142 -#define TK_LIKE 143 -#define TK_INDEX 144 -#define TK_FUNCTION 145 -#define TK_INTERVAL 146 -#define TK_TOPIC 147 -#define TK_AS 148 -#define TK_WITH 149 -#define TK_META 150 -#define TK_CONSUMER 151 -#define TK_GROUP 152 -#define TK_DESC 153 -#define TK_DESCRIBE 154 -#define TK_RESET 155 -#define TK_QUERY 156 -#define TK_CACHE 157 -#define TK_EXPLAIN 158 -#define TK_ANALYZE 159 -#define TK_VERBOSE 160 -#define TK_NK_BOOL 161 -#define TK_RATIO 162 -#define TK_NK_FLOAT 163 -#define TK_COMPACT 164 -#define TK_VNODES 165 -#define TK_IN 166 -#define TK_OUTPUTTYPE 167 -#define TK_AGGREGATE 168 -#define TK_BUFSIZE 169 -#define TK_STREAM 170 -#define TK_INTO 171 -#define TK_TRIGGER 172 -#define TK_AT_ONCE 173 -#define TK_WINDOW_CLOSE 174 -#define TK_KILL 175 -#define TK_CONNECTION 176 -#define TK_TRANSACTION 177 -#define TK_BALANCE 178 -#define TK_VGROUP 179 -#define TK_MERGE 180 -#define TK_REDISTRIBUTE 181 -#define TK_SPLIT 182 -#define TK_SYNCDB 183 -#define TK_DELETE 184 -#define TK_NULL 185 -#define TK_NK_QUESTION 186 -#define TK_NK_ARROW 187 -#define TK_ROWTS 188 -#define TK_TBNAME 189 -#define TK_QSTARTTS 190 -#define TK_QENDTS 191 -#define TK_WSTARTTS 192 -#define TK_WENDTS 193 -#define TK_WDURATION 194 -#define TK_CAST 195 -#define TK_NOW 196 -#define TK_TODAY 197 -#define TK_TIMEZONE 198 -#define TK_COUNT 199 -#define TK_LAST_ROW 200 -#define TK_BETWEEN 201 -#define TK_IS 202 -#define TK_NK_LT 203 -#define TK_NK_GT 204 -#define TK_NK_LE 205 -#define TK_NK_GE 206 -#define TK_NK_NE 207 -#define TK_MATCH 208 -#define TK_NMATCH 209 -#define TK_CONTAINS 210 -#define TK_JOIN 211 -#define TK_INNER 212 -#define TK_SELECT 213 -#define TK_DISTINCT 214 -#define TK_WHERE 215 -#define TK_PARTITION 216 -#define TK_BY 217 -#define TK_SESSION 218 -#define TK_STATE_WINDOW 219 -#define TK_SLIDING 220 -#define TK_FILL 221 -#define TK_VALUE 222 -#define TK_NONE 223 -#define TK_PREV 224 -#define TK_LINEAR 225 -#define TK_NEXT 226 -#define TK_HAVING 227 -#define TK_RANGE 228 -#define TK_EVERY 229 -#define TK_ORDER 230 -#define TK_SLIMIT 231 -#define TK_SOFFSET 232 -#define TK_LIMIT 233 -#define TK_OFFSET 234 -#define TK_ASC 235 -#define TK_NULLS 236 -#define TK_ID 237 -#define TK_NK_BITNOT 238 -#define TK_INSERT 239 -#define TK_VALUES 240 -#define TK_IMPORT 241 -#define TK_NK_SEMI 242 -#define TK_FILE 243 +#define TK_CONSUMERS 143 +#define TK_SUBSCRIPTIONS 144 +#define TK_LIKE 145 +#define TK_INDEX 146 +#define TK_FUNCTION 147 +#define TK_INTERVAL 148 +#define TK_TOPIC 149 +#define TK_AS 150 +#define TK_WITH 151 +#define TK_META 152 +#define TK_CONSUMER 153 +#define TK_GROUP 154 +#define TK_DESC 155 +#define TK_DESCRIBE 156 +#define TK_RESET 157 +#define TK_QUERY 158 +#define TK_CACHE 159 +#define TK_EXPLAIN 160 +#define TK_ANALYZE 161 +#define TK_VERBOSE 162 +#define TK_NK_BOOL 163 +#define TK_RATIO 164 +#define TK_NK_FLOAT 165 +#define TK_COMPACT 166 +#define TK_VNODES 167 +#define TK_IN 168 +#define TK_OUTPUTTYPE 169 +#define TK_AGGREGATE 170 +#define TK_BUFSIZE 171 +#define TK_STREAM 172 +#define TK_INTO 173 +#define TK_TRIGGER 174 +#define TK_AT_ONCE 175 +#define TK_WINDOW_CLOSE 176 +#define TK_KILL 177 +#define TK_CONNECTION 178 +#define TK_TRANSACTION 179 +#define TK_BALANCE 180 +#define TK_VGROUP 181 +#define TK_MERGE 182 +#define TK_REDISTRIBUTE 183 +#define TK_SPLIT 184 +#define TK_SYNCDB 185 +#define TK_DELETE 186 +#define TK_NULL 187 +#define TK_NK_QUESTION 188 +#define TK_NK_ARROW 189 +#define TK_ROWTS 190 +#define TK_TBNAME 191 +#define TK_QSTARTTS 192 +#define TK_QENDTS 193 +#define TK_WSTARTTS 194 +#define TK_WENDTS 195 +#define TK_WDURATION 196 +#define TK_CAST 197 +#define TK_NOW 198 +#define TK_TODAY 199 +#define TK_TIMEZONE 200 +#define TK_COUNT 201 +#define TK_LAST_ROW 202 +#define TK_BETWEEN 203 +#define TK_IS 204 +#define TK_NK_LT 205 +#define TK_NK_GT 206 +#define TK_NK_LE 207 +#define TK_NK_GE 208 +#define TK_NK_NE 209 +#define TK_MATCH 210 +#define TK_NMATCH 211 +#define TK_CONTAINS 212 +#define TK_JOIN 213 +#define TK_INNER 214 +#define TK_SELECT 215 +#define TK_DISTINCT 216 +#define TK_WHERE 217 +#define TK_PARTITION 218 +#define TK_BY 219 +#define TK_SESSION 220 +#define TK_STATE_WINDOW 221 +#define TK_SLIDING 222 +#define TK_FILL 223 +#define TK_VALUE 224 +#define TK_NONE 225 +#define TK_PREV 226 +#define TK_LINEAR 227 +#define TK_NEXT 228 +#define TK_HAVING 229 +#define TK_RANGE 230 +#define TK_EVERY 231 +#define TK_ORDER 232 +#define TK_SLIMIT 233 +#define TK_SOFFSET 234 +#define TK_LIMIT 235 +#define TK_OFFSET 236 +#define TK_ASC 237 +#define TK_NULLS 238 +#define TK_ID 239 +#define TK_NK_BITNOT 240 +#define TK_INSERT 241 +#define TK_VALUES 242 +#define TK_IMPORT 243 +#define TK_NK_SEMI 244 +#define TK_FILE 245 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 1f314d19e7..1ca51b3043 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -123,6 +123,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_SELECT_VALUE, FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function + FUNCTION_TYPE_TO_COLUMN, // distributed splitting functions FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 18ddcbcd94..1bc7470246 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -28,15 +28,14 @@ extern "C" { #define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE) #define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE) -#define SHOW_CREATE_DB_RESULT_COLS 2 +#define SHOW_CREATE_DB_RESULT_COLS 2 #define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE) #define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) -#define SHOW_CREATE_TB_RESULT_COLS 2 +#define SHOW_CREATE_TB_RESULT_COLS 2 #define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) #define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) - #define PRIVILEGE_TYPE_MASK(n) (1 << n) #define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) @@ -230,10 +229,10 @@ typedef struct SShowCreateDatabaseStmt { } SShowCreateDatabaseStmt; typedef struct SShowCreateTableStmt { - ENodeType type; - char dbName[TSDB_DB_NAME_LEN]; - char tableName[TSDB_TABLE_NAME_LEN]; - void* pCfg; // STableCfg + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + void* pCfg; // STableCfg } SShowCreateTableStmt; typedef struct SShowTableDistributedStmt { @@ -255,6 +254,7 @@ typedef struct SIndexOptions { SNode* pInterval; SNode* pOffset; SNode* pSliding; + SNode* pStreamOptions; } SIndexOptions; typedef struct SCreateIndexStmt { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 26a100bb1b..4ca3899511 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -188,6 +188,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_CREATE_STABLE_STMT, QUERY_NODE_SHOW_TRANSACTIONS_STMT, QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, + QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, QUERY_NODE_KILL_TRANSACTION_STMT, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index cb09bf6a5f..7efa6316b0 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -32,6 +32,8 @@ typedef struct SLogicNode { struct SLogicNode* pParent; int32_t optimizedFlag; uint8_t precision; + SNode* pLimit; + SNode* pSlimit; } SLogicNode; typedef enum EScanType { @@ -91,10 +93,6 @@ typedef struct SProjectLogicNode { SLogicNode node; SNodeList* pProjections; char stmtName[TSDB_TABLE_NAME_LEN]; - int64_t limit; - int64_t offset; - int64_t slimit; - int64_t soffset; } SProjectLogicNode; typedef struct SIndefRowsFuncLogicNode { @@ -247,6 +245,8 @@ typedef struct SPhysiNode { SNode* pConditions; SNodeList* pChildren; struct SPhysiNode* pParent; + SNode* pLimit; + SNode* pSlimit; } SPhysiNode; typedef struct SScanPhysiNode { @@ -296,10 +296,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode; typedef struct SProjectPhysiNode { SPhysiNode node; SNodeList* pProjections; - int64_t limit; - int64_t offset; - int64_t slimit; - int64_t soffset; } SProjectPhysiNode; typedef struct SIndefRowsFuncPhysiNode { @@ -377,7 +373,7 @@ typedef struct SIntervalPhysiNode { int8_t slidingUnit; } SIntervalPhysiNode; -typedef SIntervalPhysiNode SMergeIntervalPhysiNode; +typedef SIntervalPhysiNode SMergeIntervalPhysiNode; typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode; typedef SIntervalPhysiNode SStreamIntervalPhysiNode; typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 11fe39903b..ac2530c7fb 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -539,7 +539,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq const char *pFunc = taosArrayGet(pReq->pFuncs, i); if (tEncodeCStr(&encoder, pFunc) < 0) return -1; } - + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (NULL == pReq->pFuncs) return -1; } for (int32_t i = 0; i < numOfFuncs; ++i) { - char* pFunc = NULL; + char *pFunc = NULL; if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1; if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq if (tEncodeI64(&encoder, pReq->interval) < 0) return -1; if (tEncodeI64(&encoder, pReq->offset) < 0) return -1; if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1; + if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1; + if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1; if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; @@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1; if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1; if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1; if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1; @@ -1841,7 +1845,7 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { if (tEncodeI64(&encoder, pRsp->watermark1) < 0) return -1; if (tEncodeI64(&encoder, pRsp->watermark2) < 0) return -1; if (tEncodeI32(&encoder, pRsp->ttl) < 0) return -1; - + int32_t numOfFuncs = taosArrayGetSize(pRsp->pFuncs); if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1; for (int32_t i = 0; i < numOfFuncs; ++i) { @@ -1849,19 +1853,19 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { if (tEncodeCStr(&encoder, pFunc) < 0) return -1; } - if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1; if (pRsp->commentLen > 0) { if (tEncodeCStr(&encoder, pRsp->pComment) < 0) return -1; } - + for (int32_t i = 0; i < pRsp->numOfColumns + pRsp->numOfTags; ++i) { SSchema *pSchema = &pRsp->pSchemas[i]; if (tEncodeSSchema(&encoder, pSchema) < 0) return -1; } - if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1; - if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1; - + if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1; + if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1918,7 +1922,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) } if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1; - if (tDecodeBinaryAlloc(&decoder, (void**)&pRsp->pTags, NULL) < 0) return -1; + if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1; tEndDecode(&decoder); @@ -1934,7 +1938,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) { taosMemoryFreeClear(pRsp->pComment); taosMemoryFreeClear(pRsp->pSchemas); taosMemoryFreeClear(pRsp->pTags); - + taosArrayDestroy(pRsp->pFuncs); } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 097b8b9fb8..5c561a3d01 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1340,7 +1340,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } if (rowRes != NULL) { - int32_t totalRows = pBlock->info.rows; + int32_t totalRows = pBlock->info.rows; SSDataBlock* px = createOneDataBlock(pBlock, true); for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { @@ -3594,6 +3594,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) return pList; } +static int64_t getLimit(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; } + +static int64_t getOffset(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; } + SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo) { SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo)); @@ -3606,8 +3610,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols); SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc); - SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; - SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; + SLimit limit = {.limit = getLimit(pProjPhyNode->node.pLimit), .offset = getOffset(pProjPhyNode->node.pLimit)}; + SLimit slimit = {.limit = getLimit(pProjPhyNode->node.pSlimit), .offset = getOffset(pProjPhyNode->node.pSlimit)}; pInfo->limit = limit; pInfo->slimit = slimit; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 6baf45a5b3..acf2ffe3f8 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1824,7 +1824,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -1991,7 +1991,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "diff", .type = FUNCTION_TYPE_DIFF, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateDiff, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, @@ -2001,7 +2001,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "statecount", .type = FUNCTION_TYPE_STATE_COUNT, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateCount, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2011,7 +2011,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "stateduration", .type = FUNCTION_TYPE_STATE_DURATION, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateDuration, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2021,7 +2021,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "csum", .type = FUNCTION_TYPE_CSUM, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateCsum, .getEnvFunc = getCsumFuncEnv, .initFunc = functionSetup, @@ -2031,7 +2031,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "mavg", .type = FUNCTION_TYPE_MAVG, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateMavg, .getEnvFunc = getMavgFuncEnv, .initFunc = mavgFunctionSetup, diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 34695004df..177e7fae28 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -319,6 +319,8 @@ static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { CLONE_NODE_LIST_FIELD(pChildren); COPY_SCALAR_FIELD(optimizedFlag); COPY_SCALAR_FIELD(precision); + CLONE_NODE_FIELD(pLimit); + CLONE_NODE_FIELD(pSlimit); return TSDB_CODE_SUCCESS; } @@ -371,10 +373,6 @@ static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pProjections); COPY_CHAR_ARRAY_FIELD(stmtName); - COPY_SCALAR_FIELD(limit); - COPY_SCALAR_FIELD(offset); - COPY_SCALAR_FIELD(slimit); - COPY_SCALAR_FIELD(soffset); return TSDB_CODE_SUCCESS; } @@ -619,95 +617,137 @@ SNode* nodesCloneNode(const SNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); + break; case QUERY_NODE_VALUE: code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); + break; case QUERY_NODE_OPERATOR: code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); + break; case QUERY_NODE_LOGIC_CONDITION: code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); + break; case QUERY_NODE_FUNCTION: code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); + break; case QUERY_NODE_REAL_TABLE: code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); + break; case QUERY_NODE_TEMP_TABLE: code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); + break; case QUERY_NODE_JOIN_TABLE: code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); + break; case QUERY_NODE_GROUPING_SET: code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); + break; case QUERY_NODE_ORDER_BY_EXPR: code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); + break; case QUERY_NODE_LIMIT: code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); + break; case QUERY_NODE_STATE_WINDOW: code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); + break; case QUERY_NODE_SESSION_WINDOW: code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); + break; case QUERY_NODE_INTERVAL_WINDOW: code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); + break; case QUERY_NODE_NODE_LIST: code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); + break; case QUERY_NODE_FILL: code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); + break; case QUERY_NODE_TARGET: code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); + break; case QUERY_NODE_DATABLOCK_DESC: code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); + break; case QUERY_NODE_SLOT_DESC: code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); + break; case QUERY_NODE_DOWNSTREAM_SOURCE: code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); + break; case QUERY_NODE_LEFT_VALUE: code = TSDB_CODE_SUCCESS; + break; case QUERY_NODE_SELECT_STMT: code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_SCAN: code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_JOIN: code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_AGG: code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_PROJECT: code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY: code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_EXCHANGE: code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_MERGE: code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_WINDOW: code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_FILL: code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_SORT: code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_PARTITION: code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC: code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_SUBPLAN: code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); + break; default: break; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 10a933b00b..2a9fa38dcc 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) { static const char* jkLogicPlanTargets = "Targets"; static const char* jkLogicPlanConditions = "Conditions"; static const char* jkLogicPlanChildren = "Children"; +static const char* jkLogicPlanLimit = "Limit"; +static const char* jkLogicPlanSlimit = "SLimit"; static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { const SLogicNode* pNode = (const SLogicNode*)pObj; @@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkLogicPlanChildren, pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkLogicPlanLimit, nodeToJson, pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkLogicPlanSlimit, nodeToJson, pNode->pSlimit); + } return code; } @@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkLogicPlanChildren, &pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkLogicPlanLimit, &pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkLogicPlanSlimit, &pNode->pSlimit); + } return code; } @@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) { } static const char* jkProjectLogicPlanProjections = "Projections"; -static const char* jkProjectLogicPlanLimit = "Limit"; -static const char* jkProjectLogicPlanOffset = "Offset"; -static const char* jkProjectLogicPlanSlimit = "SLimit"; -static const char* jkProjectLogicPlanSoffset = "SOffset"; static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) { const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj; @@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkProjectLogicPlanProjections, pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanLimit, pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanOffset, pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSoffset, pNode->soffset); - } return code; } @@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkProjectLogicPlanProjections, &pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanLimit, &pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanOffset, &pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSoffset, &pNode->soffset); - } return code; } @@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) { static const char* jkPhysiPlanOutputDataBlockDesc = "OutputDataBlockDesc"; static const char* jkPhysiPlanConditions = "Conditions"; static const char* jkPhysiPlanChildren = "Children"; +static const char* jkPhysiPlanLimit = "Limit"; +static const char* jkPhysiPlanSlimit = "SLimit"; static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) { const SPhysiNode* pNode = (const SPhysiNode*)pObj; @@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkPhysiPlanChildren, pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkPhysiPlanLimit, nodeToJson, pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkPhysiPlanSlimit, nodeToJson, pNode->pSlimit); + } return code; } @@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkPhysiPlanChildren, &pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkPhysiPlanLimit, &pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkPhysiPlanSlimit, &pNode->pSlimit); + } return code; } @@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) { } static const char* jkProjectPhysiPlanProjections = "Projections"; -static const char* jkProjectPhysiPlanLimit = "Limit"; -static const char* jkProjectPhysiPlanOffset = "Offset"; -static const char* jkProjectPhysiPlanSlimit = "SLimit"; -static const char* jkProjectPhysiPlanSoffset = "SOffset"; static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) { const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj; @@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkProjectPhysiPlanProjections, pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanLimit, pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanOffset, pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSlimit, pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSoffset, pNode->soffset); - } return code; } @@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkProjectPhysiPlanProjections, &pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanLimit, &pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanOffset, &pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSlimit, &pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSoffset, &pNode->soffset); - } return code; } @@ -3158,6 +3130,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkLimitLimit = "Limit"; +static const char* jkLimitOffset = "Offset"; + +static int32_t limitNodeToJson(const void* pObj, SJson* pJson) { + const SLimitNode* pNode = (const SLimitNode*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkLimitLimit, pNode->limit); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkLimitOffset, pNode->offset); + } + + return code; +} + +static int32_t jsonToLimitNode(const SJson* pJson, void* pObj) { + SLimitNode* pNode = (SLimitNode*)pObj; + + int32_t code = tjsonGetBigIntValue(pJson, jkLimitLimit, &pNode->limit); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkLimitOffset, &pNode->offset); + } + + return code; +} + static const char* jkStateWindowCol = "StateWindowCol"; static const char* jkStateWindowExpr = "StateWindowExpr"; @@ -4024,7 +4021,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_ORDER_BY_EXPR: return orderByExprNodeToJson(pObj, pJson); case QUERY_NODE_LIMIT: - break; + return limitNodeToJson(pObj, pJson); case QUERY_NODE_STATE_WINDOW: return stateWindowNodeToJson(pObj, pJson); case QUERY_NODE_SESSION_WINDOW: @@ -4184,6 +4181,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToTempTableNode(pJson, pObj); case QUERY_NODE_ORDER_BY_EXPR: return jsonToOrderByExprNode(pJson, pObj); + case QUERY_NODE_LIMIT: + return jsonToLimitNode(pJson, pObj); case QUERY_NODE_STATE_WINDOW: return jsonToStateWindowNode(pJson, pObj); case QUERY_NODE_SESSION_WINDOW: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index ff55195bee..810ed1780d 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return makeNode(type, sizeof(SShowDnodeVariablesStmt)); @@ -644,7 +645,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_SCORES_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: - case QUERY_NODE_SHOW_TRANSACTIONS_STMT: { + case QUERY_NODE_SHOW_TRANSACTIONS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 213e21cdcf..4585a59612 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions); -SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, + SNode* pStreamOptions); SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName); SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 08199c4f37..a27d0e9164 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -388,6 +388,8 @@ cmd ::= SHOW SNODES. cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); } +cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } @@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D) // index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); } cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); } -index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); } + NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); } + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E) + sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); } %type func_list { SNodeList* } %destructor func_list { nodesDestroyList($$); } @@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } +sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); } +sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } +sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; } + /************************************************ create/drop topic ***************************************************/ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); } cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index ef7f17a460..9709a8b1ea 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno return (SNode*)pStmt; } -SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, - SNode* pSliding) { +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, + SNode* pStreamOptions) { CHECK_PARSER_STATUS(pCxt); SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); CHECK_OUT_OF_MEM(pOptions); @@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt pOptions->pInterval = pInterval; pOptions->pOffset = pOffset; pOptions->pSliding = pSliding; + pOptions->pStreamOptions = pStreamOptions; return (SNode*)pOptions; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 46d2ae8383..c3aec416ac 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -377,6 +377,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pCxt->pMetaCache); } +static int32_t collectMetaKeyFromShowConsumers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS, pCxt->pMetaCache); @@ -453,6 +458,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa return code; } +static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { pCxt->pStmt = pStmt; switch (nodeType(pStmt)) { @@ -514,6 +524,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_TOPICS_STMT: return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_CONSUMERS_STMT: + return collectMetaKeyFromShowConsumers(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CONNECTIONS_STMT: return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_QUERIES_STMT: @@ -535,6 +547,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt); + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: + return collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt); default: break; } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 0dfc79269e..495950f35c 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -175,8 +175,11 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) { } } + char aliasName[TSDB_COL_NAME_LEN] = {0}; + strcpy(aliasName, ((SExprNode*)pProject)->aliasName); int32_t code = scalarCalculateConstants(pProject, pNew); if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { + strcpy(((SExprNode*)*pNew)->aliasName, aliasName); int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { SNode** pCol = taosArrayGetP(pAssociation, i); @@ -196,6 +199,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) { return NULL == ((SExprNode*)pProj)->pAssociation; } +static SNode* createConstantValue() { + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == pVal) { + return NULL; + } + pVal->node.resType.type = TSDB_DATA_TYPE_INT; + pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + const int32_t val = 1; + nodesSetValueNodeValue(pVal, (void*)&val); + pVal->translate = true; + return (SNode*)pVal; +} + static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { SNode* pProj = NULL; WHERE_EACH(pProj, pSelect->pProjectionList) { @@ -212,6 +228,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec } WHERE_NEXT; } + if (0 == LIST_LENGTH(pSelect->pProjectionList)) { + return nodesListStrictAppend(pSelect->pProjectionList, createConstantValue()); + } return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 12b717e56a..6726bb7dfd 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -63,6 +63,7 @@ static SKeyword keywordTable[] = { {"CONNECTION", TK_CONNECTION}, {"CONNECTIONS", TK_CONNECTIONS}, {"CONSUMER", TK_CONSUMER}, + {"CONSUMERS", TK_CONSUMERS}, {"COUNT", TK_COUNT}, {"CREATE", TK_CREATE}, {"CONTAINS", TK_CONTAINS}, @@ -188,6 +189,7 @@ static SKeyword keywordTable[] = { {"STREAM", TK_STREAM}, {"STREAMS", TK_STREAMS}, {"STRICT", TK_STRICT}, + {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, {"SYNCDB", TK_SYNCDB}, {"SYSINFO", TK_SYSINFO}, {"TABLE", TK_TABLE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 43a4cf0ed6..5492fe0ce1 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -707,7 +707,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { res = translateColumnUseAlias(pCxt, pCol, &found); } if (DEAL_RES_ERROR != res && !found) { - res = translateColumnWithoutPrefix(pCxt, pCol); + if (NULL != pCxt->pCurrSetOperator) { + res = generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); + } else { + res = translateColumnWithoutPrefix(pCxt, pCol); + } } } return res; @@ -2659,6 +2663,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS return code; } +static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) { + if ((NULL != pLimit && pLimit->offset < 0)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_OFFSET_LESS_ZERO); + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) { int32_t code = translateQuery(pCxt, pSetOperator->pLeft); if (TSDB_CODE_SUCCESS == code) { @@ -2674,6 +2685,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO if (TSDB_CODE_SUCCESS == code) { code = translateSetOperOrderBy(pCxt, pSetOperator); } + if (TSDB_CODE_SUCCESS == code) { + code = checkSetOperLimit(pCxt, (SLimitNode*)pSetOperator->pLimit); + } return code; } @@ -3569,9 +3583,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) { } *pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN); SNode* pNode; - FOREACH(pNode, pFuncs) { - taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); - } + FOREACH(pNode, pFuncs) { taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); } return TSDB_CODE_SUCCESS; } @@ -3870,6 +3882,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); pReq->slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); + if (NULL != pStmt->pOptions->pStreamOptions) { + SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; + pReq->maxDelay = (NULL != pStreamOpt->pDelay ? ((SValueNode*)pStreamOpt->pDelay)->datum.i : 0); + pReq->watermark = (NULL != pStreamOpt->pWatermark ? ((SValueNode*)pStreamOpt->pWatermark)->datum.i : 0); + } int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId); if (TSDB_CODE_SUCCESS == code) { @@ -3891,6 +3908,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt return pCxt->errCode; } + if (NULL != pStmt->pOptions->pStreamOptions) { + SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; + if (NULL != pStreamOpt->pWatermark && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) { + return pCxt->errCode; + } + + if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) { + return pCxt->errCode; + } + } + SMCreateSmaReq createSmaReq = {0}; int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); if (TSDB_CODE_SUCCESS == code) { @@ -4665,6 +4694,8 @@ static const char* getSysDbName(ENodeType type) { case QUERY_NODE_SHOW_STREAMS_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: return TSDB_PERFORMANCE_SCHEMA_DB; default: break; @@ -4720,6 +4751,10 @@ static const char* getSysTableName(ENodeType type) { return TSDB_PERFS_TABLE_APPS; case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return TSDB_INS_TABLE_DNODE_VARIABLES; + case QUERY_NODE_SHOW_CONSUMERS_STMT: + return TSDB_PERFS_TABLE_CONSUMERS; + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: + return TSDB_PERFS_TABLE_SUBSCRIPTIONS; default: break; } @@ -5858,6 +5893,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index b632f2eb32..225d163f53 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 367 +#define YYNOCODE 370 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - bool yy197; - EJoinType yy208; - SToken yy241; - SAlterOption yy301; - EOrder yy362; - SNodeList* yy368; - EFillMode yy388; - SDataType yy392; - EOperatorType yy412; - ENullOrder yy417; - SNode* yy442; - int32_t yy578; - int8_t yy629; - int64_t yy683; + ENullOrder yy77; + SAlterOption yy85; + int32_t yy100; + SToken yy109; + EOrder yy178; + int64_t yy209; + int8_t yy323; + SNodeList* yy404; + bool yy437; + EOperatorType yy440; + SNode* yy452; + SDataType yy504; + EJoinType yy532; + EFillMode yy614; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 645 -#define YYNRULE 473 -#define YYNTOKEN 244 -#define YY_MAX_SHIFT 644 -#define YY_MIN_SHIFTREDUCE 938 -#define YY_MAX_SHIFTREDUCE 1410 -#define YY_ERROR_ACTION 1411 -#define YY_ACCEPT_ACTION 1412 -#define YY_NO_ACTION 1413 -#define YY_MIN_REDUCE 1414 -#define YY_MAX_REDUCE 1886 +#define YYNSTATE 653 +#define YYNRULE 477 +#define YYNTOKEN 246 +#define YY_MAX_SHIFT 652 +#define YY_MIN_SHIFTREDUCE 947 +#define YY_MAX_SHIFTREDUCE 1423 +#define YY_ERROR_ACTION 1424 +#define YY_ACCEPT_ACTION 1425 +#define YY_NO_ACTION 1426 +#define YY_MIN_REDUCE 1427 +#define YY_MAX_REDUCE 1903 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,631 +216,623 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2260) +#define YY_ACTTAB_COUNT (2208) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 78, 415, 1726, 416, 1449, 30, 239, 423, 61, 416, - /* 10 */ 1449, 1864, 39, 37, 1864, 40, 38, 36, 35, 34, - /* 20 */ 321, 1541, 1217, 333, 69, 1863, 1593, 1595, 155, 1861, - /* 30 */ 1744, 1713, 1861, 1600, 312, 1215, 558, 115, 522, 519, - /* 40 */ 326, 26, 1710, 1696, 971, 542, 1543, 33, 32, 1598, - /* 50 */ 28, 40, 38, 36, 35, 34, 33, 32, 1744, 14, - /* 60 */ 40, 38, 36, 35, 34, 1223, 512, 119, 1706, 1712, - /* 70 */ 1757, 368, 1726, 88, 1727, 545, 1729, 1730, 541, 562, - /* 80 */ 562, 84, 1, 1797, 975, 976, 60, 314, 1793, 150, - /* 90 */ 1684, 33, 32, 1864, 120, 40, 38, 36, 35, 34, - /* 100 */ 1744, 231, 1540, 511, 641, 432, 117, 1862, 543, 498, - /* 110 */ 1825, 1861, 1864, 1696, 558, 542, 149, 60, 1288, 1289, - /* 120 */ 521, 151, 1805, 1806, 559, 1810, 154, 559, 523, 1587, - /* 130 */ 1861, 39, 37, 1347, 1726, 159, 1217, 347, 372, 321, - /* 140 */ 1757, 1217, 296, 87, 1727, 545, 1729, 1730, 541, 1215, - /* 150 */ 562, 513, 1548, 1797, 1215, 1548, 508, 295, 1793, 467, - /* 160 */ 466, 1218, 1744, 1216, 465, 1242, 1255, 116, 462, 1864, - /* 170 */ 522, 461, 460, 459, 1308, 1696, 43, 542, 14, 1223, - /* 180 */ 1241, 11, 10, 156, 1223, 1221, 1222, 1861, 1270, 1271, - /* 190 */ 1273, 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, - /* 200 */ 1290, 2, 1757, 1240, 305, 88, 1727, 545, 1729, 1730, - /* 210 */ 541, 186, 562, 157, 546, 1797, 374, 157, 641, 314, - /* 220 */ 1793, 150, 324, 641, 1644, 142, 1309, 1371, 514, 509, - /* 230 */ 449, 445, 441, 437, 185, 1354, 1223, 1288, 1289, 33, - /* 240 */ 32, 1241, 1826, 40, 38, 36, 35, 34, 157, 1314, - /* 250 */ 39, 37, 306, 292, 304, 303, 596, 455, 321, 70, - /* 260 */ 1217, 457, 183, 1322, 505, 1369, 1370, 1372, 1373, 1594, - /* 270 */ 1595, 39, 37, 1215, 22, 1218, 599, 1216, 519, 321, - /* 280 */ 1218, 1217, 1216, 456, 29, 319, 1303, 1304, 1305, 1306, - /* 290 */ 1307, 1311, 1312, 1313, 1215, 1242, 1296, 14, 414, 1221, - /* 300 */ 1222, 418, 1241, 1223, 1221, 1222, 119, 1270, 1271, 1273, - /* 310 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, - /* 320 */ 2, 519, 182, 175, 1223, 180, 523, 101, 1539, 428, - /* 330 */ 100, 99, 98, 97, 96, 95, 94, 93, 92, 1710, - /* 340 */ 139, 8, 641, 1726, 1505, 117, 33, 32, 173, 119, - /* 350 */ 40, 38, 36, 35, 34, 481, 1288, 1289, 1714, 588, - /* 360 */ 228, 1805, 518, 641, 517, 1706, 1712, 1864, 479, 1710, - /* 370 */ 477, 1744, 988, 138, 987, 1426, 562, 1288, 1289, 543, - /* 380 */ 600, 156, 1520, 420, 1696, 1861, 542, 451, 117, 1239, - /* 390 */ 39, 37, 1291, 1120, 1121, 1706, 1712, 499, 321, 1218, - /* 400 */ 1217, 1216, 989, 152, 1805, 1806, 562, 1810, 1526, 422, - /* 410 */ 1272, 1757, 418, 1215, 284, 1727, 545, 1729, 1730, 541, - /* 420 */ 1218, 562, 1216, 1221, 1222, 1537, 1270, 1271, 1273, 1274, - /* 430 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 519, - /* 440 */ 1437, 558, 594, 1223, 1221, 1222, 69, 1270, 1271, 1273, - /* 450 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, - /* 460 */ 9, 127, 126, 591, 590, 589, 432, 119, 1544, 33, - /* 470 */ 32, 1272, 157, 40, 38, 36, 35, 34, 988, 200, - /* 480 */ 987, 1696, 641, 1436, 33, 32, 135, 523, 40, 38, - /* 490 */ 36, 35, 34, 359, 33, 32, 1288, 1289, 40, 38, - /* 500 */ 36, 35, 34, 42, 60, 1812, 117, 559, 989, 39, - /* 510 */ 37, 464, 463, 361, 357, 559, 559, 321, 373, 1217, - /* 520 */ 296, 228, 1805, 518, 1696, 517, 111, 111, 1864, 1809, - /* 530 */ 39, 37, 1215, 453, 458, 1548, 71, 294, 321, 1218, - /* 540 */ 1217, 1216, 154, 1548, 1548, 1243, 1861, 36, 35, 34, - /* 550 */ 33, 32, 1308, 1215, 40, 38, 36, 35, 34, 1381, - /* 560 */ 612, 610, 1223, 1221, 1222, 1415, 1270, 1271, 1273, 1274, - /* 570 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 9, - /* 580 */ 1524, 490, 367, 1223, 366, 405, 101, 1533, 1636, 100, - /* 590 */ 99, 98, 97, 96, 95, 94, 93, 92, 1600, 166, - /* 600 */ 2, 641, 33, 32, 1309, 332, 40, 38, 36, 35, - /* 610 */ 34, 325, 559, 331, 1598, 1288, 1289, 1414, 1435, 136, - /* 620 */ 1427, 136, 641, 375, 1455, 1361, 164, 1314, 1550, 208, - /* 630 */ 1550, 168, 167, 1434, 157, 157, 1288, 1289, 596, 201, - /* 640 */ 1548, 110, 109, 108, 107, 106, 105, 104, 103, 102, - /* 650 */ 559, 67, 1812, 7, 66, 60, 519, 73, 1218, 1696, - /* 660 */ 1216, 390, 29, 319, 1303, 1304, 1305, 1306, 1307, 1311, - /* 670 */ 1312, 1313, 636, 230, 1696, 1310, 1808, 1255, 1548, 1218, - /* 680 */ 1433, 1216, 1221, 1222, 119, 1270, 1271, 1273, 1274, 1275, - /* 690 */ 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 1315, 1199, - /* 700 */ 1200, 1535, 497, 1221, 1222, 1476, 1270, 1271, 1273, 1274, - /* 710 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 334, - /* 720 */ 136, 1696, 291, 117, 1239, 137, 1040, 136, 1812, 1551, - /* 730 */ 269, 398, 592, 27, 410, 1591, 1550, 58, 153, 1805, - /* 740 */ 1806, 457, 1810, 1864, 267, 57, 1600, 1432, 56, 1479, - /* 750 */ 546, 383, 1807, 411, 1412, 385, 1042, 154, 1241, 559, - /* 760 */ 1645, 1861, 1599, 456, 169, 527, 618, 617, 616, 336, - /* 770 */ 391, 615, 614, 613, 121, 608, 607, 606, 605, 604, - /* 780 */ 603, 602, 601, 129, 597, 376, 157, 1548, 1696, 60, - /* 790 */ 1078, 585, 584, 583, 1082, 582, 1084, 1085, 581, 1087, - /* 800 */ 578, 1525, 1093, 575, 1095, 1096, 572, 569, 1523, 593, - /* 810 */ 467, 466, 1591, 338, 483, 465, 1531, 263, 116, 462, - /* 820 */ 1578, 204, 461, 460, 459, 409, 1342, 86, 404, 403, - /* 830 */ 402, 401, 400, 397, 396, 395, 394, 393, 389, 388, - /* 840 */ 387, 386, 380, 379, 378, 377, 975, 976, 559, 1244, - /* 850 */ 537, 1431, 1430, 559, 1864, 1864, 1429, 328, 327, 431, - /* 860 */ 64, 63, 371, 1428, 1545, 163, 559, 1231, 154, 154, - /* 870 */ 1726, 365, 1861, 1861, 1346, 559, 1548, 1673, 1425, 1466, - /* 880 */ 1224, 1548, 290, 1817, 1342, 355, 556, 353, 349, 345, - /* 890 */ 160, 340, 1696, 1696, 1548, 594, 1424, 1696, 1744, 1423, - /* 900 */ 530, 468, 594, 1548, 1696, 191, 543, 1506, 189, 1422, - /* 910 */ 1223, 1696, 1421, 542, 127, 126, 591, 590, 589, 1696, - /* 920 */ 157, 127, 126, 591, 590, 589, 523, 1272, 1420, 1726, - /* 930 */ 1419, 207, 1418, 1417, 52, 494, 193, 1696, 1757, 192, - /* 940 */ 1696, 87, 1727, 545, 1729, 1730, 541, 472, 562, 563, - /* 950 */ 1696, 1797, 559, 1696, 528, 295, 1793, 1744, 195, 72, - /* 960 */ 535, 194, 482, 491, 525, 543, 1461, 1864, 559, 1696, - /* 970 */ 1696, 1696, 542, 1696, 1696, 1713, 199, 211, 329, 495, - /* 980 */ 1548, 154, 11, 10, 197, 1861, 1710, 196, 470, 1226, - /* 990 */ 475, 611, 1726, 587, 469, 1459, 1548, 1757, 559, 198, - /* 1000 */ 88, 1727, 545, 1729, 1730, 541, 1232, 562, 1227, 557, - /* 1010 */ 1797, 559, 1706, 1712, 314, 1793, 1877, 473, 50, 215, - /* 1020 */ 1744, 41, 252, 562, 55, 1832, 1548, 54, 543, 559, - /* 1030 */ 1235, 362, 41, 1696, 83, 542, 1409, 1410, 1716, 1548, - /* 1040 */ 335, 560, 1285, 1286, 80, 41, 1225, 241, 506, 234, - /* 1050 */ 123, 450, 124, 1726, 222, 125, 1745, 1548, 1368, 217, - /* 1060 */ 1757, 1316, 50, 88, 1727, 545, 1729, 1730, 541, 1012, - /* 1070 */ 562, 484, 1278, 1797, 1718, 1726, 337, 314, 1793, 1877, - /* 1080 */ 567, 1744, 124, 125, 1345, 1170, 1300, 243, 1855, 543, - /* 1090 */ 551, 531, 249, 1450, 1696, 1071, 542, 112, 1588, 1013, - /* 1100 */ 1828, 124, 262, 1744, 520, 233, 236, 238, 3, 5, - /* 1110 */ 339, 543, 1239, 342, 346, 301, 1696, 1229, 542, 1040, - /* 1120 */ 1099, 1757, 1103, 1110, 89, 1727, 545, 1729, 1730, 541, - /* 1130 */ 302, 562, 1183, 392, 1797, 259, 1726, 1108, 1796, 1793, - /* 1140 */ 1638, 128, 165, 1757, 399, 406, 88, 1727, 545, 1729, - /* 1150 */ 1730, 541, 408, 562, 412, 1245, 1797, 407, 413, 421, - /* 1160 */ 314, 1793, 1877, 1248, 1744, 424, 172, 425, 1247, 426, - /* 1170 */ 174, 1816, 543, 1249, 1228, 427, 177, 1696, 429, 542, - /* 1180 */ 179, 1246, 430, 181, 68, 433, 184, 452, 454, 1726, - /* 1190 */ 1538, 188, 523, 1678, 1534, 190, 293, 130, 131, 91, - /* 1200 */ 1677, 1536, 260, 1726, 1757, 485, 1532, 276, 1727, 545, - /* 1210 */ 1729, 1730, 541, 492, 562, 132, 133, 1744, 202, 489, - /* 1220 */ 205, 209, 486, 496, 502, 543, 1244, 507, 6, 516, - /* 1230 */ 1696, 1744, 542, 1864, 311, 549, 213, 1839, 504, 543, - /* 1240 */ 1838, 313, 144, 510, 1696, 523, 542, 156, 216, 1819, - /* 1250 */ 1829, 1861, 221, 503, 224, 1726, 501, 1757, 500, 226, - /* 1260 */ 276, 1727, 545, 1729, 1730, 541, 118, 562, 1342, 1243, - /* 1270 */ 44, 1757, 529, 1726, 89, 1727, 545, 1729, 1730, 541, - /* 1280 */ 532, 562, 225, 1744, 1797, 1813, 1864, 315, 534, 1793, - /* 1290 */ 18, 540, 227, 1643, 223, 1860, 1696, 1642, 542, 232, - /* 1300 */ 154, 1744, 1778, 552, 1861, 547, 548, 553, 323, 543, - /* 1310 */ 245, 79, 554, 1549, 1696, 261, 542, 1880, 247, 77, - /* 1320 */ 526, 533, 235, 1757, 565, 1726, 283, 1727, 545, 1729, - /* 1330 */ 1730, 541, 539, 562, 536, 1769, 1592, 237, 1521, 255, - /* 1340 */ 264, 1757, 1726, 637, 140, 1727, 545, 1729, 1730, 541, - /* 1350 */ 640, 562, 638, 1744, 266, 51, 143, 285, 287, 286, - /* 1360 */ 268, 543, 1690, 1689, 62, 1688, 1696, 341, 542, 1685, - /* 1370 */ 1744, 343, 344, 1210, 1211, 161, 348, 1683, 543, 350, - /* 1380 */ 351, 352, 1682, 1696, 354, 542, 1681, 356, 1680, 524, - /* 1390 */ 1878, 1726, 358, 1757, 1679, 360, 89, 1727, 545, 1729, - /* 1400 */ 1730, 541, 1663, 562, 363, 162, 1797, 364, 1186, 1185, - /* 1410 */ 1757, 1794, 1657, 279, 1727, 545, 1729, 1730, 541, 1744, - /* 1420 */ 562, 1656, 369, 370, 1655, 1654, 1157, 543, 1631, 65, - /* 1430 */ 1630, 1629, 1696, 1628, 542, 1627, 1626, 381, 382, 1625, - /* 1440 */ 384, 1624, 1623, 1622, 1621, 1620, 1619, 1618, 1617, 1616, - /* 1450 */ 1615, 1726, 515, 1614, 1613, 1612, 1611, 122, 1610, 1757, - /* 1460 */ 1726, 170, 140, 1727, 545, 1729, 1730, 541, 113, 562, - /* 1470 */ 1609, 1608, 1607, 1606, 1605, 1604, 33, 32, 1603, 1744, - /* 1480 */ 40, 38, 36, 35, 34, 1159, 1602, 543, 1744, 1601, - /* 1490 */ 1478, 1446, 1696, 978, 542, 977, 540, 417, 1445, 171, - /* 1500 */ 148, 1696, 1671, 542, 114, 318, 419, 1665, 1879, 1726, - /* 1510 */ 178, 1652, 1640, 1527, 1477, 176, 1475, 1473, 434, 1757, - /* 1520 */ 1653, 1726, 284, 1727, 545, 1729, 1730, 541, 1757, 562, - /* 1530 */ 438, 283, 1727, 545, 1729, 1730, 541, 1744, 562, 435, - /* 1540 */ 1770, 439, 1006, 436, 440, 543, 1471, 443, 444, 1744, - /* 1550 */ 1696, 1469, 542, 442, 446, 447, 1458, 543, 1457, 1442, - /* 1560 */ 448, 1529, 1696, 320, 542, 1114, 1113, 1528, 49, 187, - /* 1570 */ 1039, 1038, 644, 1037, 1726, 322, 1036, 1757, 1033, 1467, - /* 1580 */ 284, 1727, 545, 1729, 1730, 541, 258, 562, 609, 1757, - /* 1590 */ 1726, 611, 284, 1727, 545, 1729, 1730, 541, 1032, 562, - /* 1600 */ 147, 1031, 1744, 307, 1462, 634, 630, 626, 622, 256, - /* 1610 */ 543, 308, 1460, 471, 309, 1696, 1441, 542, 1744, 474, - /* 1620 */ 476, 1407, 1440, 478, 1439, 480, 543, 90, 1670, 1193, - /* 1630 */ 1664, 1696, 53, 542, 85, 487, 134, 250, 493, 1726, - /* 1640 */ 1651, 488, 1757, 1649, 206, 270, 1727, 545, 1729, 1730, - /* 1650 */ 541, 310, 562, 1650, 1648, 1647, 23, 4, 1757, 1383, - /* 1660 */ 41, 271, 1727, 545, 1729, 1730, 541, 1744, 562, 214, - /* 1670 */ 555, 220, 212, 141, 47, 543, 1367, 218, 24, 15, - /* 1680 */ 1696, 1360, 542, 1716, 219, 25, 10, 74, 46, 1339, - /* 1690 */ 229, 1338, 145, 1400, 17, 1395, 1394, 316, 45, 1726, - /* 1700 */ 210, 1389, 16, 1406, 1399, 1398, 317, 1757, 1726, 1301, - /* 1710 */ 272, 1727, 545, 1729, 1730, 541, 19, 562, 13, 1280, - /* 1720 */ 146, 1191, 1279, 203, 158, 1263, 544, 1744, 550, 31, - /* 1730 */ 12, 20, 1639, 246, 21, 543, 1744, 1715, 251, 240, - /* 1740 */ 1696, 1365, 542, 248, 543, 242, 1233, 244, 75, 1696, - /* 1750 */ 76, 542, 564, 566, 1760, 330, 570, 1726, 1282, 80, - /* 1760 */ 1100, 561, 48, 568, 573, 1097, 1094, 1757, 571, 1726, - /* 1770 */ 278, 1727, 545, 1729, 1730, 541, 1757, 562, 574, 280, - /* 1780 */ 1727, 545, 1729, 1730, 541, 1744, 562, 1088, 576, 577, - /* 1790 */ 579, 1086, 580, 543, 1092, 1091, 1090, 1744, 1696, 1089, - /* 1800 */ 542, 1077, 1109, 586, 81, 543, 253, 82, 59, 1105, - /* 1810 */ 1696, 1004, 542, 595, 1046, 1028, 598, 254, 1026, 1025, - /* 1820 */ 1726, 1024, 1021, 1023, 1022, 1757, 1020, 1019, 273, 1727, - /* 1830 */ 545, 1729, 1730, 541, 1726, 562, 1043, 1757, 1041, 1016, - /* 1840 */ 281, 1727, 545, 1729, 1730, 541, 1015, 562, 1744, 1014, - /* 1850 */ 1011, 1010, 1009, 1474, 619, 620, 543, 621, 1472, 623, - /* 1860 */ 624, 1696, 1744, 542, 625, 1470, 627, 628, 629, 1468, - /* 1870 */ 543, 631, 633, 632, 1456, 1696, 635, 542, 968, 1438, - /* 1880 */ 643, 257, 639, 1413, 1219, 1726, 265, 642, 1757, 1413, - /* 1890 */ 1413, 274, 1727, 545, 1729, 1730, 541, 1726, 562, 1413, - /* 1900 */ 1413, 1413, 1757, 1413, 1413, 282, 1727, 545, 1729, 1730, - /* 1910 */ 541, 1726, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, - /* 1920 */ 1413, 543, 1413, 1413, 1413, 1744, 1696, 1413, 542, 1413, - /* 1930 */ 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, 1744, - /* 1940 */ 542, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 1950 */ 1413, 1413, 1696, 1757, 542, 1413, 275, 1727, 545, 1729, - /* 1960 */ 1730, 541, 1726, 562, 1413, 1757, 1413, 1413, 288, 1727, - /* 1970 */ 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1413, 1757, - /* 1980 */ 1413, 1413, 289, 1727, 545, 1729, 1730, 541, 1726, 562, - /* 1990 */ 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, - /* 2000 */ 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, - /* 2010 */ 1413, 1413, 1413, 1413, 1413, 1413, 1744, 1413, 1413, 1413, - /* 2020 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, - /* 2030 */ 1757, 542, 1413, 1738, 1727, 545, 1729, 1730, 541, 1413, - /* 2040 */ 562, 1726, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1413, - /* 2050 */ 1413, 1413, 1413, 1726, 1413, 1413, 1757, 1413, 1413, 1737, - /* 2060 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1744, - /* 2070 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 2080 */ 1413, 1744, 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, - /* 2090 */ 1413, 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, - /* 2100 */ 1413, 1413, 1413, 1413, 1726, 1413, 1413, 1413, 1413, 1757, - /* 2110 */ 1413, 1413, 1736, 1727, 545, 1729, 1730, 541, 1726, 562, - /* 2120 */ 1413, 1757, 1413, 1413, 299, 1727, 545, 1729, 1730, 541, - /* 2130 */ 1413, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, - /* 2140 */ 543, 1413, 1413, 1413, 1413, 1696, 1744, 542, 1413, 1413, - /* 2150 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, - /* 2160 */ 1413, 542, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1726, - /* 2170 */ 1413, 1413, 1757, 1413, 1413, 298, 1727, 545, 1729, 1730, - /* 2180 */ 541, 1726, 562, 1413, 1413, 1413, 1757, 1413, 1413, 300, - /* 2190 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1744, 1413, 1413, - /* 2200 */ 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1744, - /* 2210 */ 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 2220 */ 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, 1413, - /* 2230 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1757, 1413, 1413, - /* 2240 */ 297, 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1757, - /* 2250 */ 1413, 1413, 277, 1727, 545, 1729, 1730, 541, 1413, 562, + /* 0 */ 422, 1661, 423, 1462, 430, 1730, 423, 1462, 317, 1881, + /* 10 */ 141, 1425, 39, 37, 1518, 373, 1727, 69, 1552, 1550, + /* 20 */ 326, 1428, 1230, 1880, 379, 1730, 1367, 1878, 334, 1727, + /* 30 */ 115, 140, 1254, 1439, 1743, 1228, 1727, 338, 566, 1556, + /* 40 */ 1606, 1608, 101, 1723, 1729, 100, 99, 98, 97, 96, + /* 50 */ 95, 94, 93, 92, 570, 1881, 1723, 1729, 61, 14, + /* 60 */ 1309, 296, 1761, 1723, 1729, 1236, 1254, 570, 1761, 156, + /* 70 */ 550, 566, 343, 1878, 570, 1713, 519, 549, 39, 37, + /* 80 */ 1360, 427, 1, 504, 1255, 1230, 326, 1252, 1230, 33, + /* 90 */ 32, 439, 530, 40, 38, 36, 35, 34, 1228, 1743, + /* 100 */ 43, 1228, 151, 1774, 649, 520, 87, 1744, 552, 1746, + /* 110 */ 1747, 548, 1881, 570, 518, 1600, 1814, 69, 1301, 1302, + /* 120 */ 298, 1810, 60, 1881, 1255, 14, 156, 1761, 1236, 1881, + /* 130 */ 1878, 1236, 1881, 567, 567, 547, 60, 156, 526, 1557, + /* 140 */ 1713, 1878, 549, 157, 111, 161, 158, 1878, 2, 101, + /* 150 */ 1878, 460, 100, 99, 98, 97, 96, 95, 94, 93, + /* 160 */ 92, 1561, 1561, 1231, 1394, 1229, 119, 649, 1774, 604, + /* 170 */ 649, 287, 1744, 552, 1746, 1747, 548, 546, 570, 543, + /* 180 */ 1786, 1323, 1129, 1130, 1301, 1302, 1450, 1234, 1235, 534, + /* 190 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, + /* 200 */ 1299, 1300, 1303, 1285, 1328, 166, 117, 295, 1829, 1252, + /* 210 */ 40, 38, 36, 35, 34, 159, 405, 1427, 1236, 417, + /* 220 */ 528, 153, 1822, 1823, 567, 1827, 1231, 1713, 1229, 1231, + /* 230 */ 67, 1229, 1826, 66, 1384, 377, 390, 1285, 418, 27, + /* 240 */ 392, 110, 109, 108, 107, 106, 105, 104, 103, 102, + /* 250 */ 1234, 1235, 1561, 1234, 1235, 159, 1283, 1284, 1286, 1287, + /* 260 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 159, + /* 270 */ 383, 512, 1382, 1383, 1385, 1386, 33, 32, 39, 37, + /* 280 */ 40, 38, 36, 35, 34, 1254, 326, 608, 1230, 1533, + /* 290 */ 1087, 593, 592, 591, 1091, 590, 1093, 1094, 589, 1096, + /* 300 */ 586, 1228, 1102, 583, 1104, 1105, 580, 577, 11, 10, + /* 310 */ 416, 22, 566, 411, 410, 409, 408, 407, 404, 403, + /* 320 */ 402, 401, 400, 396, 395, 394, 393, 387, 386, 385, + /* 330 */ 384, 1236, 381, 380, 39, 37, 1743, 1253, 310, 30, + /* 340 */ 240, 997, 326, 996, 1230, 33, 32, 209, 8, 40, + /* 350 */ 38, 36, 35, 34, 474, 473, 458, 1228, 1731, 472, + /* 360 */ 980, 1256, 116, 469, 1761, 567, 468, 467, 466, 1727, + /* 370 */ 649, 998, 550, 60, 42, 73, 111, 1713, 596, 549, + /* 380 */ 535, 14, 497, 465, 1301, 1302, 311, 1236, 309, 308, + /* 390 */ 1335, 462, 412, 1561, 530, 464, 1723, 1729, 515, 479, + /* 400 */ 984, 985, 1881, 1449, 2, 1774, 1440, 570, 87, 1744, + /* 410 */ 552, 1746, 1747, 548, 489, 570, 1879, 463, 1814, 567, + /* 420 */ 1878, 567, 298, 1810, 84, 553, 649, 1492, 201, 1231, + /* 430 */ 378, 1229, 382, 329, 1881, 607, 1658, 120, 170, 169, + /* 440 */ 1301, 1302, 482, 1448, 1713, 1553, 476, 1561, 156, 1561, + /* 450 */ 490, 200, 1878, 1234, 1235, 1546, 1283, 1284, 1286, 1287, + /* 460 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 330, + /* 470 */ 521, 516, 39, 37, 1304, 421, 55, 138, 425, 54, + /* 480 */ 326, 159, 1230, 567, 1713, 1231, 1563, 1229, 474, 473, + /* 490 */ 1881, 231, 1420, 472, 397, 1228, 116, 469, 526, 1519, + /* 500 */ 468, 467, 466, 526, 156, 58, 159, 159, 1878, 1234, + /* 510 */ 1235, 1561, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, + /* 520 */ 568, 1298, 1299, 1300, 1303, 1236, 119, 39, 37, 1607, + /* 530 */ 1608, 119, 567, 364, 1257, 326, 1447, 1230, 984, 985, + /* 540 */ 33, 32, 9, 398, 40, 38, 36, 35, 34, 202, + /* 550 */ 1228, 33, 32, 366, 362, 40, 38, 36, 35, 34, + /* 560 */ 1561, 567, 429, 1743, 649, 425, 117, 336, 997, 1446, + /* 570 */ 996, 117, 438, 1657, 1419, 138, 305, 1713, 1301, 1302, + /* 580 */ 1236, 154, 1822, 1823, 1563, 1827, 155, 1822, 1823, 1561, + /* 590 */ 1827, 1761, 602, 39, 37, 235, 567, 9, 998, 550, + /* 600 */ 1445, 326, 1444, 1230, 1713, 464, 549, 1558, 71, 304, + /* 610 */ 1713, 129, 128, 599, 598, 597, 1228, 567, 506, 649, + /* 620 */ 471, 470, 1479, 1231, 1561, 1229, 1374, 463, 1690, 36, + /* 630 */ 35, 34, 1774, 1301, 1302, 288, 1744, 552, 1746, 1747, + /* 640 */ 548, 1713, 570, 1713, 475, 1561, 1236, 1234, 1235, 1049, + /* 650 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, + /* 660 */ 1299, 1300, 1303, 2, 212, 567, 567, 33, 32, 1254, + /* 670 */ 567, 40, 38, 36, 35, 34, 498, 502, 1231, 1051, + /* 680 */ 1229, 564, 33, 32, 1651, 649, 40, 38, 36, 35, + /* 690 */ 34, 620, 618, 1561, 1561, 168, 1834, 1355, 1561, 1301, + /* 700 */ 1302, 1538, 1234, 1235, 1548, 1283, 1284, 1286, 1287, 1288, + /* 710 */ 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 299, 60, + /* 720 */ 567, 33, 32, 652, 339, 40, 38, 36, 35, 34, + /* 730 */ 1544, 565, 138, 299, 532, 205, 1613, 262, 567, 1539, + /* 740 */ 488, 1563, 1268, 331, 1231, 1443, 1229, 1613, 1561, 256, + /* 750 */ 1321, 149, 1611, 486, 337, 484, 642, 638, 634, 630, + /* 760 */ 260, 244, 1743, 1611, 1537, 1321, 1561, 1442, 1234, 1235, + /* 770 */ 1441, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, + /* 780 */ 1298, 1299, 1300, 1303, 138, 85, 1713, 139, 254, 553, + /* 790 */ 1761, 1438, 273, 1564, 1359, 602, 1268, 439, 550, 372, + /* 800 */ 1659, 371, 567, 1713, 1322, 549, 271, 57, 1713, 1829, + /* 810 */ 56, 1713, 544, 340, 129, 128, 599, 598, 597, 1322, + /* 820 */ 1437, 563, 604, 1212, 1213, 1656, 171, 1327, 305, 1613, + /* 830 */ 1561, 1774, 1713, 1825, 88, 1744, 552, 1746, 1747, 548, + /* 840 */ 1285, 570, 1327, 1489, 1814, 1612, 1436, 1435, 319, 1810, + /* 850 */ 1894, 60, 159, 211, 78, 1701, 7, 595, 1434, 1849, + /* 860 */ 1433, 1713, 29, 324, 1316, 1317, 1318, 1319, 1320, 1324, + /* 870 */ 1325, 1326, 245, 246, 1204, 1554, 204, 29, 324, 1316, + /* 880 */ 1317, 1318, 1319, 1320, 1324, 1325, 1326, 1713, 1713, 86, + /* 890 */ 33, 32, 513, 1432, 40, 38, 36, 35, 34, 1713, + /* 900 */ 1743, 1713, 352, 1431, 626, 625, 624, 341, 1829, 623, + /* 910 */ 622, 621, 121, 616, 615, 614, 613, 612, 611, 610, + /* 920 */ 609, 131, 605, 619, 64, 63, 376, 1430, 1761, 165, + /* 930 */ 208, 542, 1824, 304, 1713, 370, 529, 333, 332, 600, + /* 940 */ 537, 1713, 1604, 549, 1713, 601, 294, 1244, 1604, 360, + /* 950 */ 1239, 358, 354, 350, 162, 345, 267, 457, 72, 1591, + /* 960 */ 1237, 1743, 193, 367, 195, 191, 223, 194, 1713, 1774, + /* 970 */ 1536, 1474, 88, 1744, 552, 1746, 1747, 548, 197, 570, + /* 980 */ 199, 196, 1814, 198, 159, 1472, 319, 1810, 152, 1761, + /* 990 */ 1236, 52, 501, 477, 11, 10, 1238, 529, 491, 50, + /* 1000 */ 232, 1762, 1713, 83, 549, 26, 1358, 480, 505, 1842, + /* 1010 */ 1733, 33, 32, 80, 28, 40, 38, 36, 35, 34, + /* 1020 */ 33, 32, 1743, 342, 40, 38, 36, 35, 34, 571, + /* 1030 */ 1774, 1355, 137, 88, 1744, 552, 1746, 1747, 548, 1381, + /* 1040 */ 570, 1422, 1423, 1814, 1463, 1601, 1735, 319, 1810, 152, + /* 1050 */ 1761, 1845, 216, 41, 527, 234, 237, 239, 550, 1313, + /* 1060 */ 41, 5, 41, 1713, 602, 549, 242, 344, 3, 1252, + /* 1070 */ 1843, 123, 347, 351, 126, 127, 50, 1743, 306, 1049, + /* 1080 */ 1242, 575, 126, 129, 128, 599, 598, 597, 1245, 1468, + /* 1090 */ 1240, 1774, 218, 1329, 88, 1744, 552, 1746, 1747, 548, + /* 1100 */ 1291, 570, 1180, 127, 1814, 1761, 247, 112, 319, 1810, + /* 1110 */ 1894, 559, 1248, 550, 253, 1080, 266, 307, 1713, 1872, + /* 1120 */ 549, 1108, 1112, 568, 1298, 1299, 1241, 1196, 126, 263, + /* 1130 */ 1743, 1021, 399, 538, 1653, 167, 406, 644, 1258, 1743, + /* 1140 */ 414, 413, 415, 1119, 419, 1261, 1774, 1117, 431, 88, + /* 1150 */ 1744, 552, 1746, 1747, 548, 420, 570, 1743, 1761, 1814, + /* 1160 */ 428, 1022, 174, 319, 1810, 1894, 550, 1761, 130, 1260, + /* 1170 */ 433, 1713, 176, 549, 1833, 550, 432, 1262, 434, 179, + /* 1180 */ 1713, 181, 549, 1259, 437, 1761, 459, 183, 530, 436, + /* 1190 */ 68, 440, 186, 550, 461, 91, 1551, 530, 1713, 1774, + /* 1200 */ 549, 190, 280, 1744, 552, 1746, 1747, 548, 1774, 570, + /* 1210 */ 1547, 280, 1744, 552, 1746, 1747, 548, 192, 570, 132, + /* 1220 */ 133, 1549, 1743, 1545, 134, 135, 1774, 297, 1881, 89, + /* 1230 */ 1744, 552, 1746, 1747, 548, 1695, 570, 1881, 1743, 1814, + /* 1240 */ 264, 203, 158, 1813, 1810, 492, 1878, 1743, 493, 496, + /* 1250 */ 1761, 156, 1257, 206, 499, 1878, 503, 316, 550, 210, + /* 1260 */ 514, 1846, 509, 1713, 556, 549, 1761, 1856, 214, 511, + /* 1270 */ 217, 318, 6, 517, 550, 1761, 523, 510, 1836, 1713, + /* 1280 */ 224, 549, 508, 550, 507, 1855, 1355, 118, 1713, 226, + /* 1290 */ 549, 1774, 222, 227, 89, 1744, 552, 1746, 1747, 548, + /* 1300 */ 1743, 570, 146, 225, 1814, 1256, 1830, 1774, 541, 1810, + /* 1310 */ 142, 1744, 552, 1746, 1747, 548, 1774, 570, 44, 89, + /* 1320 */ 1744, 552, 1746, 1747, 548, 539, 570, 1877, 1761, 1814, + /* 1330 */ 188, 536, 320, 18, 1811, 124, 550, 233, 236, 228, + /* 1340 */ 1795, 1713, 125, 549, 144, 554, 555, 1897, 533, 456, + /* 1350 */ 452, 448, 444, 187, 1743, 531, 1895, 1694, 1663, 557, + /* 1360 */ 540, 328, 560, 1743, 561, 249, 251, 238, 562, 1774, + /* 1370 */ 265, 77, 283, 1744, 552, 1746, 1747, 548, 70, 570, + /* 1380 */ 1562, 185, 1761, 79, 573, 268, 1534, 645, 259, 1605, + /* 1390 */ 550, 1761, 646, 648, 51, 1713, 145, 549, 289, 550, + /* 1400 */ 272, 291, 290, 270, 1713, 1707, 549, 1706, 62, 1705, + /* 1410 */ 346, 522, 348, 1743, 1702, 349, 1223, 1224, 323, 163, + /* 1420 */ 353, 1700, 355, 1774, 1743, 356, 142, 1744, 552, 1746, + /* 1430 */ 1747, 548, 1774, 570, 357, 288, 1744, 552, 1746, 1747, + /* 1440 */ 548, 1761, 570, 184, 177, 1699, 182, 359, 1698, 547, + /* 1450 */ 435, 361, 1761, 1697, 1713, 363, 549, 1696, 365, 1680, + /* 1460 */ 550, 164, 368, 369, 1199, 1713, 1198, 549, 1674, 175, + /* 1470 */ 1673, 374, 1896, 375, 1672, 1671, 1743, 1168, 1646, 325, + /* 1480 */ 1645, 1644, 1774, 65, 1643, 287, 1744, 552, 1746, 1747, + /* 1490 */ 548, 1642, 570, 1774, 1787, 1641, 288, 1744, 552, 1746, + /* 1500 */ 1747, 548, 1640, 570, 1761, 1639, 388, 389, 1638, 391, + /* 1510 */ 1637, 1636, 550, 1635, 1634, 1633, 1632, 1713, 1631, 549, + /* 1520 */ 1630, 1629, 1628, 1627, 1626, 1625, 1624, 122, 1623, 1743, + /* 1530 */ 1622, 327, 1621, 1620, 1619, 1618, 1617, 1616, 1743, 1170, + /* 1540 */ 1615, 1614, 1491, 1459, 150, 1774, 172, 1743, 288, 1744, + /* 1550 */ 552, 1746, 1747, 548, 1458, 570, 1688, 1761, 113, 987, + /* 1560 */ 986, 1682, 1670, 1669, 180, 550, 1761, 1655, 1540, 173, + /* 1570 */ 1713, 1490, 549, 424, 550, 1761, 1488, 426, 114, 1713, + /* 1580 */ 1486, 549, 1484, 550, 1482, 441, 178, 443, 1713, 1471, + /* 1590 */ 549, 442, 445, 1470, 447, 449, 1455, 1542, 1774, 1743, + /* 1600 */ 446, 274, 1744, 552, 1746, 1747, 548, 1774, 570, 451, + /* 1610 */ 275, 1744, 552, 1746, 1747, 548, 1774, 570, 453, 276, + /* 1620 */ 1744, 552, 1746, 1747, 548, 1015, 570, 1761, 450, 49, + /* 1630 */ 455, 1122, 454, 1123, 1541, 550, 1048, 1047, 1046, 1045, + /* 1640 */ 1713, 1743, 549, 617, 1480, 1042, 1041, 1040, 189, 619, + /* 1650 */ 312, 1475, 313, 1473, 478, 314, 481, 1454, 483, 1453, + /* 1660 */ 485, 1743, 1452, 487, 1687, 90, 1206, 1681, 1774, 1761, + /* 1670 */ 494, 282, 1744, 552, 1746, 1747, 548, 550, 570, 1668, + /* 1680 */ 1666, 136, 1713, 1743, 549, 1667, 1665, 1664, 15, 1761, + /* 1690 */ 4, 1408, 41, 47, 10, 23, 213, 550, 1396, 207, + /* 1700 */ 143, 53, 1713, 215, 549, 1380, 219, 221, 24, 220, + /* 1710 */ 1774, 1761, 1373, 284, 1744, 552, 1746, 1747, 548, 550, + /* 1720 */ 570, 500, 495, 315, 1713, 74, 549, 1733, 16, 1352, + /* 1730 */ 1774, 25, 46, 277, 1744, 552, 1746, 1747, 548, 1743, + /* 1740 */ 570, 1351, 230, 147, 17, 1407, 1413, 321, 1743, 1412, + /* 1750 */ 1411, 1402, 1774, 322, 19, 285, 1744, 552, 1746, 1747, + /* 1760 */ 548, 1314, 570, 148, 1276, 1293, 31, 1761, 160, 1662, + /* 1770 */ 1654, 250, 1732, 1292, 241, 550, 1761, 45, 1378, 551, + /* 1780 */ 1713, 12, 549, 558, 550, 13, 20, 21, 243, 1713, + /* 1790 */ 248, 549, 80, 255, 1246, 75, 572, 574, 1743, 1295, + /* 1800 */ 252, 76, 1777, 569, 1101, 48, 335, 1743, 1774, 578, + /* 1810 */ 1109, 278, 1744, 552, 1746, 1747, 548, 1774, 570, 576, + /* 1820 */ 286, 1744, 552, 1746, 1747, 548, 1761, 570, 1106, 1103, + /* 1830 */ 579, 581, 582, 584, 550, 1761, 587, 1097, 585, 1713, + /* 1840 */ 1095, 549, 588, 550, 1100, 1099, 1086, 1098, 1713, 594, + /* 1850 */ 549, 1118, 257, 1114, 1013, 81, 603, 1743, 82, 59, + /* 1860 */ 1037, 606, 258, 1035, 1055, 1034, 1743, 1774, 1033, 1032, + /* 1870 */ 279, 1744, 552, 1746, 1747, 548, 1774, 570, 1031, 292, + /* 1880 */ 1744, 552, 1746, 1747, 548, 1761, 570, 1030, 1029, 1028, + /* 1890 */ 1050, 1052, 1025, 550, 1761, 1024, 1023, 1020, 1713, 1019, + /* 1900 */ 549, 1018, 550, 1487, 627, 628, 629, 1713, 1485, 549, + /* 1910 */ 631, 633, 1483, 635, 1481, 632, 637, 636, 1743, 639, + /* 1920 */ 640, 641, 1469, 643, 977, 1451, 1774, 1743, 261, 293, + /* 1930 */ 1744, 552, 1746, 1747, 548, 1774, 570, 647, 1755, 1744, + /* 1940 */ 552, 1746, 1747, 548, 650, 570, 1761, 1426, 1232, 269, + /* 1950 */ 651, 1426, 1426, 1426, 550, 1761, 1426, 1426, 1426, 1713, + /* 1960 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1426, + /* 1970 */ 549, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 1980 */ 1743, 1426, 1426, 1426, 1426, 1426, 1426, 1774, 1426, 1743, + /* 1990 */ 1754, 1744, 552, 1746, 1747, 548, 1774, 570, 1743, 1753, + /* 2000 */ 1744, 552, 1746, 1747, 548, 1426, 570, 1743, 1761, 1426, + /* 2010 */ 526, 1426, 1426, 1426, 1426, 1426, 550, 1761, 1426, 1426, + /* 2020 */ 1426, 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 1426, + /* 2030 */ 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 119, 1713, + /* 2040 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1774, + /* 2050 */ 549, 1426, 302, 1744, 552, 1746, 1747, 548, 1774, 570, + /* 2060 */ 530, 301, 1744, 552, 1746, 1747, 548, 1774, 570, 1426, + /* 2070 */ 303, 1744, 552, 1746, 1747, 548, 1774, 570, 117, 300, + /* 2080 */ 1744, 552, 1746, 1747, 548, 1743, 570, 1426, 1426, 1426, + /* 2090 */ 1426, 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 526, + /* 2100 */ 1881, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2110 */ 1426, 1426, 1426, 1761, 158, 1426, 1426, 1426, 1878, 1426, + /* 2120 */ 1426, 550, 1426, 1426, 1426, 1426, 1713, 119, 549, 1426, + /* 2130 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2140 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 530, + /* 2150 */ 1426, 1426, 1426, 1426, 1774, 1426, 1426, 281, 1744, 552, + /* 2160 */ 1746, 1747, 548, 1426, 570, 1426, 1426, 117, 1426, 1426, + /* 2170 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2180 */ 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 1426, 1881, + /* 2190 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2200 */ 1426, 1426, 1426, 156, 1426, 1426, 1426, 1878, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 257, 251, 247, 253, 254, 329, 330, 251, 4, 253, - /* 10 */ 254, 344, 12, 13, 344, 12, 13, 14, 15, 16, - /* 20 */ 20, 278, 22, 286, 259, 358, 289, 290, 358, 362, - /* 30 */ 275, 277, 362, 275, 280, 35, 20, 272, 283, 255, - /* 40 */ 282, 2, 288, 288, 4, 290, 281, 8, 9, 291, - /* 50 */ 2, 12, 13, 14, 15, 16, 8, 9, 275, 59, - /* 60 */ 12, 13, 14, 15, 16, 65, 283, 283, 314, 315, - /* 70 */ 315, 303, 247, 318, 319, 320, 321, 322, 323, 325, - /* 80 */ 325, 257, 82, 328, 44, 45, 82, 332, 333, 334, - /* 90 */ 0, 8, 9, 344, 270, 12, 13, 14, 15, 16, - /* 100 */ 275, 346, 278, 320, 104, 58, 322, 358, 283, 354, - /* 110 */ 355, 362, 344, 288, 20, 290, 274, 82, 118, 119, - /* 120 */ 336, 337, 338, 339, 255, 341, 358, 255, 303, 287, - /* 130 */ 362, 12, 13, 14, 247, 266, 22, 47, 266, 20, - /* 140 */ 315, 22, 59, 318, 319, 320, 321, 322, 323, 35, - /* 150 */ 325, 20, 283, 328, 35, 283, 146, 332, 333, 61, - /* 160 */ 62, 161, 275, 163, 66, 20, 83, 69, 70, 344, - /* 170 */ 283, 73, 74, 75, 91, 288, 82, 290, 59, 65, - /* 180 */ 20, 1, 2, 358, 65, 185, 186, 362, 188, 189, + /* 0 */ 253, 0, 255, 256, 253, 279, 255, 256, 282, 347, + /* 10 */ 262, 246, 12, 13, 266, 307, 290, 261, 279, 278, + /* 20 */ 20, 0, 22, 361, 257, 279, 14, 365, 282, 290, + /* 30 */ 274, 248, 20, 250, 249, 35, 290, 288, 20, 283, + /* 40 */ 291, 292, 21, 317, 318, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 328, 347, 317, 318, 4, 59, + /* 60 */ 14, 294, 277, 317, 318, 65, 20, 328, 277, 361, + /* 70 */ 285, 20, 307, 365, 328, 290, 285, 292, 12, 13, + /* 80 */ 14, 14, 82, 307, 20, 22, 20, 20, 22, 8, + /* 90 */ 9, 58, 307, 12, 13, 14, 15, 16, 35, 249, + /* 100 */ 82, 35, 276, 318, 104, 20, 321, 322, 323, 324, + /* 110 */ 325, 326, 347, 328, 323, 289, 331, 261, 118, 119, + /* 120 */ 335, 336, 82, 347, 20, 59, 361, 277, 65, 347, + /* 130 */ 365, 65, 347, 257, 257, 285, 82, 361, 257, 283, + /* 140 */ 290, 365, 292, 361, 268, 268, 361, 365, 82, 21, + /* 150 */ 365, 275, 24, 25, 26, 27, 28, 29, 30, 31, + /* 160 */ 32, 285, 285, 163, 83, 165, 285, 104, 318, 58, + /* 170 */ 104, 321, 322, 323, 324, 325, 326, 327, 328, 329, + /* 180 */ 330, 145, 118, 119, 118, 119, 249, 187, 188, 43, /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - /* 200 */ 200, 82, 315, 20, 37, 318, 319, 320, 321, 322, - /* 210 */ 323, 33, 325, 213, 290, 328, 255, 213, 104, 332, - /* 220 */ 333, 334, 298, 104, 300, 47, 143, 185, 218, 219, - /* 230 */ 52, 53, 54, 55, 56, 14, 65, 118, 119, 8, - /* 240 */ 9, 20, 355, 12, 13, 14, 15, 16, 213, 166, - /* 250 */ 12, 13, 85, 292, 87, 88, 58, 90, 20, 81, - /* 260 */ 22, 94, 84, 83, 222, 223, 224, 225, 226, 289, - /* 270 */ 290, 12, 13, 35, 43, 161, 65, 163, 255, 20, - /* 280 */ 161, 22, 163, 116, 201, 202, 203, 204, 205, 206, - /* 290 */ 207, 208, 209, 210, 35, 20, 14, 59, 252, 185, - /* 300 */ 186, 255, 20, 65, 185, 186, 283, 188, 189, 190, - /* 310 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - /* 320 */ 82, 255, 144, 145, 65, 147, 303, 21, 277, 151, - /* 330 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 288, - /* 340 */ 260, 82, 104, 247, 264, 322, 8, 9, 170, 283, - /* 350 */ 12, 13, 14, 15, 16, 21, 118, 119, 277, 93, - /* 360 */ 337, 338, 339, 104, 341, 314, 315, 344, 34, 288, - /* 370 */ 36, 275, 20, 246, 22, 248, 325, 118, 119, 283, - /* 380 */ 263, 358, 265, 14, 288, 362, 290, 35, 322, 20, - /* 390 */ 12, 13, 14, 118, 119, 314, 315, 301, 20, 161, - /* 400 */ 22, 163, 50, 337, 338, 339, 325, 341, 0, 252, - /* 410 */ 189, 315, 255, 35, 318, 319, 320, 321, 322, 323, - /* 420 */ 161, 325, 163, 185, 186, 276, 188, 189, 190, 191, - /* 430 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 255, - /* 440 */ 247, 20, 94, 65, 185, 186, 259, 188, 189, 190, - /* 450 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - /* 460 */ 82, 113, 114, 115, 116, 117, 58, 283, 281, 8, - /* 470 */ 9, 189, 213, 12, 13, 14, 15, 16, 20, 114, - /* 480 */ 22, 288, 104, 247, 8, 9, 148, 303, 12, 13, - /* 490 */ 14, 15, 16, 156, 8, 9, 118, 119, 12, 13, - /* 500 */ 14, 15, 16, 82, 82, 316, 322, 255, 50, 12, - /* 510 */ 13, 261, 262, 176, 177, 255, 255, 20, 266, 22, - /* 520 */ 59, 337, 338, 339, 288, 341, 266, 266, 344, 340, - /* 530 */ 12, 13, 35, 273, 273, 283, 171, 172, 20, 161, - /* 540 */ 22, 163, 358, 283, 283, 20, 362, 14, 15, 16, - /* 550 */ 8, 9, 91, 35, 12, 13, 14, 15, 16, 83, - /* 560 */ 261, 262, 65, 185, 186, 0, 188, 189, 190, 191, - /* 570 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 82, - /* 580 */ 0, 307, 160, 65, 162, 76, 21, 276, 283, 24, - /* 590 */ 25, 26, 27, 28, 29, 30, 31, 32, 275, 294, - /* 600 */ 82, 104, 8, 9, 143, 282, 12, 13, 14, 15, - /* 610 */ 16, 267, 255, 267, 291, 118, 119, 0, 247, 275, - /* 620 */ 248, 275, 104, 266, 0, 83, 56, 166, 284, 56, - /* 630 */ 284, 122, 123, 247, 213, 213, 118, 119, 58, 113, - /* 640 */ 283, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 650 */ 255, 81, 316, 39, 84, 82, 255, 84, 161, 288, - /* 660 */ 163, 266, 201, 202, 203, 204, 205, 206, 207, 208, - /* 670 */ 209, 210, 48, 148, 288, 143, 340, 83, 283, 161, - /* 680 */ 247, 163, 185, 186, 283, 188, 189, 190, 191, 192, - /* 690 */ 193, 194, 195, 196, 197, 198, 199, 200, 166, 173, - /* 700 */ 174, 276, 303, 185, 186, 0, 188, 189, 190, 191, - /* 710 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 267, - /* 720 */ 275, 288, 18, 322, 20, 18, 35, 275, 316, 284, - /* 730 */ 23, 27, 285, 201, 30, 288, 284, 3, 337, 338, - /* 740 */ 339, 94, 341, 344, 37, 38, 275, 247, 41, 0, - /* 750 */ 290, 47, 340, 49, 244, 51, 65, 358, 20, 255, - /* 760 */ 300, 362, 291, 116, 57, 43, 61, 62, 63, 64, - /* 770 */ 266, 66, 67, 68, 69, 70, 71, 72, 73, 74, - /* 780 */ 75, 76, 77, 78, 79, 81, 213, 283, 288, 82, - /* 790 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - /* 800 */ 105, 0, 107, 108, 109, 110, 111, 112, 0, 285, - /* 810 */ 61, 62, 288, 303, 303, 66, 276, 268, 69, 70, - /* 820 */ 271, 276, 73, 74, 75, 121, 212, 120, 124, 125, - /* 830 */ 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - /* 840 */ 136, 137, 138, 139, 140, 141, 44, 45, 255, 20, - /* 850 */ 276, 247, 247, 255, 344, 344, 247, 12, 13, 266, - /* 860 */ 153, 154, 155, 247, 266, 158, 255, 22, 358, 358, - /* 870 */ 247, 164, 362, 362, 4, 255, 283, 266, 247, 0, - /* 880 */ 35, 283, 175, 211, 212, 178, 266, 180, 181, 182, - /* 890 */ 183, 184, 288, 288, 283, 94, 247, 288, 275, 247, - /* 900 */ 43, 22, 94, 283, 288, 86, 283, 264, 89, 247, - /* 910 */ 65, 288, 247, 290, 113, 114, 115, 116, 117, 288, - /* 920 */ 213, 113, 114, 115, 116, 117, 303, 189, 247, 247, - /* 930 */ 247, 56, 247, 247, 148, 149, 86, 288, 315, 89, - /* 940 */ 288, 318, 319, 320, 321, 322, 323, 4, 325, 104, - /* 950 */ 288, 328, 255, 288, 232, 332, 333, 275, 86, 84, - /* 960 */ 59, 89, 19, 266, 230, 283, 0, 344, 255, 288, - /* 970 */ 288, 288, 290, 288, 288, 277, 33, 148, 280, 266, - /* 980 */ 283, 358, 1, 2, 86, 362, 288, 89, 22, 35, - /* 990 */ 47, 43, 247, 276, 51, 0, 283, 315, 255, 56, - /* 1000 */ 318, 319, 320, 321, 322, 323, 161, 325, 163, 266, - /* 1010 */ 328, 255, 314, 315, 332, 333, 334, 22, 43, 43, - /* 1020 */ 275, 43, 266, 325, 81, 343, 283, 84, 283, 255, - /* 1030 */ 185, 83, 43, 288, 82, 290, 118, 119, 46, 283, - /* 1040 */ 266, 196, 197, 198, 92, 43, 35, 43, 356, 365, - /* 1050 */ 43, 256, 43, 247, 351, 43, 275, 283, 83, 83, - /* 1060 */ 315, 83, 43, 318, 319, 320, 321, 322, 323, 35, - /* 1070 */ 325, 311, 83, 328, 82, 247, 256, 332, 333, 334, - /* 1080 */ 43, 275, 43, 43, 214, 83, 185, 83, 343, 283, - /* 1090 */ 83, 234, 83, 254, 288, 83, 290, 43, 287, 65, - /* 1100 */ 317, 43, 83, 275, 342, 359, 359, 359, 345, 215, - /* 1110 */ 313, 283, 20, 255, 47, 312, 288, 163, 290, 35, - /* 1120 */ 83, 315, 83, 83, 318, 319, 320, 321, 322, 323, - /* 1130 */ 261, 325, 159, 255, 328, 305, 247, 83, 332, 333, - /* 1140 */ 255, 83, 42, 315, 295, 293, 318, 319, 320, 321, - /* 1150 */ 322, 323, 293, 325, 255, 20, 328, 143, 249, 249, - /* 1160 */ 332, 333, 334, 20, 275, 309, 259, 290, 20, 302, - /* 1170 */ 259, 343, 283, 20, 163, 304, 259, 288, 302, 290, - /* 1180 */ 259, 20, 296, 259, 259, 255, 259, 249, 275, 247, - /* 1190 */ 275, 275, 303, 288, 275, 275, 249, 275, 275, 255, - /* 1200 */ 288, 275, 309, 247, 315, 169, 275, 318, 319, 320, - /* 1210 */ 321, 322, 323, 255, 325, 275, 275, 275, 257, 290, - /* 1220 */ 257, 257, 308, 255, 288, 283, 20, 221, 227, 152, - /* 1230 */ 288, 275, 290, 344, 302, 220, 299, 350, 288, 283, - /* 1240 */ 350, 288, 350, 288, 288, 303, 290, 358, 299, 353, - /* 1250 */ 317, 362, 352, 229, 348, 247, 228, 315, 216, 313, - /* 1260 */ 318, 319, 320, 321, 322, 323, 283, 325, 212, 20, - /* 1270 */ 42, 315, 231, 247, 318, 319, 320, 321, 322, 323, - /* 1280 */ 233, 325, 347, 275, 328, 316, 344, 236, 332, 333, - /* 1290 */ 82, 283, 335, 299, 349, 361, 288, 299, 290, 360, - /* 1300 */ 358, 275, 331, 145, 362, 288, 288, 297, 288, 283, - /* 1310 */ 283, 82, 296, 283, 288, 271, 290, 366, 257, 257, - /* 1320 */ 361, 361, 360, 315, 279, 247, 318, 319, 320, 321, - /* 1330 */ 322, 323, 324, 325, 326, 327, 288, 360, 265, 257, - /* 1340 */ 255, 315, 247, 36, 318, 319, 320, 321, 322, 323, - /* 1350 */ 249, 325, 250, 275, 258, 306, 310, 269, 269, 269, - /* 1360 */ 245, 283, 0, 0, 42, 0, 288, 73, 290, 0, - /* 1370 */ 275, 35, 179, 35, 35, 35, 179, 0, 283, 35, - /* 1380 */ 35, 179, 0, 288, 179, 290, 0, 35, 0, 363, - /* 1390 */ 364, 247, 22, 315, 0, 35, 318, 319, 320, 321, - /* 1400 */ 322, 323, 0, 325, 166, 82, 328, 165, 163, 161, - /* 1410 */ 315, 333, 0, 318, 319, 320, 321, 322, 323, 275, - /* 1420 */ 325, 0, 157, 156, 0, 0, 46, 283, 0, 142, - /* 1430 */ 0, 0, 288, 0, 290, 0, 0, 137, 35, 0, - /* 1440 */ 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 1450 */ 0, 247, 357, 0, 0, 0, 0, 42, 0, 315, - /* 1460 */ 247, 42, 318, 319, 320, 321, 322, 323, 39, 325, - /* 1470 */ 0, 0, 0, 0, 0, 0, 8, 9, 0, 275, - /* 1480 */ 12, 13, 14, 15, 16, 22, 0, 283, 275, 0, - /* 1490 */ 0, 0, 288, 14, 290, 14, 283, 46, 0, 40, - /* 1500 */ 43, 288, 0, 290, 39, 301, 46, 0, 364, 247, - /* 1510 */ 152, 0, 0, 0, 0, 39, 0, 0, 35, 315, - /* 1520 */ 0, 247, 318, 319, 320, 321, 322, 323, 315, 325, - /* 1530 */ 35, 318, 319, 320, 321, 322, 323, 275, 325, 47, - /* 1540 */ 327, 47, 60, 39, 39, 283, 0, 47, 39, 275, - /* 1550 */ 288, 0, 290, 35, 35, 47, 0, 283, 0, 0, - /* 1560 */ 39, 0, 288, 301, 290, 35, 22, 0, 91, 89, - /* 1570 */ 35, 35, 19, 35, 247, 301, 35, 315, 35, 0, - /* 1580 */ 318, 319, 320, 321, 322, 323, 33, 325, 43, 315, - /* 1590 */ 247, 43, 318, 319, 320, 321, 322, 323, 35, 325, - /* 1600 */ 47, 35, 275, 22, 0, 52, 53, 54, 55, 56, - /* 1610 */ 283, 22, 0, 49, 22, 288, 0, 290, 275, 35, - /* 1620 */ 35, 153, 0, 35, 0, 22, 283, 20, 0, 35, - /* 1630 */ 0, 288, 148, 290, 81, 22, 167, 84, 150, 247, - /* 1640 */ 0, 148, 315, 0, 145, 318, 319, 320, 321, 322, - /* 1650 */ 323, 148, 325, 0, 0, 0, 82, 43, 315, 83, - /* 1660 */ 43, 318, 319, 320, 321, 322, 323, 275, 325, 83, - /* 1670 */ 117, 46, 82, 82, 43, 283, 83, 82, 82, 217, - /* 1680 */ 288, 83, 290, 46, 43, 43, 2, 82, 43, 83, - /* 1690 */ 46, 83, 46, 83, 43, 35, 35, 35, 211, 247, - /* 1700 */ 147, 83, 217, 235, 35, 35, 35, 315, 247, 185, - /* 1710 */ 318, 319, 320, 321, 322, 323, 43, 325, 217, 83, - /* 1720 */ 46, 168, 83, 170, 46, 22, 187, 275, 146, 82, - /* 1730 */ 82, 82, 0, 39, 82, 283, 275, 46, 46, 83, - /* 1740 */ 288, 83, 290, 144, 283, 82, 22, 82, 82, 288, - /* 1750 */ 82, 290, 93, 35, 82, 35, 35, 247, 83, 92, - /* 1760 */ 83, 82, 82, 82, 35, 83, 83, 315, 82, 247, - /* 1770 */ 318, 319, 320, 321, 322, 323, 315, 325, 82, 318, - /* 1780 */ 319, 320, 321, 322, 323, 275, 325, 83, 35, 82, - /* 1790 */ 35, 83, 82, 283, 106, 106, 106, 275, 288, 106, - /* 1800 */ 290, 22, 35, 94, 82, 283, 43, 82, 82, 22, - /* 1810 */ 288, 60, 290, 59, 65, 35, 80, 43, 35, 35, - /* 1820 */ 247, 35, 22, 35, 35, 315, 35, 35, 318, 319, - /* 1830 */ 320, 321, 322, 323, 247, 325, 65, 315, 35, 35, - /* 1840 */ 318, 319, 320, 321, 322, 323, 35, 325, 275, 35, - /* 1850 */ 35, 35, 35, 0, 35, 47, 283, 39, 0, 35, - /* 1860 */ 47, 288, 275, 290, 39, 0, 35, 47, 39, 0, - /* 1870 */ 283, 35, 39, 47, 0, 288, 35, 290, 35, 0, - /* 1880 */ 20, 22, 21, 367, 22, 247, 22, 21, 315, 367, - /* 1890 */ 367, 318, 319, 320, 321, 322, 323, 247, 325, 367, - /* 1900 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, - /* 1910 */ 323, 247, 325, 275, 367, 367, 367, 367, 367, 367, - /* 1920 */ 367, 283, 367, 367, 367, 275, 288, 367, 290, 367, - /* 1930 */ 367, 367, 367, 283, 367, 367, 367, 367, 288, 275, - /* 1940 */ 290, 367, 367, 367, 367, 367, 367, 283, 367, 367, - /* 1950 */ 367, 367, 288, 315, 290, 367, 318, 319, 320, 321, - /* 1960 */ 322, 323, 247, 325, 367, 315, 367, 367, 318, 319, - /* 1970 */ 320, 321, 322, 323, 367, 325, 367, 367, 367, 315, - /* 1980 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, - /* 1990 */ 275, 367, 367, 367, 367, 367, 367, 367, 283, 367, - /* 2000 */ 367, 367, 367, 288, 367, 290, 367, 367, 367, 367, - /* 2010 */ 367, 367, 367, 367, 367, 367, 275, 367, 367, 367, - /* 2020 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, - /* 2030 */ 315, 290, 367, 318, 319, 320, 321, 322, 323, 367, - /* 2040 */ 325, 247, 367, 367, 367, 367, 367, 367, 367, 367, - /* 2050 */ 367, 367, 367, 247, 367, 367, 315, 367, 367, 318, - /* 2060 */ 319, 320, 321, 322, 323, 367, 325, 367, 367, 275, - /* 2070 */ 367, 367, 367, 367, 367, 367, 367, 283, 367, 367, - /* 2080 */ 367, 275, 288, 367, 290, 367, 367, 367, 367, 283, - /* 2090 */ 367, 367, 367, 367, 288, 367, 290, 367, 367, 367, - /* 2100 */ 367, 367, 367, 367, 247, 367, 367, 367, 367, 315, - /* 2110 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, - /* 2120 */ 367, 315, 367, 367, 318, 319, 320, 321, 322, 323, - /* 2130 */ 367, 325, 275, 367, 367, 367, 367, 367, 367, 367, - /* 2140 */ 283, 367, 367, 367, 367, 288, 275, 290, 367, 367, - /* 2150 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, - /* 2160 */ 367, 290, 367, 367, 367, 367, 367, 367, 367, 247, - /* 2170 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, - /* 2180 */ 323, 247, 325, 367, 367, 367, 315, 367, 367, 318, - /* 2190 */ 319, 320, 321, 322, 323, 367, 325, 275, 367, 367, - /* 2200 */ 367, 367, 367, 367, 367, 283, 367, 367, 367, 275, - /* 2210 */ 288, 367, 290, 367, 367, 367, 367, 283, 367, 367, - /* 2220 */ 367, 367, 288, 367, 290, 367, 367, 367, 367, 367, - /* 2230 */ 367, 367, 367, 367, 367, 367, 367, 315, 367, 367, - /* 2240 */ 318, 319, 320, 321, 322, 323, 367, 325, 367, 315, - /* 2250 */ 367, 367, 318, 319, 320, 321, 322, 323, 367, 325, + /* 200 */ 200, 201, 202, 191, 168, 56, 325, 18, 319, 20, + /* 210 */ 12, 13, 14, 15, 16, 215, 27, 0, 65, 30, + /* 220 */ 339, 340, 341, 342, 257, 344, 163, 290, 165, 163, + /* 230 */ 81, 165, 343, 84, 187, 268, 47, 191, 49, 203, + /* 240 */ 51, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 250 */ 187, 188, 285, 187, 188, 215, 190, 191, 192, 193, + /* 260 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 215, + /* 270 */ 81, 224, 225, 226, 227, 228, 8, 9, 12, 13, + /* 280 */ 12, 13, 14, 15, 16, 20, 20, 265, 22, 267, + /* 290 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + /* 300 */ 105, 35, 107, 108, 109, 110, 111, 112, 1, 2, + /* 310 */ 121, 43, 20, 124, 125, 126, 127, 128, 129, 130, + /* 320 */ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + /* 330 */ 141, 65, 143, 144, 12, 13, 249, 20, 37, 332, + /* 340 */ 333, 20, 20, 22, 22, 8, 9, 56, 82, 12, + /* 350 */ 13, 14, 15, 16, 61, 62, 35, 35, 279, 66, + /* 360 */ 4, 20, 69, 70, 277, 257, 73, 74, 75, 290, + /* 370 */ 104, 50, 285, 82, 82, 84, 268, 290, 93, 292, + /* 380 */ 234, 59, 311, 275, 118, 119, 85, 65, 87, 88, + /* 390 */ 83, 90, 76, 285, 307, 94, 317, 318, 148, 4, + /* 400 */ 44, 45, 347, 249, 82, 318, 250, 328, 321, 322, + /* 410 */ 323, 324, 325, 326, 19, 328, 361, 116, 331, 257, + /* 420 */ 365, 257, 335, 336, 259, 292, 104, 0, 33, 163, + /* 430 */ 268, 165, 268, 300, 347, 65, 303, 272, 122, 123, + /* 440 */ 118, 119, 47, 249, 290, 280, 51, 285, 361, 285, + /* 450 */ 307, 56, 365, 187, 188, 278, 190, 191, 192, 193, + /* 460 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 269, + /* 470 */ 220, 221, 12, 13, 14, 254, 81, 277, 257, 84, + /* 480 */ 20, 215, 22, 257, 290, 163, 286, 165, 61, 62, + /* 490 */ 347, 150, 155, 66, 268, 35, 69, 70, 257, 266, + /* 500 */ 73, 74, 75, 257, 361, 3, 215, 215, 365, 187, + /* 510 */ 188, 285, 190, 191, 192, 193, 194, 195, 196, 197, + /* 520 */ 198, 199, 200, 201, 202, 65, 285, 12, 13, 291, + /* 530 */ 292, 285, 257, 158, 20, 20, 249, 22, 44, 45, + /* 540 */ 8, 9, 82, 268, 12, 13, 14, 15, 16, 114, + /* 550 */ 35, 8, 9, 178, 179, 12, 13, 14, 15, 16, + /* 560 */ 285, 257, 254, 249, 104, 257, 325, 269, 20, 249, + /* 570 */ 22, 325, 268, 302, 237, 277, 305, 290, 118, 119, + /* 580 */ 65, 340, 341, 342, 286, 344, 340, 341, 342, 285, + /* 590 */ 344, 277, 94, 12, 13, 368, 257, 82, 50, 285, + /* 600 */ 249, 20, 249, 22, 290, 94, 292, 268, 173, 174, + /* 610 */ 290, 113, 114, 115, 116, 117, 35, 257, 304, 104, + /* 620 */ 263, 264, 0, 163, 285, 165, 83, 116, 268, 14, + /* 630 */ 15, 16, 318, 118, 119, 321, 322, 323, 324, 325, + /* 640 */ 326, 290, 328, 290, 22, 285, 65, 187, 188, 35, + /* 650 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + /* 660 */ 200, 201, 202, 82, 150, 257, 257, 8, 9, 20, + /* 670 */ 257, 12, 13, 14, 15, 16, 268, 268, 163, 65, + /* 680 */ 165, 268, 8, 9, 285, 104, 12, 13, 14, 15, + /* 690 */ 16, 263, 264, 285, 285, 296, 213, 214, 285, 118, + /* 700 */ 119, 0, 187, 188, 278, 190, 191, 192, 193, 194, + /* 710 */ 195, 196, 197, 198, 199, 200, 201, 202, 59, 82, + /* 720 */ 257, 8, 9, 19, 269, 12, 13, 14, 15, 16, + /* 730 */ 278, 268, 277, 59, 232, 278, 277, 33, 257, 0, + /* 740 */ 21, 286, 83, 284, 163, 249, 165, 277, 285, 268, + /* 750 */ 91, 47, 293, 34, 284, 36, 52, 53, 54, 55, + /* 760 */ 56, 113, 249, 293, 0, 91, 285, 249, 187, 188, + /* 770 */ 249, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 780 */ 199, 200, 201, 202, 277, 81, 290, 18, 84, 292, + /* 790 */ 277, 249, 23, 286, 4, 94, 83, 58, 285, 162, + /* 800 */ 303, 164, 257, 290, 145, 292, 37, 38, 290, 319, + /* 810 */ 41, 290, 278, 268, 113, 114, 115, 116, 117, 145, + /* 820 */ 249, 117, 58, 175, 176, 302, 57, 168, 305, 277, + /* 830 */ 285, 318, 290, 343, 321, 322, 323, 324, 325, 326, + /* 840 */ 191, 328, 168, 0, 331, 293, 249, 249, 335, 336, + /* 850 */ 337, 82, 215, 149, 259, 0, 39, 278, 249, 346, + /* 860 */ 249, 290, 203, 204, 205, 206, 207, 208, 209, 210, + /* 870 */ 211, 212, 113, 114, 170, 280, 172, 203, 204, 205, + /* 880 */ 206, 207, 208, 209, 210, 211, 212, 290, 290, 120, + /* 890 */ 8, 9, 359, 249, 12, 13, 14, 15, 16, 290, + /* 900 */ 249, 290, 47, 249, 61, 62, 63, 64, 319, 66, + /* 910 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + /* 920 */ 77, 78, 79, 43, 155, 156, 157, 249, 277, 160, + /* 930 */ 56, 59, 343, 174, 290, 166, 285, 12, 13, 287, + /* 940 */ 43, 290, 290, 292, 290, 287, 177, 22, 290, 180, + /* 950 */ 35, 182, 183, 184, 185, 186, 270, 258, 84, 273, + /* 960 */ 35, 249, 86, 83, 86, 89, 354, 89, 290, 318, + /* 970 */ 0, 0, 321, 322, 323, 324, 325, 326, 86, 328, + /* 980 */ 86, 89, 331, 89, 215, 0, 335, 336, 337, 277, + /* 990 */ 65, 150, 151, 22, 1, 2, 35, 285, 314, 43, + /* 1000 */ 349, 277, 290, 82, 292, 2, 216, 22, 357, 358, + /* 1010 */ 46, 8, 9, 92, 2, 12, 13, 14, 15, 16, + /* 1020 */ 8, 9, 249, 258, 12, 13, 14, 15, 16, 104, + /* 1030 */ 318, 214, 150, 321, 322, 323, 324, 325, 326, 83, + /* 1040 */ 328, 118, 119, 331, 256, 289, 82, 335, 336, 337, + /* 1050 */ 277, 320, 43, 43, 345, 362, 362, 362, 285, 187, + /* 1060 */ 43, 217, 43, 290, 94, 292, 43, 316, 348, 20, + /* 1070 */ 358, 43, 257, 47, 43, 43, 43, 249, 315, 35, + /* 1080 */ 165, 43, 43, 113, 114, 115, 116, 117, 163, 0, + /* 1090 */ 165, 318, 83, 83, 321, 322, 323, 324, 325, 326, + /* 1100 */ 83, 328, 83, 43, 331, 277, 83, 43, 335, 336, + /* 1110 */ 337, 83, 187, 285, 83, 83, 83, 263, 290, 346, + /* 1120 */ 292, 83, 83, 198, 199, 200, 165, 161, 43, 309, + /* 1130 */ 249, 35, 257, 236, 257, 42, 297, 48, 20, 249, + /* 1140 */ 145, 295, 295, 83, 257, 20, 318, 83, 313, 321, + /* 1150 */ 322, 323, 324, 325, 326, 251, 328, 249, 277, 331, + /* 1160 */ 251, 65, 261, 335, 336, 337, 285, 277, 83, 20, + /* 1170 */ 306, 290, 261, 292, 346, 285, 292, 20, 308, 261, + /* 1180 */ 290, 261, 292, 20, 298, 277, 251, 261, 307, 306, + /* 1190 */ 261, 257, 261, 285, 277, 257, 277, 307, 290, 318, + /* 1200 */ 292, 277, 321, 322, 323, 324, 325, 326, 318, 328, + /* 1210 */ 277, 321, 322, 323, 324, 325, 326, 277, 328, 277, + /* 1220 */ 277, 277, 249, 277, 277, 277, 318, 251, 347, 321, + /* 1230 */ 322, 323, 324, 325, 326, 290, 328, 347, 249, 331, + /* 1240 */ 313, 259, 361, 335, 336, 171, 365, 249, 312, 292, + /* 1250 */ 277, 361, 20, 259, 257, 365, 257, 306, 285, 259, + /* 1260 */ 223, 320, 290, 290, 222, 292, 277, 353, 301, 290, + /* 1270 */ 301, 290, 229, 290, 285, 277, 154, 231, 356, 290, + /* 1280 */ 352, 292, 230, 285, 218, 353, 214, 285, 290, 350, + /* 1290 */ 292, 318, 355, 316, 321, 322, 323, 324, 325, 326, + /* 1300 */ 249, 328, 353, 351, 331, 20, 319, 318, 335, 336, + /* 1310 */ 321, 322, 323, 324, 325, 326, 318, 328, 42, 321, + /* 1320 */ 322, 323, 324, 325, 326, 235, 328, 364, 277, 331, + /* 1330 */ 33, 233, 238, 82, 336, 301, 285, 363, 363, 338, + /* 1340 */ 334, 290, 301, 292, 47, 290, 290, 369, 364, 52, + /* 1350 */ 53, 54, 55, 56, 249, 366, 367, 290, 290, 290, + /* 1360 */ 364, 290, 147, 249, 299, 285, 259, 363, 298, 318, + /* 1370 */ 273, 259, 321, 322, 323, 324, 325, 326, 81, 328, + /* 1380 */ 285, 84, 277, 82, 281, 257, 267, 36, 259, 290, + /* 1390 */ 285, 277, 252, 251, 310, 290, 305, 292, 271, 285, + /* 1400 */ 247, 271, 271, 260, 290, 0, 292, 0, 42, 0, + /* 1410 */ 73, 360, 35, 249, 0, 181, 35, 35, 304, 35, + /* 1420 */ 181, 0, 35, 318, 249, 35, 321, 322, 323, 324, + /* 1430 */ 325, 326, 318, 328, 181, 321, 322, 323, 324, 325, + /* 1440 */ 326, 277, 328, 146, 147, 0, 149, 181, 0, 285, + /* 1450 */ 153, 35, 277, 0, 290, 22, 292, 0, 35, 0, + /* 1460 */ 285, 82, 168, 167, 165, 290, 163, 292, 0, 172, + /* 1470 */ 0, 159, 367, 158, 0, 0, 249, 46, 0, 304, + /* 1480 */ 0, 0, 318, 142, 0, 321, 322, 323, 324, 325, + /* 1490 */ 326, 0, 328, 318, 330, 0, 321, 322, 323, 324, + /* 1500 */ 325, 326, 0, 328, 277, 0, 137, 35, 0, 137, + /* 1510 */ 0, 0, 285, 0, 0, 0, 0, 290, 0, 292, + /* 1520 */ 0, 0, 0, 0, 0, 0, 0, 42, 0, 249, + /* 1530 */ 0, 304, 0, 0, 0, 0, 0, 0, 249, 22, + /* 1540 */ 0, 0, 0, 0, 43, 318, 42, 249, 321, 322, + /* 1550 */ 323, 324, 325, 326, 0, 328, 0, 277, 39, 14, + /* 1560 */ 14, 0, 0, 0, 154, 285, 277, 0, 0, 40, + /* 1570 */ 290, 0, 292, 46, 285, 277, 0, 46, 39, 290, + /* 1580 */ 0, 292, 0, 285, 0, 35, 39, 39, 290, 0, + /* 1590 */ 292, 47, 35, 0, 39, 35, 0, 0, 318, 249, + /* 1600 */ 47, 321, 322, 323, 324, 325, 326, 318, 328, 39, + /* 1610 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, + /* 1620 */ 322, 323, 324, 325, 326, 60, 328, 277, 47, 91, + /* 1630 */ 39, 22, 47, 35, 0, 285, 35, 35, 35, 35, + /* 1640 */ 290, 249, 292, 43, 0, 35, 35, 35, 89, 43, + /* 1650 */ 22, 0, 22, 0, 49, 22, 35, 0, 35, 0, + /* 1660 */ 35, 249, 0, 22, 0, 20, 35, 0, 318, 277, + /* 1670 */ 22, 321, 322, 323, 324, 325, 326, 285, 328, 0, + /* 1680 */ 0, 169, 290, 249, 292, 0, 0, 0, 219, 277, + /* 1690 */ 43, 35, 43, 43, 2, 82, 82, 285, 83, 147, + /* 1700 */ 82, 150, 290, 83, 292, 83, 82, 46, 82, 43, + /* 1710 */ 318, 277, 83, 321, 322, 323, 324, 325, 326, 285, + /* 1720 */ 328, 152, 150, 150, 290, 82, 292, 46, 219, 83, + /* 1730 */ 318, 43, 43, 321, 322, 323, 324, 325, 326, 249, + /* 1740 */ 328, 83, 46, 46, 43, 35, 83, 35, 249, 35, + /* 1750 */ 35, 83, 318, 35, 43, 321, 322, 323, 324, 325, + /* 1760 */ 326, 187, 328, 46, 22, 83, 82, 277, 46, 0, + /* 1770 */ 0, 39, 46, 83, 83, 285, 277, 213, 83, 189, + /* 1780 */ 290, 82, 292, 148, 285, 219, 82, 82, 82, 290, + /* 1790 */ 82, 292, 92, 46, 22, 82, 93, 35, 249, 83, + /* 1800 */ 146, 82, 82, 82, 106, 82, 35, 249, 318, 35, + /* 1810 */ 83, 321, 322, 323, 324, 325, 326, 318, 328, 82, + /* 1820 */ 321, 322, 323, 324, 325, 326, 277, 328, 83, 83, + /* 1830 */ 82, 35, 82, 35, 285, 277, 35, 83, 82, 290, + /* 1840 */ 83, 292, 82, 285, 106, 106, 22, 106, 290, 94, + /* 1850 */ 292, 35, 43, 22, 60, 82, 59, 249, 82, 82, + /* 1860 */ 35, 80, 43, 35, 65, 35, 249, 318, 35, 35, + /* 1870 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, + /* 1880 */ 322, 323, 324, 325, 326, 277, 328, 22, 35, 35, + /* 1890 */ 35, 65, 35, 285, 277, 35, 35, 35, 290, 35, + /* 1900 */ 292, 35, 285, 0, 35, 47, 39, 290, 0, 292, + /* 1910 */ 35, 39, 0, 35, 0, 47, 39, 47, 249, 35, + /* 1920 */ 47, 39, 0, 35, 35, 0, 318, 249, 22, 321, + /* 1930 */ 322, 323, 324, 325, 326, 318, 328, 21, 321, 322, + /* 1940 */ 323, 324, 325, 326, 21, 328, 277, 370, 22, 22, + /* 1950 */ 20, 370, 370, 370, 285, 277, 370, 370, 370, 290, + /* 1960 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 370, + /* 1970 */ 292, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 1980 */ 249, 370, 370, 370, 370, 370, 370, 318, 370, 249, + /* 1990 */ 321, 322, 323, 324, 325, 326, 318, 328, 249, 321, + /* 2000 */ 322, 323, 324, 325, 326, 370, 328, 249, 277, 370, + /* 2010 */ 257, 370, 370, 370, 370, 370, 285, 277, 370, 370, + /* 2020 */ 370, 290, 370, 292, 370, 285, 277, 370, 370, 370, + /* 2030 */ 290, 370, 292, 370, 285, 277, 370, 370, 285, 290, + /* 2040 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 318, + /* 2050 */ 292, 370, 321, 322, 323, 324, 325, 326, 318, 328, + /* 2060 */ 307, 321, 322, 323, 324, 325, 326, 318, 328, 370, + /* 2070 */ 321, 322, 323, 324, 325, 326, 318, 328, 325, 321, + /* 2080 */ 322, 323, 324, 325, 326, 249, 328, 370, 370, 370, + /* 2090 */ 370, 370, 370, 340, 341, 342, 370, 344, 370, 257, + /* 2100 */ 347, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2110 */ 370, 370, 370, 277, 361, 370, 370, 370, 365, 370, + /* 2120 */ 370, 285, 370, 370, 370, 370, 290, 285, 292, 370, + /* 2130 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2140 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 307, + /* 2150 */ 370, 370, 370, 370, 318, 370, 370, 321, 322, 323, + /* 2160 */ 324, 325, 326, 370, 328, 370, 370, 325, 370, 370, + /* 2170 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2180 */ 370, 370, 340, 341, 342, 370, 344, 370, 370, 347, + /* 2190 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2200 */ 370, 370, 370, 361, 370, 370, 370, 365, }; -#define YY_SHIFT_COUNT (644) +#define YY_SHIFT_COUNT (652) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1879) +#define YY_SHIFT_MAX (1930) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 707, 0, 0, 119, 238, 238, 238, 238, 259, 259, - /* 10 */ 238, 238, 378, 497, 518, 497, 497, 497, 497, 497, - /* 20 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, - /* 30 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, - /* 40 */ 497, 497, 421, 421, 94, 94, 94, 845, 845, 845, - /* 50 */ 845, 422, 573, 35, 16, 16, 40, 40, 4, 275, - /* 60 */ 35, 35, 16, 16, 16, 16, 16, 16, 16, 16, - /* 70 */ 47, 16, 16, 16, 131, 145, 160, 16, 16, 160, - /* 80 */ 16, 160, 160, 160, 16, 198, 704, 83, 461, 461, - /* 90 */ 306, 98, 114, 114, 114, 114, 114, 114, 114, 114, - /* 100 */ 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, - /* 110 */ 114, 167, 275, 369, 369, 408, 691, 525, 525, 525, - /* 120 */ 580, 691, 183, 145, 160, 160, 171, 171, 266, 211, - /* 130 */ 695, 695, 695, 695, 695, 695, 695, 1553, 565, 749, - /* 140 */ 1468, 42, 352, 365, 10, 221, 282, 458, 802, 647, - /* 150 */ 829, 672, 614, 672, 734, 734, 734, 870, 738, 894, - /* 160 */ 1092, 1067, 1084, 973, 1092, 1092, 1100, 1014, 1014, 1092, - /* 170 */ 1135, 1135, 1143, 47, 145, 47, 1148, 1153, 47, 1148, - /* 180 */ 47, 1161, 47, 47, 1092, 47, 1135, 160, 160, 160, - /* 190 */ 160, 160, 160, 160, 160, 160, 160, 160, 1092, 1135, - /* 200 */ 171, 171, 1143, 198, 1036, 145, 198, 1092, 1092, 1148, - /* 210 */ 198, 1206, 171, 1006, 1015, 171, 1006, 1015, 171, 171, - /* 220 */ 160, 1001, 1077, 1006, 1024, 1028, 1042, 894, 1056, 183, - /* 230 */ 1249, 1228, 1047, 1041, 1051, 1047, 1041, 1047, 1041, 1208, - /* 240 */ 1015, 171, 171, 1015, 171, 1158, 183, 1161, 198, 266, - /* 250 */ 198, 183, 1229, 171, 211, 1092, 198, 1307, 1135, 2260, - /* 260 */ 2260, 2260, 2260, 2260, 2260, 2260, 705, 178, 617, 943, - /* 270 */ 476, 231, 542, 39, 48, 338, 594, 486, 486, 486, - /* 280 */ 486, 486, 486, 486, 486, 801, 808, 348, 3, 3, - /* 290 */ 337, 570, 509, 334, 526, 180, 532, 533, 533, 533, - /* 300 */ 533, 90, 948, 819, 850, 872, 898, 879, 966, 995, - /* 310 */ 875, 786, 975, 976, 981, 918, 722, 857, 978, 901, - /* 320 */ 989, 992, 1002, 1004, 1007, 1009, 1012, 954, 1011, 1019, - /* 330 */ 1037, 1039, 1040, 1054, 1058, 952, 1034, 624, 1362, 1363, - /* 340 */ 1322, 1365, 1294, 1369, 1336, 1193, 1338, 1339, 1340, 1197, - /* 350 */ 1377, 1344, 1345, 1202, 1382, 1205, 1386, 1352, 1388, 1370, - /* 360 */ 1394, 1360, 1402, 1323, 1238, 1242, 1245, 1248, 1412, 1421, - /* 370 */ 1265, 1267, 1424, 1425, 1380, 1428, 1287, 1430, 1431, 1433, - /* 380 */ 1435, 1436, 1300, 1403, 1439, 1303, 1441, 1442, 1443, 1444, - /* 390 */ 1445, 1446, 1447, 1448, 1449, 1450, 1453, 1454, 1455, 1456, - /* 400 */ 1415, 1458, 1470, 1471, 1472, 1473, 1474, 1463, 1475, 1478, - /* 410 */ 1486, 1489, 1490, 1491, 1419, 1429, 1457, 1479, 1451, 1481, - /* 420 */ 1460, 1498, 1459, 1465, 1502, 1507, 1520, 1476, 1358, 1511, - /* 430 */ 1512, 1513, 1482, 1514, 1516, 1483, 1492, 1504, 1517, 1495, - /* 440 */ 1494, 1505, 1546, 1518, 1500, 1509, 1551, 1519, 1508, 1521, - /* 450 */ 1556, 1558, 1559, 1561, 1477, 1480, 1530, 1544, 1567, 1535, - /* 460 */ 1536, 1538, 1541, 1545, 1548, 1543, 1563, 1566, 1579, 1581, - /* 470 */ 1604, 1589, 1564, 1612, 1592, 1584, 1616, 1585, 1622, 1588, - /* 480 */ 1624, 1603, 1607, 1628, 1484, 1594, 1630, 1469, 1613, 1493, - /* 490 */ 1499, 1640, 1643, 1503, 1488, 1653, 1654, 1655, 1614, 1617, - /* 500 */ 1462, 1574, 1576, 1590, 1586, 1631, 1593, 1591, 1595, 1596, - /* 510 */ 1598, 1641, 1625, 1637, 1605, 1642, 1485, 1606, 1608, 1644, - /* 520 */ 1487, 1645, 1646, 1610, 1651, 1501, 1618, 1660, 1661, 1662, - /* 530 */ 1669, 1670, 1671, 1618, 1684, 1524, 1673, 1636, 1647, 1639, - /* 540 */ 1674, 1648, 1649, 1678, 1703, 1539, 1652, 1656, 1658, 1663, - /* 550 */ 1665, 1582, 1666, 1732, 1694, 1599, 1668, 1667, 1691, 1692, - /* 560 */ 1672, 1675, 1679, 1724, 1680, 1659, 1677, 1718, 1720, 1681, - /* 570 */ 1682, 1721, 1686, 1683, 1729, 1696, 1704, 1753, 1707, 1708, - /* 580 */ 1755, 1710, 1688, 1689, 1690, 1693, 1779, 1709, 1722, 1725, - /* 590 */ 1767, 1726, 1763, 1763, 1787, 1751, 1754, 1780, 1749, 1736, - /* 600 */ 1774, 1783, 1784, 1786, 1788, 1789, 1800, 1791, 1792, 1771, - /* 610 */ 1545, 1803, 1548, 1804, 1811, 1814, 1815, 1816, 1817, 1853, - /* 620 */ 1819, 1808, 1818, 1858, 1824, 1813, 1825, 1865, 1831, 1820, - /* 630 */ 1829, 1869, 1836, 1826, 1833, 1874, 1841, 1843, 1879, 1859, - /* 640 */ 1861, 1862, 1864, 1866, 1860, + /* 0 */ 769, 0, 0, 66, 322, 322, 322, 322, 266, 266, + /* 10 */ 322, 322, 460, 515, 581, 515, 515, 515, 515, 515, + /* 20 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + /* 30 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + /* 40 */ 515, 515, 292, 292, 18, 18, 18, 925, 925, 925, + /* 50 */ 925, 637, 291, 40, 51, 51, 356, 356, 54, 64, + /* 60 */ 40, 40, 51, 51, 51, 51, 51, 51, 51, 51, + /* 70 */ 33, 51, 51, 51, 85, 104, 265, 51, 51, 265, + /* 80 */ 51, 265, 265, 265, 51, 111, 189, 659, 674, 674, + /* 90 */ 128, 293, 63, 63, 63, 63, 63, 63, 63, 63, + /* 100 */ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + /* 110 */ 63, 301, 64, 67, 67, 739, 614, 341, 341, 341, + /* 120 */ 764, 614, 317, 104, 1, 1, 265, 265, 153, 153, + /* 130 */ 285, 370, 195, 195, 195, 195, 195, 195, 195, 704, + /* 140 */ 21, 427, 337, 47, 321, 435, 250, 12, 46, 548, + /* 150 */ 494, 511, 514, 483, 817, 483, 502, 502, 502, 790, + /* 160 */ 649, 844, 1049, 1026, 1044, 966, 1049, 1049, 1093, 995, + /* 170 */ 995, 1049, 1118, 1118, 1125, 33, 104, 33, 1149, 1157, + /* 180 */ 33, 1149, 33, 1163, 33, 33, 1049, 33, 1118, 265, + /* 190 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + /* 200 */ 1049, 1118, 153, 1125, 111, 1074, 104, 111, 1049, 1049, + /* 210 */ 1149, 111, 1232, 153, 1037, 1042, 153, 1037, 1042, 153, + /* 220 */ 153, 265, 1043, 1122, 1037, 1046, 1052, 1066, 844, 1072, + /* 230 */ 317, 1285, 1276, 1090, 1098, 1094, 1090, 1098, 1090, 1098, + /* 240 */ 1251, 1042, 153, 153, 153, 153, 153, 1042, 153, 1215, + /* 250 */ 317, 1163, 111, 285, 111, 317, 1301, 153, 370, 1049, + /* 260 */ 111, 1351, 1118, 2208, 2208, 2208, 2208, 2208, 2208, 2208, + /* 270 */ 843, 1297, 217, 395, 81, 268, 543, 1003, 1012, 882, + /* 280 */ 713, 532, 532, 532, 532, 532, 532, 532, 532, 701, + /* 290 */ 970, 498, 198, 198, 375, 149, 316, 719, 307, 36, + /* 300 */ 615, 615, 615, 615, 648, 759, 855, 880, 876, 878, + /* 310 */ 892, 894, 622, 971, 985, 874, 841, 956, 1009, 993, + /* 320 */ 923, 146, 897, 1010, 872, 1017, 964, 1019, 1023, 1028, + /* 330 */ 1031, 1032, 915, 961, 1033, 1038, 1039, 1060, 1064, 1085, + /* 340 */ 921, 1096, 1089, 1405, 1407, 1366, 1409, 1337, 1414, 1377, + /* 350 */ 1234, 1381, 1382, 1384, 1239, 1421, 1387, 1390, 1253, 1445, + /* 360 */ 1266, 1448, 1416, 1453, 1433, 1457, 1423, 1459, 1379, 1294, + /* 370 */ 1296, 1299, 1303, 1468, 1470, 1312, 1315, 1474, 1475, 1431, + /* 380 */ 1478, 1480, 1481, 1341, 1484, 1491, 1495, 1502, 1505, 1369, + /* 390 */ 1472, 1508, 1372, 1510, 1511, 1513, 1514, 1515, 1516, 1518, + /* 400 */ 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1485, 1528, 1530, + /* 410 */ 1532, 1533, 1534, 1535, 1517, 1536, 1537, 1540, 1541, 1542, + /* 420 */ 1543, 1504, 1519, 1501, 1545, 1527, 1546, 1531, 1554, 1529, + /* 430 */ 1539, 1556, 1561, 1562, 1547, 1410, 1563, 1567, 1568, 1565, + /* 440 */ 1571, 1576, 1550, 1544, 1548, 1580, 1557, 1553, 1555, 1582, + /* 450 */ 1560, 1581, 1570, 1584, 1583, 1585, 1591, 1589, 1593, 1596, + /* 460 */ 1597, 1538, 1559, 1598, 1609, 1634, 1601, 1602, 1603, 1604, + /* 470 */ 1600, 1606, 1610, 1611, 1612, 1644, 1628, 1651, 1630, 1605, + /* 480 */ 1653, 1633, 1621, 1657, 1623, 1659, 1625, 1662, 1641, 1645, + /* 490 */ 1664, 1551, 1631, 1667, 1512, 1648, 1572, 1552, 1679, 1680, + /* 500 */ 1573, 1569, 1685, 1686, 1687, 1647, 1649, 1469, 1613, 1615, + /* 510 */ 1614, 1620, 1650, 1622, 1618, 1624, 1626, 1629, 1666, 1661, + /* 520 */ 1681, 1643, 1688, 1509, 1646, 1658, 1696, 1564, 1689, 1697, + /* 530 */ 1663, 1701, 1566, 1668, 1656, 1710, 1712, 1714, 1715, 1718, + /* 540 */ 1668, 1692, 1574, 1711, 1682, 1684, 1690, 1717, 1699, 1704, + /* 550 */ 1722, 1742, 1590, 1705, 1691, 1695, 1706, 1769, 1708, 1635, + /* 560 */ 1713, 1770, 1732, 1654, 1719, 1700, 1726, 1747, 1720, 1716, + /* 570 */ 1721, 1772, 1723, 1703, 1727, 1762, 1771, 1737, 1745, 1774, + /* 580 */ 1748, 1746, 1796, 1750, 1754, 1798, 1756, 1757, 1801, 1760, + /* 590 */ 1698, 1738, 1739, 1741, 1824, 1755, 1773, 1776, 1816, 1777, + /* 600 */ 1809, 1809, 1831, 1794, 1797, 1825, 1799, 1781, 1819, 1828, + /* 610 */ 1830, 1833, 1834, 1843, 1865, 1853, 1854, 1826, 1600, 1855, + /* 620 */ 1606, 1857, 1860, 1861, 1862, 1864, 1866, 1903, 1869, 1858, + /* 630 */ 1867, 1908, 1875, 1868, 1872, 1912, 1878, 1870, 1877, 1914, + /* 640 */ 1884, 1873, 1882, 1922, 1888, 1889, 1925, 1906, 1916, 1926, + /* 650 */ 1927, 1923, 1930, }; -#define YY_REDUCE_COUNT (265) -#define YY_REDUCE_MIN (-333) -#define YY_REDUCE_MAX (1934) +#define YY_REDUCE_COUNT (269) +#define YY_REDUCE_MIN (-338) +#define YY_REDUCE_MAX (1842) static const short yy_reduce_ofst[] = { - /* 0 */ 510, -175, 623, -245, -113, 682, 745, 828, 889, 942, - /* 10 */ 806, 956, 1008, 1026, 1078, 96, 1095, 1144, 1204, 1213, - /* 20 */ 1262, 1274, 1327, 1343, 1392, 1452, 1461, 1510, 1522, 1573, - /* 30 */ 1587, 1638, 1650, 1664, 1715, 1741, 1794, 1806, 1857, 1871, - /* 40 */ 1922, 1934, 23, 184, -216, 66, 401, -246, 698, 51, - /* 50 */ 81, -232, 399, 511, 260, 261, -250, -244, -333, -263, - /* 60 */ -330, -251, -131, -128, 252, 357, 395, 504, 593, 598, - /* 70 */ -235, 611, 697, 713, -217, -76, 344, 620, 743, -242, - /* 80 */ 756, 346, 323, 452, 774, -176, -39, -324, -324, -324, - /* 90 */ 127, 80, 193, 236, 371, 386, 433, 500, 604, 605, - /* 100 */ 609, 616, 631, 649, 652, 662, 665, 681, 683, 685, - /* 110 */ 686, -158, -20, 46, 157, 187, 250, 189, 336, 412, - /* 120 */ -257, 299, 305, 460, 445, 471, 447, 524, 549, 117, - /* 130 */ 149, 311, 425, 540, 545, 574, 717, 274, 372, 643, - /* 140 */ 684, 692, 795, 760, 703, 781, 781, 820, 839, 811, - /* 150 */ 783, 762, 762, 762, 746, 747, 748, 763, 781, 797, - /* 160 */ 858, 803, 869, 830, 878, 885, 849, 852, 859, 899, - /* 170 */ 909, 910, 856, 907, 877, 911, 867, 871, 917, 876, - /* 180 */ 921, 886, 924, 925, 930, 927, 938, 913, 915, 916, - /* 190 */ 919, 920, 922, 923, 926, 931, 940, 941, 944, 947, - /* 200 */ 905, 912, 893, 961, 914, 929, 963, 958, 968, 932, - /* 210 */ 964, 933, 936, 887, 937, 950, 890, 949, 953, 955, - /* 220 */ 781, 896, 900, 892, 945, 906, 935, 946, 762, 983, - /* 230 */ 969, 957, 934, 939, 951, 959, 962, 960, 977, 971, - /* 240 */ 994, 1017, 1018, 998, 1020, 1010, 1027, 1016, 1061, 1044, - /* 250 */ 1062, 1030, 1045, 1048, 1073, 1085, 1082, 1102, 1101, 1049, - /* 260 */ 1046, 1088, 1089, 1090, 1096, 1115, + /* 0 */ -235, -215, 87, 651, 712, 513, 773, 828, 881, 890, + /* 10 */ 908, 973, -150, 989, 998, 314, 1051, 1105, 1114, 1164, + /* 20 */ 1175, 1227, 1280, 1289, 1298, 1350, 1392, 1412, 1434, 1490, + /* 30 */ 1499, 1549, 1558, 1608, 1617, 1669, 1678, 1731, 1740, 1749, + /* 40 */ 1758, 1836, 1753, 1842, -119, 241, 246, -274, -254, -261, + /* 50 */ 79, -292, -224, 143, -124, 108, -253, -249, -338, -251, + /* 60 */ -218, 55, -123, -33, 162, 164, 226, 275, 304, 339, + /* 70 */ -244, 360, 408, 409, -209, 133, 200, 413, 463, 459, + /* 80 */ 481, 298, 470, 455, 545, 165, -233, 7, 7, 7, + /* 90 */ -217, -252, -63, 154, 194, 287, 320, 351, 353, 496, + /* 100 */ 518, 521, 542, 571, 597, 598, 609, 611, 644, 654, + /* 110 */ 678, -174, 238, 221, 308, -144, 357, -111, 490, 589, + /* 120 */ 595, 428, 399, 497, 271, 523, 507, 552, 652, 658, + /* 130 */ 686, 22, -259, 177, 426, 452, 457, 534, 579, 71, + /* 140 */ 156, 233, 227, 533, 699, 684, 612, 724, 724, 765, + /* 150 */ 788, 756, 731, 709, 709, 709, 693, 694, 695, 720, + /* 160 */ 724, 751, 815, 763, 854, 820, 875, 877, 839, 846, + /* 170 */ 847, 887, 904, 909, 835, 901, 884, 911, 864, 870, + /* 180 */ 918, 883, 920, 886, 926, 929, 934, 931, 935, 917, + /* 190 */ 919, 924, 933, 940, 942, 943, 944, 946, 947, 948, + /* 200 */ 938, 976, 945, 927, 982, 936, 957, 994, 997, 999, + /* 210 */ 951, 1000, 941, 972, 914, 967, 979, 932, 969, 981, + /* 220 */ 983, 724, 922, 937, 949, 928, 952, 939, 977, 709, + /* 230 */ 1002, 987, 1001, 963, 974, 978, 984, 975, 996, 1004, + /* 240 */ 1006, 1034, 1055, 1056, 1067, 1068, 1069, 1041, 1071, 1065, + /* 250 */ 1080, 1070, 1107, 1097, 1112, 1095, 1103, 1099, 1119, 1128, + /* 260 */ 1129, 1140, 1142, 1084, 1091, 1127, 1130, 1131, 1143, 1153, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 10 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 20 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 30 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 40 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 50 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 60 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 70 */ 1483, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 80 */ 1411, 1411, 1411, 1411, 1411, 1481, 1632, 1411, 1799, 1411, - /* 90 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 100 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 110 */ 1411, 1411, 1411, 1411, 1411, 1483, 1411, 1811, 1811, 1811, - /* 120 */ 1481, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1577, 1411, - /* 130 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1666, 1411, 1411, - /* 140 */ 1881, 1411, 1411, 1672, 1835, 1411, 1411, 1411, 1411, 1530, - /* 150 */ 1827, 1803, 1817, 1804, 1866, 1866, 1866, 1820, 1411, 1831, - /* 160 */ 1411, 1411, 1411, 1658, 1411, 1411, 1637, 1634, 1634, 1411, - /* 170 */ 1411, 1411, 1411, 1483, 1411, 1483, 1411, 1411, 1483, 1411, - /* 180 */ 1483, 1411, 1483, 1483, 1411, 1483, 1411, 1411, 1411, 1411, - /* 190 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 200 */ 1411, 1411, 1411, 1481, 1668, 1411, 1481, 1411, 1411, 1411, - /* 210 */ 1481, 1411, 1411, 1842, 1840, 1411, 1842, 1840, 1411, 1411, - /* 220 */ 1411, 1854, 1850, 1842, 1858, 1856, 1833, 1831, 1817, 1411, - /* 230 */ 1411, 1801, 1872, 1868, 1884, 1872, 1868, 1872, 1868, 1411, - /* 240 */ 1840, 1411, 1411, 1840, 1411, 1641, 1411, 1411, 1481, 1411, - /* 250 */ 1481, 1411, 1546, 1411, 1411, 1411, 1481, 1443, 1411, 1660, - /* 260 */ 1674, 1580, 1580, 1580, 1484, 1416, 1411, 1411, 1411, 1411, - /* 270 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1743, 1853, 1852, - /* 280 */ 1775, 1774, 1773, 1771, 1742, 1411, 1411, 1542, 1741, 1740, - /* 290 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1734, 1735, 1733, - /* 300 */ 1732, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 310 */ 1411, 1411, 1411, 1411, 1800, 1411, 1869, 1873, 1411, 1411, - /* 320 */ 1411, 1717, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 330 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 340 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 350 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 360 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 370 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 380 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 390 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 400 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 410 */ 1411, 1411, 1411, 1411, 1411, 1411, 1448, 1411, 1411, 1411, - /* 420 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 430 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 440 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 450 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 460 */ 1411, 1411, 1411, 1511, 1510, 1411, 1411, 1411, 1411, 1411, - /* 470 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 480 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 490 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1824, 1834, - /* 500 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 510 */ 1411, 1411, 1411, 1717, 1411, 1851, 1411, 1810, 1806, 1411, - /* 520 */ 1411, 1802, 1411, 1411, 1867, 1411, 1411, 1411, 1411, 1411, - /* 530 */ 1411, 1411, 1411, 1411, 1795, 1411, 1768, 1411, 1411, 1411, - /* 540 */ 1411, 1411, 1411, 1411, 1411, 1728, 1411, 1411, 1411, 1411, - /* 550 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1716, 1411, - /* 560 */ 1759, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1574, - /* 570 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 580 */ 1411, 1411, 1559, 1557, 1556, 1555, 1411, 1552, 1411, 1411, - /* 590 */ 1411, 1411, 1583, 1582, 1411, 1411, 1411, 1411, 1411, 1411, - /* 600 */ 1503, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 610 */ 1494, 1411, 1493, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 620 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 630 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 640 */ 1411, 1411, 1411, 1411, 1411, + /* 0 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 10 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 20 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 30 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 40 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 50 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 60 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 70 */ 1496, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 80 */ 1424, 1424, 1424, 1424, 1424, 1494, 1647, 1424, 1816, 1424, + /* 90 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 100 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 110 */ 1424, 1424, 1424, 1424, 1424, 1496, 1424, 1828, 1828, 1828, + /* 120 */ 1494, 1424, 1424, 1424, 1691, 1691, 1424, 1424, 1424, 1424, + /* 130 */ 1590, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1683, + /* 140 */ 1424, 1424, 1898, 1424, 1424, 1689, 1852, 1424, 1424, 1424, + /* 150 */ 1424, 1543, 1844, 1820, 1834, 1821, 1883, 1883, 1883, 1837, + /* 160 */ 1424, 1848, 1424, 1424, 1424, 1675, 1424, 1424, 1652, 1649, + /* 170 */ 1649, 1424, 1424, 1424, 1424, 1496, 1424, 1496, 1424, 1424, + /* 180 */ 1496, 1424, 1496, 1424, 1496, 1496, 1424, 1496, 1424, 1424, + /* 190 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 200 */ 1424, 1424, 1424, 1424, 1494, 1685, 1424, 1494, 1424, 1424, + /* 210 */ 1424, 1494, 1424, 1424, 1859, 1857, 1424, 1859, 1857, 1424, + /* 220 */ 1424, 1424, 1871, 1867, 1859, 1875, 1873, 1850, 1848, 1834, + /* 230 */ 1424, 1424, 1818, 1889, 1885, 1901, 1889, 1885, 1889, 1885, + /* 240 */ 1424, 1857, 1424, 1424, 1424, 1424, 1424, 1857, 1424, 1424, + /* 250 */ 1424, 1424, 1494, 1424, 1494, 1424, 1559, 1424, 1424, 1424, + /* 260 */ 1494, 1456, 1424, 1677, 1691, 1593, 1593, 1593, 1497, 1429, + /* 270 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 280 */ 1424, 1760, 1870, 1869, 1792, 1791, 1790, 1788, 1759, 1424, + /* 290 */ 1424, 1555, 1758, 1757, 1424, 1424, 1424, 1424, 1424, 1424, + /* 300 */ 1751, 1752, 1750, 1749, 1424, 1424, 1424, 1424, 1424, 1424, + /* 310 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1817, + /* 320 */ 1424, 1886, 1890, 1424, 1424, 1424, 1734, 1424, 1424, 1424, + /* 330 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 340 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 350 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 360 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 370 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 380 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 390 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 400 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 410 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 420 */ 1424, 1424, 1424, 1461, 1424, 1424, 1424, 1424, 1424, 1424, + /* 430 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 440 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 450 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 460 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 470 */ 1524, 1523, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 480 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 490 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 500 */ 1424, 1424, 1424, 1424, 1424, 1841, 1851, 1424, 1424, 1424, + /* 510 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 520 */ 1734, 1424, 1868, 1424, 1827, 1823, 1424, 1424, 1819, 1424, + /* 530 */ 1424, 1884, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 540 */ 1424, 1812, 1424, 1785, 1424, 1424, 1424, 1424, 1424, 1424, + /* 550 */ 1424, 1424, 1745, 1424, 1424, 1424, 1424, 1695, 1424, 1424, + /* 560 */ 1424, 1424, 1424, 1424, 1424, 1424, 1733, 1424, 1776, 1424, + /* 570 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1587, 1424, 1424, + /* 580 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 590 */ 1572, 1570, 1569, 1568, 1424, 1565, 1424, 1424, 1424, 1424, + /* 600 */ 1596, 1595, 1424, 1424, 1424, 1424, 1424, 1424, 1516, 1424, + /* 610 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1507, 1424, + /* 620 */ 1506, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 630 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 640 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 650 */ 1424, 1424, 1424, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1003,6 +995,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* CLUSTER => nothing */ 0, /* TRANSACTIONS => nothing */ 0, /* DISTRIBUTED => nothing */ + 0, /* CONSUMERS => nothing */ + 0, /* SUBSCRIPTIONS => nothing */ 0, /* LIKE => nothing */ 0, /* INDEX => nothing */ 0, /* FUNCTION => nothing */ @@ -1098,12 +1092,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 237, /* NK_BITNOT => ID */ - 237, /* INSERT => ID */ - 237, /* VALUES => ID */ - 237, /* IMPORT => ID */ - 237, /* NK_SEMI => ID */ - 237, /* FILE => ID */ + 239, /* NK_BITNOT => ID */ + 239, /* INSERT => ID */ + 239, /* VALUES => ID */ + 239, /* IMPORT => ID */ + 239, /* NK_SEMI => ID */ + 239, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1334,230 +1328,233 @@ static const char *const yyTokenName[] = { /* 140 */ "CLUSTER", /* 141 */ "TRANSACTIONS", /* 142 */ "DISTRIBUTED", - /* 143 */ "LIKE", - /* 144 */ "INDEX", - /* 145 */ "FUNCTION", - /* 146 */ "INTERVAL", - /* 147 */ "TOPIC", - /* 148 */ "AS", - /* 149 */ "WITH", - /* 150 */ "META", - /* 151 */ "CONSUMER", - /* 152 */ "GROUP", - /* 153 */ "DESC", - /* 154 */ "DESCRIBE", - /* 155 */ "RESET", - /* 156 */ "QUERY", - /* 157 */ "CACHE", - /* 158 */ "EXPLAIN", - /* 159 */ "ANALYZE", - /* 160 */ "VERBOSE", - /* 161 */ "NK_BOOL", - /* 162 */ "RATIO", - /* 163 */ "NK_FLOAT", - /* 164 */ "COMPACT", - /* 165 */ "VNODES", - /* 166 */ "IN", - /* 167 */ "OUTPUTTYPE", - /* 168 */ "AGGREGATE", - /* 169 */ "BUFSIZE", - /* 170 */ "STREAM", - /* 171 */ "INTO", - /* 172 */ "TRIGGER", - /* 173 */ "AT_ONCE", - /* 174 */ "WINDOW_CLOSE", - /* 175 */ "KILL", - /* 176 */ "CONNECTION", - /* 177 */ "TRANSACTION", - /* 178 */ "BALANCE", - /* 179 */ "VGROUP", - /* 180 */ "MERGE", - /* 181 */ "REDISTRIBUTE", - /* 182 */ "SPLIT", - /* 183 */ "SYNCDB", - /* 184 */ "DELETE", - /* 185 */ "NULL", - /* 186 */ "NK_QUESTION", - /* 187 */ "NK_ARROW", - /* 188 */ "ROWTS", - /* 189 */ "TBNAME", - /* 190 */ "QSTARTTS", - /* 191 */ "QENDTS", - /* 192 */ "WSTARTTS", - /* 193 */ "WENDTS", - /* 194 */ "WDURATION", - /* 195 */ "CAST", - /* 196 */ "NOW", - /* 197 */ "TODAY", - /* 198 */ "TIMEZONE", - /* 199 */ "COUNT", - /* 200 */ "LAST_ROW", - /* 201 */ "BETWEEN", - /* 202 */ "IS", - /* 203 */ "NK_LT", - /* 204 */ "NK_GT", - /* 205 */ "NK_LE", - /* 206 */ "NK_GE", - /* 207 */ "NK_NE", - /* 208 */ "MATCH", - /* 209 */ "NMATCH", - /* 210 */ "CONTAINS", - /* 211 */ "JOIN", - /* 212 */ "INNER", - /* 213 */ "SELECT", - /* 214 */ "DISTINCT", - /* 215 */ "WHERE", - /* 216 */ "PARTITION", - /* 217 */ "BY", - /* 218 */ "SESSION", - /* 219 */ "STATE_WINDOW", - /* 220 */ "SLIDING", - /* 221 */ "FILL", - /* 222 */ "VALUE", - /* 223 */ "NONE", - /* 224 */ "PREV", - /* 225 */ "LINEAR", - /* 226 */ "NEXT", - /* 227 */ "HAVING", - /* 228 */ "RANGE", - /* 229 */ "EVERY", - /* 230 */ "ORDER", - /* 231 */ "SLIMIT", - /* 232 */ "SOFFSET", - /* 233 */ "LIMIT", - /* 234 */ "OFFSET", - /* 235 */ "ASC", - /* 236 */ "NULLS", - /* 237 */ "ID", - /* 238 */ "NK_BITNOT", - /* 239 */ "INSERT", - /* 240 */ "VALUES", - /* 241 */ "IMPORT", - /* 242 */ "NK_SEMI", - /* 243 */ "FILE", - /* 244 */ "cmd", - /* 245 */ "account_options", - /* 246 */ "alter_account_options", - /* 247 */ "literal", - /* 248 */ "alter_account_option", - /* 249 */ "user_name", - /* 250 */ "sysinfo_opt", - /* 251 */ "privileges", - /* 252 */ "priv_level", - /* 253 */ "priv_type_list", - /* 254 */ "priv_type", - /* 255 */ "db_name", - /* 256 */ "dnode_endpoint", - /* 257 */ "not_exists_opt", - /* 258 */ "db_options", - /* 259 */ "exists_opt", - /* 260 */ "alter_db_options", - /* 261 */ "integer_list", - /* 262 */ "variable_list", - /* 263 */ "retention_list", - /* 264 */ "alter_db_option", - /* 265 */ "retention", - /* 266 */ "full_table_name", - /* 267 */ "column_def_list", - /* 268 */ "tags_def_opt", - /* 269 */ "table_options", - /* 270 */ "multi_create_clause", - /* 271 */ "tags_def", - /* 272 */ "multi_drop_clause", - /* 273 */ "alter_table_clause", - /* 274 */ "alter_table_options", - /* 275 */ "column_name", - /* 276 */ "type_name", - /* 277 */ "signed_literal", - /* 278 */ "create_subtable_clause", - /* 279 */ "specific_tags_opt", - /* 280 */ "literal_list", - /* 281 */ "drop_table_clause", - /* 282 */ "col_name_list", - /* 283 */ "table_name", - /* 284 */ "column_def", - /* 285 */ "duration_list", - /* 286 */ "rollup_func_list", - /* 287 */ "alter_table_option", - /* 288 */ "duration_literal", - /* 289 */ "rollup_func_name", - /* 290 */ "function_name", - /* 291 */ "col_name", - /* 292 */ "db_name_cond_opt", - /* 293 */ "like_pattern_opt", - /* 294 */ "table_name_cond", - /* 295 */ "from_db_opt", - /* 296 */ "index_name", - /* 297 */ "index_options", - /* 298 */ "func_list", - /* 299 */ "sliding_opt", - /* 300 */ "func", - /* 301 */ "expression_list", - /* 302 */ "topic_name", - /* 303 */ "query_expression", - /* 304 */ "cgroup_name", - /* 305 */ "analyze_opt", - /* 306 */ "explain_options", - /* 307 */ "agg_func_opt", - /* 308 */ "bufsize_opt", - /* 309 */ "stream_name", - /* 310 */ "stream_options", - /* 311 */ "into_opt", - /* 312 */ "dnode_list", - /* 313 */ "where_clause_opt", - /* 314 */ "signed", - /* 315 */ "literal_func", - /* 316 */ "table_alias", - /* 317 */ "column_alias", - /* 318 */ "expression", - /* 319 */ "pseudo_column", - /* 320 */ "column_reference", - /* 321 */ "function_expression", - /* 322 */ "subquery", - /* 323 */ "star_func", - /* 324 */ "star_func_para_list", - /* 325 */ "noarg_func", - /* 326 */ "other_para_list", - /* 327 */ "star_func_para", - /* 328 */ "predicate", - /* 329 */ "compare_op", - /* 330 */ "in_op", - /* 331 */ "in_predicate_value", - /* 332 */ "boolean_value_expression", - /* 333 */ "boolean_primary", - /* 334 */ "common_expression", - /* 335 */ "from_clause_opt", - /* 336 */ "table_reference_list", - /* 337 */ "table_reference", - /* 338 */ "table_primary", - /* 339 */ "joined_table", - /* 340 */ "alias_opt", - /* 341 */ "parenthesized_joined_table", - /* 342 */ "join_type", - /* 343 */ "search_condition", - /* 344 */ "query_specification", - /* 345 */ "set_quantifier_opt", - /* 346 */ "select_list", - /* 347 */ "partition_by_clause_opt", - /* 348 */ "range_opt", - /* 349 */ "every_opt", - /* 350 */ "fill_opt", - /* 351 */ "twindow_clause_opt", - /* 352 */ "group_by_clause_opt", - /* 353 */ "having_clause_opt", - /* 354 */ "select_sublist", - /* 355 */ "select_item", - /* 356 */ "fill_mode", - /* 357 */ "group_by_list", - /* 358 */ "query_expression_body", - /* 359 */ "order_by_clause_opt", - /* 360 */ "slimit_clause_opt", - /* 361 */ "limit_clause_opt", - /* 362 */ "query_primary", - /* 363 */ "sort_specification_list", - /* 364 */ "sort_specification", - /* 365 */ "ordering_specification_opt", - /* 366 */ "null_ordering_opt", + /* 143 */ "CONSUMERS", + /* 144 */ "SUBSCRIPTIONS", + /* 145 */ "LIKE", + /* 146 */ "INDEX", + /* 147 */ "FUNCTION", + /* 148 */ "INTERVAL", + /* 149 */ "TOPIC", + /* 150 */ "AS", + /* 151 */ "WITH", + /* 152 */ "META", + /* 153 */ "CONSUMER", + /* 154 */ "GROUP", + /* 155 */ "DESC", + /* 156 */ "DESCRIBE", + /* 157 */ "RESET", + /* 158 */ "QUERY", + /* 159 */ "CACHE", + /* 160 */ "EXPLAIN", + /* 161 */ "ANALYZE", + /* 162 */ "VERBOSE", + /* 163 */ "NK_BOOL", + /* 164 */ "RATIO", + /* 165 */ "NK_FLOAT", + /* 166 */ "COMPACT", + /* 167 */ "VNODES", + /* 168 */ "IN", + /* 169 */ "OUTPUTTYPE", + /* 170 */ "AGGREGATE", + /* 171 */ "BUFSIZE", + /* 172 */ "STREAM", + /* 173 */ "INTO", + /* 174 */ "TRIGGER", + /* 175 */ "AT_ONCE", + /* 176 */ "WINDOW_CLOSE", + /* 177 */ "KILL", + /* 178 */ "CONNECTION", + /* 179 */ "TRANSACTION", + /* 180 */ "BALANCE", + /* 181 */ "VGROUP", + /* 182 */ "MERGE", + /* 183 */ "REDISTRIBUTE", + /* 184 */ "SPLIT", + /* 185 */ "SYNCDB", + /* 186 */ "DELETE", + /* 187 */ "NULL", + /* 188 */ "NK_QUESTION", + /* 189 */ "NK_ARROW", + /* 190 */ "ROWTS", + /* 191 */ "TBNAME", + /* 192 */ "QSTARTTS", + /* 193 */ "QENDTS", + /* 194 */ "WSTARTTS", + /* 195 */ "WENDTS", + /* 196 */ "WDURATION", + /* 197 */ "CAST", + /* 198 */ "NOW", + /* 199 */ "TODAY", + /* 200 */ "TIMEZONE", + /* 201 */ "COUNT", + /* 202 */ "LAST_ROW", + /* 203 */ "BETWEEN", + /* 204 */ "IS", + /* 205 */ "NK_LT", + /* 206 */ "NK_GT", + /* 207 */ "NK_LE", + /* 208 */ "NK_GE", + /* 209 */ "NK_NE", + /* 210 */ "MATCH", + /* 211 */ "NMATCH", + /* 212 */ "CONTAINS", + /* 213 */ "JOIN", + /* 214 */ "INNER", + /* 215 */ "SELECT", + /* 216 */ "DISTINCT", + /* 217 */ "WHERE", + /* 218 */ "PARTITION", + /* 219 */ "BY", + /* 220 */ "SESSION", + /* 221 */ "STATE_WINDOW", + /* 222 */ "SLIDING", + /* 223 */ "FILL", + /* 224 */ "VALUE", + /* 225 */ "NONE", + /* 226 */ "PREV", + /* 227 */ "LINEAR", + /* 228 */ "NEXT", + /* 229 */ "HAVING", + /* 230 */ "RANGE", + /* 231 */ "EVERY", + /* 232 */ "ORDER", + /* 233 */ "SLIMIT", + /* 234 */ "SOFFSET", + /* 235 */ "LIMIT", + /* 236 */ "OFFSET", + /* 237 */ "ASC", + /* 238 */ "NULLS", + /* 239 */ "ID", + /* 240 */ "NK_BITNOT", + /* 241 */ "INSERT", + /* 242 */ "VALUES", + /* 243 */ "IMPORT", + /* 244 */ "NK_SEMI", + /* 245 */ "FILE", + /* 246 */ "cmd", + /* 247 */ "account_options", + /* 248 */ "alter_account_options", + /* 249 */ "literal", + /* 250 */ "alter_account_option", + /* 251 */ "user_name", + /* 252 */ "sysinfo_opt", + /* 253 */ "privileges", + /* 254 */ "priv_level", + /* 255 */ "priv_type_list", + /* 256 */ "priv_type", + /* 257 */ "db_name", + /* 258 */ "dnode_endpoint", + /* 259 */ "not_exists_opt", + /* 260 */ "db_options", + /* 261 */ "exists_opt", + /* 262 */ "alter_db_options", + /* 263 */ "integer_list", + /* 264 */ "variable_list", + /* 265 */ "retention_list", + /* 266 */ "alter_db_option", + /* 267 */ "retention", + /* 268 */ "full_table_name", + /* 269 */ "column_def_list", + /* 270 */ "tags_def_opt", + /* 271 */ "table_options", + /* 272 */ "multi_create_clause", + /* 273 */ "tags_def", + /* 274 */ "multi_drop_clause", + /* 275 */ "alter_table_clause", + /* 276 */ "alter_table_options", + /* 277 */ "column_name", + /* 278 */ "type_name", + /* 279 */ "signed_literal", + /* 280 */ "create_subtable_clause", + /* 281 */ "specific_tags_opt", + /* 282 */ "literal_list", + /* 283 */ "drop_table_clause", + /* 284 */ "col_name_list", + /* 285 */ "table_name", + /* 286 */ "column_def", + /* 287 */ "duration_list", + /* 288 */ "rollup_func_list", + /* 289 */ "alter_table_option", + /* 290 */ "duration_literal", + /* 291 */ "rollup_func_name", + /* 292 */ "function_name", + /* 293 */ "col_name", + /* 294 */ "db_name_cond_opt", + /* 295 */ "like_pattern_opt", + /* 296 */ "table_name_cond", + /* 297 */ "from_db_opt", + /* 298 */ "index_name", + /* 299 */ "index_options", + /* 300 */ "func_list", + /* 301 */ "sliding_opt", + /* 302 */ "sma_stream_opt", + /* 303 */ "func", + /* 304 */ "expression_list", + /* 305 */ "stream_options", + /* 306 */ "topic_name", + /* 307 */ "query_expression", + /* 308 */ "cgroup_name", + /* 309 */ "analyze_opt", + /* 310 */ "explain_options", + /* 311 */ "agg_func_opt", + /* 312 */ "bufsize_opt", + /* 313 */ "stream_name", + /* 314 */ "into_opt", + /* 315 */ "dnode_list", + /* 316 */ "where_clause_opt", + /* 317 */ "signed", + /* 318 */ "literal_func", + /* 319 */ "table_alias", + /* 320 */ "column_alias", + /* 321 */ "expression", + /* 322 */ "pseudo_column", + /* 323 */ "column_reference", + /* 324 */ "function_expression", + /* 325 */ "subquery", + /* 326 */ "star_func", + /* 327 */ "star_func_para_list", + /* 328 */ "noarg_func", + /* 329 */ "other_para_list", + /* 330 */ "star_func_para", + /* 331 */ "predicate", + /* 332 */ "compare_op", + /* 333 */ "in_op", + /* 334 */ "in_predicate_value", + /* 335 */ "boolean_value_expression", + /* 336 */ "boolean_primary", + /* 337 */ "common_expression", + /* 338 */ "from_clause_opt", + /* 339 */ "table_reference_list", + /* 340 */ "table_reference", + /* 341 */ "table_primary", + /* 342 */ "joined_table", + /* 343 */ "alias_opt", + /* 344 */ "parenthesized_joined_table", + /* 345 */ "join_type", + /* 346 */ "search_condition", + /* 347 */ "query_specification", + /* 348 */ "set_quantifier_opt", + /* 349 */ "select_list", + /* 350 */ "partition_by_clause_opt", + /* 351 */ "range_opt", + /* 352 */ "every_opt", + /* 353 */ "fill_opt", + /* 354 */ "twindow_clause_opt", + /* 355 */ "group_by_clause_opt", + /* 356 */ "having_clause_opt", + /* 357 */ "select_sublist", + /* 358 */ "select_item", + /* 359 */ "fill_mode", + /* 360 */ "group_by_list", + /* 361 */ "query_expression_body", + /* 362 */ "order_by_clause_opt", + /* 363 */ "slimit_clause_opt", + /* 364 */ "limit_clause_opt", + /* 365 */ "query_primary", + /* 366 */ "sort_specification_list", + /* 367 */ "sort_specification", + /* 368 */ "ordering_specification_opt", + /* 369 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1783,261 +1780,265 @@ static const char *const yyRuleName[] = { /* 215 */ "cmd ::= SHOW CLUSTER", /* 216 */ "cmd ::= SHOW TRANSACTIONS", /* 217 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 218 */ "db_name_cond_opt ::=", - /* 219 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 220 */ "like_pattern_opt ::=", - /* 221 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 222 */ "table_name_cond ::= table_name", - /* 223 */ "from_db_opt ::=", - /* 224 */ "from_db_opt ::= FROM db_name", - /* 225 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 226 */ "cmd ::= DROP INDEX exists_opt index_name", - /* 227 */ "index_options ::=", - /* 228 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 229 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 230 */ "func_list ::= func", - /* 231 */ "func_list ::= func_list NK_COMMA func", - /* 232 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 233 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 234 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 235 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 236 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 237 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 238 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 239 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 240 */ "cmd ::= DESC full_table_name", - /* 241 */ "cmd ::= DESCRIBE full_table_name", - /* 242 */ "cmd ::= RESET QUERY CACHE", - /* 243 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 244 */ "analyze_opt ::=", - /* 245 */ "analyze_opt ::= ANALYZE", - /* 246 */ "explain_options ::=", - /* 247 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 248 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 249 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 250 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 251 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 252 */ "agg_func_opt ::=", - /* 253 */ "agg_func_opt ::= AGGREGATE", - /* 254 */ "bufsize_opt ::=", - /* 255 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 256 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 257 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 258 */ "into_opt ::=", - /* 259 */ "into_opt ::= INTO full_table_name", - /* 260 */ "stream_options ::=", - /* 261 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 262 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 263 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 264 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 265 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 266 */ "cmd ::= KILL QUERY NK_STRING", - /* 267 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 268 */ "cmd ::= BALANCE VGROUP", - /* 269 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 270 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 271 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 272 */ "dnode_list ::= DNODE NK_INTEGER", - /* 273 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 274 */ "cmd ::= SYNCDB db_name REPLICA", - /* 275 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 276 */ "cmd ::= query_expression", - /* 277 */ "literal ::= NK_INTEGER", - /* 278 */ "literal ::= NK_FLOAT", - /* 279 */ "literal ::= NK_STRING", - /* 280 */ "literal ::= NK_BOOL", - /* 281 */ "literal ::= TIMESTAMP NK_STRING", - /* 282 */ "literal ::= duration_literal", - /* 283 */ "literal ::= NULL", - /* 284 */ "literal ::= NK_QUESTION", - /* 285 */ "duration_literal ::= NK_VARIABLE", - /* 286 */ "signed ::= NK_INTEGER", - /* 287 */ "signed ::= NK_PLUS NK_INTEGER", - /* 288 */ "signed ::= NK_MINUS NK_INTEGER", - /* 289 */ "signed ::= NK_FLOAT", - /* 290 */ "signed ::= NK_PLUS NK_FLOAT", - /* 291 */ "signed ::= NK_MINUS NK_FLOAT", - /* 292 */ "signed_literal ::= signed", - /* 293 */ "signed_literal ::= NK_STRING", - /* 294 */ "signed_literal ::= NK_BOOL", - /* 295 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 296 */ "signed_literal ::= duration_literal", - /* 297 */ "signed_literal ::= NULL", - /* 298 */ "signed_literal ::= literal_func", - /* 299 */ "literal_list ::= signed_literal", - /* 300 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 301 */ "db_name ::= NK_ID", - /* 302 */ "table_name ::= NK_ID", - /* 303 */ "column_name ::= NK_ID", - /* 304 */ "function_name ::= NK_ID", - /* 305 */ "table_alias ::= NK_ID", - /* 306 */ "column_alias ::= NK_ID", - /* 307 */ "user_name ::= NK_ID", - /* 308 */ "index_name ::= NK_ID", - /* 309 */ "topic_name ::= NK_ID", - /* 310 */ "stream_name ::= NK_ID", - /* 311 */ "cgroup_name ::= NK_ID", - /* 312 */ "expression ::= literal", - /* 313 */ "expression ::= pseudo_column", - /* 314 */ "expression ::= column_reference", - /* 315 */ "expression ::= function_expression", - /* 316 */ "expression ::= subquery", - /* 317 */ "expression ::= NK_LP expression NK_RP", - /* 318 */ "expression ::= NK_PLUS expression", - /* 319 */ "expression ::= NK_MINUS expression", - /* 320 */ "expression ::= expression NK_PLUS expression", - /* 321 */ "expression ::= expression NK_MINUS expression", - /* 322 */ "expression ::= expression NK_STAR expression", - /* 323 */ "expression ::= expression NK_SLASH expression", - /* 324 */ "expression ::= expression NK_REM expression", - /* 325 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 326 */ "expression ::= expression NK_BITAND expression", - /* 327 */ "expression ::= expression NK_BITOR expression", - /* 328 */ "expression_list ::= expression", - /* 329 */ "expression_list ::= expression_list NK_COMMA expression", - /* 330 */ "column_reference ::= column_name", - /* 331 */ "column_reference ::= table_name NK_DOT column_name", - /* 332 */ "pseudo_column ::= ROWTS", - /* 333 */ "pseudo_column ::= TBNAME", - /* 334 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 335 */ "pseudo_column ::= QSTARTTS", - /* 336 */ "pseudo_column ::= QENDTS", - /* 337 */ "pseudo_column ::= WSTARTTS", - /* 338 */ "pseudo_column ::= WENDTS", - /* 339 */ "pseudo_column ::= WDURATION", - /* 340 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 341 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 342 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 343 */ "function_expression ::= literal_func", - /* 344 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 345 */ "literal_func ::= NOW", - /* 346 */ "noarg_func ::= NOW", - /* 347 */ "noarg_func ::= TODAY", - /* 348 */ "noarg_func ::= TIMEZONE", - /* 349 */ "star_func ::= COUNT", - /* 350 */ "star_func ::= FIRST", - /* 351 */ "star_func ::= LAST", - /* 352 */ "star_func ::= LAST_ROW", - /* 353 */ "star_func_para_list ::= NK_STAR", - /* 354 */ "star_func_para_list ::= other_para_list", - /* 355 */ "other_para_list ::= star_func_para", - /* 356 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 357 */ "star_func_para ::= expression", - /* 358 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 359 */ "predicate ::= expression compare_op expression", - /* 360 */ "predicate ::= expression BETWEEN expression AND expression", - /* 361 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 362 */ "predicate ::= expression IS NULL", - /* 363 */ "predicate ::= expression IS NOT NULL", - /* 364 */ "predicate ::= expression in_op in_predicate_value", - /* 365 */ "compare_op ::= NK_LT", - /* 366 */ "compare_op ::= NK_GT", - /* 367 */ "compare_op ::= NK_LE", - /* 368 */ "compare_op ::= NK_GE", - /* 369 */ "compare_op ::= NK_NE", - /* 370 */ "compare_op ::= NK_EQ", - /* 371 */ "compare_op ::= LIKE", - /* 372 */ "compare_op ::= NOT LIKE", - /* 373 */ "compare_op ::= MATCH", - /* 374 */ "compare_op ::= NMATCH", - /* 375 */ "compare_op ::= CONTAINS", - /* 376 */ "in_op ::= IN", - /* 377 */ "in_op ::= NOT IN", - /* 378 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 379 */ "boolean_value_expression ::= boolean_primary", - /* 380 */ "boolean_value_expression ::= NOT boolean_primary", - /* 381 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 382 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 383 */ "boolean_primary ::= predicate", - /* 384 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 385 */ "common_expression ::= expression", - /* 386 */ "common_expression ::= boolean_value_expression", - /* 387 */ "from_clause_opt ::=", - /* 388 */ "from_clause_opt ::= FROM table_reference_list", - /* 389 */ "table_reference_list ::= table_reference", - /* 390 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 391 */ "table_reference ::= table_primary", - /* 392 */ "table_reference ::= joined_table", - /* 393 */ "table_primary ::= table_name alias_opt", - /* 394 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 395 */ "table_primary ::= subquery alias_opt", - /* 396 */ "table_primary ::= parenthesized_joined_table", - /* 397 */ "alias_opt ::=", - /* 398 */ "alias_opt ::= table_alias", - /* 399 */ "alias_opt ::= AS table_alias", - /* 400 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 401 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 402 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 403 */ "join_type ::=", - /* 404 */ "join_type ::= INNER", - /* 405 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 406 */ "set_quantifier_opt ::=", - /* 407 */ "set_quantifier_opt ::= DISTINCT", - /* 408 */ "set_quantifier_opt ::= ALL", - /* 409 */ "select_list ::= NK_STAR", - /* 410 */ "select_list ::= select_sublist", - /* 411 */ "select_sublist ::= select_item", - /* 412 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 413 */ "select_item ::= common_expression", - /* 414 */ "select_item ::= common_expression column_alias", - /* 415 */ "select_item ::= common_expression AS column_alias", - /* 416 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 417 */ "where_clause_opt ::=", - /* 418 */ "where_clause_opt ::= WHERE search_condition", - /* 419 */ "partition_by_clause_opt ::=", - /* 420 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 421 */ "twindow_clause_opt ::=", - /* 422 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 423 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 424 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 425 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 426 */ "sliding_opt ::=", - /* 427 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 428 */ "fill_opt ::=", - /* 429 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 430 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 431 */ "fill_mode ::= NONE", - /* 432 */ "fill_mode ::= PREV", - /* 433 */ "fill_mode ::= NULL", - /* 434 */ "fill_mode ::= LINEAR", - /* 435 */ "fill_mode ::= NEXT", - /* 436 */ "group_by_clause_opt ::=", - /* 437 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 438 */ "group_by_list ::= expression", - /* 439 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 440 */ "having_clause_opt ::=", - /* 441 */ "having_clause_opt ::= HAVING search_condition", - /* 442 */ "range_opt ::=", - /* 443 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 444 */ "every_opt ::=", - /* 445 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 446 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 447 */ "query_expression_body ::= query_primary", - /* 448 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 449 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 450 */ "query_primary ::= query_specification", - /* 451 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 452 */ "order_by_clause_opt ::=", - /* 453 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 454 */ "slimit_clause_opt ::=", - /* 455 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 456 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 457 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 458 */ "limit_clause_opt ::=", - /* 459 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 460 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 461 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 462 */ "subquery ::= NK_LP query_expression NK_RP", - /* 463 */ "search_condition ::= common_expression", - /* 464 */ "sort_specification_list ::= sort_specification", - /* 465 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 466 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 467 */ "ordering_specification_opt ::=", - /* 468 */ "ordering_specification_opt ::= ASC", - /* 469 */ "ordering_specification_opt ::= DESC", - /* 470 */ "null_ordering_opt ::=", - /* 471 */ "null_ordering_opt ::= NULLS FIRST", - /* 472 */ "null_ordering_opt ::= NULLS LAST", + /* 218 */ "cmd ::= SHOW CONSUMERS", + /* 219 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 220 */ "db_name_cond_opt ::=", + /* 221 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 222 */ "like_pattern_opt ::=", + /* 223 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 224 */ "table_name_cond ::= table_name", + /* 225 */ "from_db_opt ::=", + /* 226 */ "from_db_opt ::= FROM db_name", + /* 227 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 228 */ "cmd ::= DROP INDEX exists_opt index_name", + /* 229 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 230 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 231 */ "func_list ::= func", + /* 232 */ "func_list ::= func_list NK_COMMA func", + /* 233 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 234 */ "sma_stream_opt ::=", + /* 235 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 236 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 237 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 238 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 239 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 240 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 241 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 242 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 243 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 244 */ "cmd ::= DESC full_table_name", + /* 245 */ "cmd ::= DESCRIBE full_table_name", + /* 246 */ "cmd ::= RESET QUERY CACHE", + /* 247 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 248 */ "analyze_opt ::=", + /* 249 */ "analyze_opt ::= ANALYZE", + /* 250 */ "explain_options ::=", + /* 251 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 252 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 253 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 254 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 255 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 256 */ "agg_func_opt ::=", + /* 257 */ "agg_func_opt ::= AGGREGATE", + /* 258 */ "bufsize_opt ::=", + /* 259 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 260 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 261 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 262 */ "into_opt ::=", + /* 263 */ "into_opt ::= INTO full_table_name", + /* 264 */ "stream_options ::=", + /* 265 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 266 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 267 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 268 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 269 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 270 */ "cmd ::= KILL QUERY NK_STRING", + /* 271 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 272 */ "cmd ::= BALANCE VGROUP", + /* 273 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 274 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 275 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 276 */ "dnode_list ::= DNODE NK_INTEGER", + /* 277 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 278 */ "cmd ::= SYNCDB db_name REPLICA", + /* 279 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 280 */ "cmd ::= query_expression", + /* 281 */ "literal ::= NK_INTEGER", + /* 282 */ "literal ::= NK_FLOAT", + /* 283 */ "literal ::= NK_STRING", + /* 284 */ "literal ::= NK_BOOL", + /* 285 */ "literal ::= TIMESTAMP NK_STRING", + /* 286 */ "literal ::= duration_literal", + /* 287 */ "literal ::= NULL", + /* 288 */ "literal ::= NK_QUESTION", + /* 289 */ "duration_literal ::= NK_VARIABLE", + /* 290 */ "signed ::= NK_INTEGER", + /* 291 */ "signed ::= NK_PLUS NK_INTEGER", + /* 292 */ "signed ::= NK_MINUS NK_INTEGER", + /* 293 */ "signed ::= NK_FLOAT", + /* 294 */ "signed ::= NK_PLUS NK_FLOAT", + /* 295 */ "signed ::= NK_MINUS NK_FLOAT", + /* 296 */ "signed_literal ::= signed", + /* 297 */ "signed_literal ::= NK_STRING", + /* 298 */ "signed_literal ::= NK_BOOL", + /* 299 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 300 */ "signed_literal ::= duration_literal", + /* 301 */ "signed_literal ::= NULL", + /* 302 */ "signed_literal ::= literal_func", + /* 303 */ "literal_list ::= signed_literal", + /* 304 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 305 */ "db_name ::= NK_ID", + /* 306 */ "table_name ::= NK_ID", + /* 307 */ "column_name ::= NK_ID", + /* 308 */ "function_name ::= NK_ID", + /* 309 */ "table_alias ::= NK_ID", + /* 310 */ "column_alias ::= NK_ID", + /* 311 */ "user_name ::= NK_ID", + /* 312 */ "index_name ::= NK_ID", + /* 313 */ "topic_name ::= NK_ID", + /* 314 */ "stream_name ::= NK_ID", + /* 315 */ "cgroup_name ::= NK_ID", + /* 316 */ "expression ::= literal", + /* 317 */ "expression ::= pseudo_column", + /* 318 */ "expression ::= column_reference", + /* 319 */ "expression ::= function_expression", + /* 320 */ "expression ::= subquery", + /* 321 */ "expression ::= NK_LP expression NK_RP", + /* 322 */ "expression ::= NK_PLUS expression", + /* 323 */ "expression ::= NK_MINUS expression", + /* 324 */ "expression ::= expression NK_PLUS expression", + /* 325 */ "expression ::= expression NK_MINUS expression", + /* 326 */ "expression ::= expression NK_STAR expression", + /* 327 */ "expression ::= expression NK_SLASH expression", + /* 328 */ "expression ::= expression NK_REM expression", + /* 329 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 330 */ "expression ::= expression NK_BITAND expression", + /* 331 */ "expression ::= expression NK_BITOR expression", + /* 332 */ "expression_list ::= expression", + /* 333 */ "expression_list ::= expression_list NK_COMMA expression", + /* 334 */ "column_reference ::= column_name", + /* 335 */ "column_reference ::= table_name NK_DOT column_name", + /* 336 */ "pseudo_column ::= ROWTS", + /* 337 */ "pseudo_column ::= TBNAME", + /* 338 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 339 */ "pseudo_column ::= QSTARTTS", + /* 340 */ "pseudo_column ::= QENDTS", + /* 341 */ "pseudo_column ::= WSTARTTS", + /* 342 */ "pseudo_column ::= WENDTS", + /* 343 */ "pseudo_column ::= WDURATION", + /* 344 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 345 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 346 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 347 */ "function_expression ::= literal_func", + /* 348 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 349 */ "literal_func ::= NOW", + /* 350 */ "noarg_func ::= NOW", + /* 351 */ "noarg_func ::= TODAY", + /* 352 */ "noarg_func ::= TIMEZONE", + /* 353 */ "star_func ::= COUNT", + /* 354 */ "star_func ::= FIRST", + /* 355 */ "star_func ::= LAST", + /* 356 */ "star_func ::= LAST_ROW", + /* 357 */ "star_func_para_list ::= NK_STAR", + /* 358 */ "star_func_para_list ::= other_para_list", + /* 359 */ "other_para_list ::= star_func_para", + /* 360 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 361 */ "star_func_para ::= expression", + /* 362 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 363 */ "predicate ::= expression compare_op expression", + /* 364 */ "predicate ::= expression BETWEEN expression AND expression", + /* 365 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 366 */ "predicate ::= expression IS NULL", + /* 367 */ "predicate ::= expression IS NOT NULL", + /* 368 */ "predicate ::= expression in_op in_predicate_value", + /* 369 */ "compare_op ::= NK_LT", + /* 370 */ "compare_op ::= NK_GT", + /* 371 */ "compare_op ::= NK_LE", + /* 372 */ "compare_op ::= NK_GE", + /* 373 */ "compare_op ::= NK_NE", + /* 374 */ "compare_op ::= NK_EQ", + /* 375 */ "compare_op ::= LIKE", + /* 376 */ "compare_op ::= NOT LIKE", + /* 377 */ "compare_op ::= MATCH", + /* 378 */ "compare_op ::= NMATCH", + /* 379 */ "compare_op ::= CONTAINS", + /* 380 */ "in_op ::= IN", + /* 381 */ "in_op ::= NOT IN", + /* 382 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 383 */ "boolean_value_expression ::= boolean_primary", + /* 384 */ "boolean_value_expression ::= NOT boolean_primary", + /* 385 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 386 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 387 */ "boolean_primary ::= predicate", + /* 388 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 389 */ "common_expression ::= expression", + /* 390 */ "common_expression ::= boolean_value_expression", + /* 391 */ "from_clause_opt ::=", + /* 392 */ "from_clause_opt ::= FROM table_reference_list", + /* 393 */ "table_reference_list ::= table_reference", + /* 394 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 395 */ "table_reference ::= table_primary", + /* 396 */ "table_reference ::= joined_table", + /* 397 */ "table_primary ::= table_name alias_opt", + /* 398 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 399 */ "table_primary ::= subquery alias_opt", + /* 400 */ "table_primary ::= parenthesized_joined_table", + /* 401 */ "alias_opt ::=", + /* 402 */ "alias_opt ::= table_alias", + /* 403 */ "alias_opt ::= AS table_alias", + /* 404 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 405 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 406 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 407 */ "join_type ::=", + /* 408 */ "join_type ::= INNER", + /* 409 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 410 */ "set_quantifier_opt ::=", + /* 411 */ "set_quantifier_opt ::= DISTINCT", + /* 412 */ "set_quantifier_opt ::= ALL", + /* 413 */ "select_list ::= NK_STAR", + /* 414 */ "select_list ::= select_sublist", + /* 415 */ "select_sublist ::= select_item", + /* 416 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 417 */ "select_item ::= common_expression", + /* 418 */ "select_item ::= common_expression column_alias", + /* 419 */ "select_item ::= common_expression AS column_alias", + /* 420 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 421 */ "where_clause_opt ::=", + /* 422 */ "where_clause_opt ::= WHERE search_condition", + /* 423 */ "partition_by_clause_opt ::=", + /* 424 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 425 */ "twindow_clause_opt ::=", + /* 426 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 427 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 428 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 429 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 430 */ "sliding_opt ::=", + /* 431 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 432 */ "fill_opt ::=", + /* 433 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 434 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 435 */ "fill_mode ::= NONE", + /* 436 */ "fill_mode ::= PREV", + /* 437 */ "fill_mode ::= NULL", + /* 438 */ "fill_mode ::= LINEAR", + /* 439 */ "fill_mode ::= NEXT", + /* 440 */ "group_by_clause_opt ::=", + /* 441 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 442 */ "group_by_list ::= expression", + /* 443 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 444 */ "having_clause_opt ::=", + /* 445 */ "having_clause_opt ::= HAVING search_condition", + /* 446 */ "range_opt ::=", + /* 447 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 448 */ "every_opt ::=", + /* 449 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 450 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 451 */ "query_expression_body ::= query_primary", + /* 452 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 453 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 454 */ "query_primary ::= query_specification", + /* 455 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 456 */ "order_by_clause_opt ::=", + /* 457 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 458 */ "slimit_clause_opt ::=", + /* 459 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 460 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 461 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 462 */ "limit_clause_opt ::=", + /* 463 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 464 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 465 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 466 */ "subquery ::= NK_LP query_expression NK_RP", + /* 467 */ "search_condition ::= common_expression", + /* 468 */ "sort_specification_list ::= sort_specification", + /* 469 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 470 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 471 */ "ordering_specification_opt ::=", + /* 472 */ "ordering_specification_opt ::= ASC", + /* 473 */ "ordering_specification_opt ::= DESC", + /* 474 */ "null_ordering_opt ::=", + /* 475 */ "null_ordering_opt ::= NULLS FIRST", + /* 476 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2164,181 +2165,182 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 244: /* cmd */ - case 247: /* literal */ - case 258: /* db_options */ - case 260: /* alter_db_options */ - case 265: /* retention */ - case 266: /* full_table_name */ - case 269: /* table_options */ - case 273: /* alter_table_clause */ - case 274: /* alter_table_options */ - case 277: /* signed_literal */ - case 278: /* create_subtable_clause */ - case 281: /* drop_table_clause */ - case 284: /* column_def */ - case 288: /* duration_literal */ - case 289: /* rollup_func_name */ - case 291: /* col_name */ - case 292: /* db_name_cond_opt */ - case 293: /* like_pattern_opt */ - case 294: /* table_name_cond */ - case 295: /* from_db_opt */ - case 297: /* index_options */ - case 299: /* sliding_opt */ - case 300: /* func */ - case 303: /* query_expression */ - case 306: /* explain_options */ - case 310: /* stream_options */ - case 311: /* into_opt */ - case 313: /* where_clause_opt */ - case 314: /* signed */ - case 315: /* literal_func */ - case 318: /* expression */ - case 319: /* pseudo_column */ - case 320: /* column_reference */ - case 321: /* function_expression */ - case 322: /* subquery */ - case 327: /* star_func_para */ - case 328: /* predicate */ - case 331: /* in_predicate_value */ - case 332: /* boolean_value_expression */ - case 333: /* boolean_primary */ - case 334: /* common_expression */ - case 335: /* from_clause_opt */ - case 336: /* table_reference_list */ - case 337: /* table_reference */ - case 338: /* table_primary */ - case 339: /* joined_table */ - case 341: /* parenthesized_joined_table */ - case 343: /* search_condition */ - case 344: /* query_specification */ - case 348: /* range_opt */ - case 349: /* every_opt */ - case 350: /* fill_opt */ - case 351: /* twindow_clause_opt */ - case 353: /* having_clause_opt */ - case 355: /* select_item */ - case 358: /* query_expression_body */ - case 360: /* slimit_clause_opt */ - case 361: /* limit_clause_opt */ - case 362: /* query_primary */ - case 364: /* sort_specification */ + case 246: /* cmd */ + case 249: /* literal */ + case 260: /* db_options */ + case 262: /* alter_db_options */ + case 267: /* retention */ + case 268: /* full_table_name */ + case 271: /* table_options */ + case 275: /* alter_table_clause */ + case 276: /* alter_table_options */ + case 279: /* signed_literal */ + case 280: /* create_subtable_clause */ + case 283: /* drop_table_clause */ + case 286: /* column_def */ + case 290: /* duration_literal */ + case 291: /* rollup_func_name */ + case 293: /* col_name */ + case 294: /* db_name_cond_opt */ + case 295: /* like_pattern_opt */ + case 296: /* table_name_cond */ + case 297: /* from_db_opt */ + case 299: /* index_options */ + case 301: /* sliding_opt */ + case 302: /* sma_stream_opt */ + case 303: /* func */ + case 305: /* stream_options */ + case 307: /* query_expression */ + case 310: /* explain_options */ + case 314: /* into_opt */ + case 316: /* where_clause_opt */ + case 317: /* signed */ + case 318: /* literal_func */ + case 321: /* expression */ + case 322: /* pseudo_column */ + case 323: /* column_reference */ + case 324: /* function_expression */ + case 325: /* subquery */ + case 330: /* star_func_para */ + case 331: /* predicate */ + case 334: /* in_predicate_value */ + case 335: /* boolean_value_expression */ + case 336: /* boolean_primary */ + case 337: /* common_expression */ + case 338: /* from_clause_opt */ + case 339: /* table_reference_list */ + case 340: /* table_reference */ + case 341: /* table_primary */ + case 342: /* joined_table */ + case 344: /* parenthesized_joined_table */ + case 346: /* search_condition */ + case 347: /* query_specification */ + case 351: /* range_opt */ + case 352: /* every_opt */ + case 353: /* fill_opt */ + case 354: /* twindow_clause_opt */ + case 356: /* having_clause_opt */ + case 358: /* select_item */ + case 361: /* query_expression_body */ + case 363: /* slimit_clause_opt */ + case 364: /* limit_clause_opt */ + case 365: /* query_primary */ + case 367: /* sort_specification */ { - nodesDestroyNode((yypminor->yy442)); + nodesDestroyNode((yypminor->yy452)); } break; - case 245: /* account_options */ - case 246: /* alter_account_options */ - case 248: /* alter_account_option */ - case 308: /* bufsize_opt */ + case 247: /* account_options */ + case 248: /* alter_account_options */ + case 250: /* alter_account_option */ + case 312: /* bufsize_opt */ { } break; - case 249: /* user_name */ - case 252: /* priv_level */ - case 255: /* db_name */ - case 256: /* dnode_endpoint */ - case 275: /* column_name */ - case 283: /* table_name */ - case 290: /* function_name */ - case 296: /* index_name */ - case 302: /* topic_name */ - case 304: /* cgroup_name */ - case 309: /* stream_name */ - case 316: /* table_alias */ - case 317: /* column_alias */ - case 323: /* star_func */ - case 325: /* noarg_func */ - case 340: /* alias_opt */ + case 251: /* user_name */ + case 254: /* priv_level */ + case 257: /* db_name */ + case 258: /* dnode_endpoint */ + case 277: /* column_name */ + case 285: /* table_name */ + case 292: /* function_name */ + case 298: /* index_name */ + case 306: /* topic_name */ + case 308: /* cgroup_name */ + case 313: /* stream_name */ + case 319: /* table_alias */ + case 320: /* column_alias */ + case 326: /* star_func */ + case 328: /* noarg_func */ + case 343: /* alias_opt */ { } break; - case 250: /* sysinfo_opt */ + case 252: /* sysinfo_opt */ { } break; - case 251: /* privileges */ - case 253: /* priv_type_list */ - case 254: /* priv_type */ + case 253: /* privileges */ + case 255: /* priv_type_list */ + case 256: /* priv_type */ { } break; - case 257: /* not_exists_opt */ - case 259: /* exists_opt */ - case 305: /* analyze_opt */ - case 307: /* agg_func_opt */ - case 345: /* set_quantifier_opt */ + case 259: /* not_exists_opt */ + case 261: /* exists_opt */ + case 309: /* analyze_opt */ + case 311: /* agg_func_opt */ + case 348: /* set_quantifier_opt */ { } break; - case 261: /* integer_list */ - case 262: /* variable_list */ - case 263: /* retention_list */ - case 267: /* column_def_list */ - case 268: /* tags_def_opt */ - case 270: /* multi_create_clause */ - case 271: /* tags_def */ - case 272: /* multi_drop_clause */ - case 279: /* specific_tags_opt */ - case 280: /* literal_list */ - case 282: /* col_name_list */ - case 285: /* duration_list */ - case 286: /* rollup_func_list */ - case 298: /* func_list */ - case 301: /* expression_list */ - case 312: /* dnode_list */ - case 324: /* star_func_para_list */ - case 326: /* other_para_list */ - case 346: /* select_list */ - case 347: /* partition_by_clause_opt */ - case 352: /* group_by_clause_opt */ - case 354: /* select_sublist */ - case 357: /* group_by_list */ - case 359: /* order_by_clause_opt */ - case 363: /* sort_specification_list */ + case 263: /* integer_list */ + case 264: /* variable_list */ + case 265: /* retention_list */ + case 269: /* column_def_list */ + case 270: /* tags_def_opt */ + case 272: /* multi_create_clause */ + case 273: /* tags_def */ + case 274: /* multi_drop_clause */ + case 281: /* specific_tags_opt */ + case 282: /* literal_list */ + case 284: /* col_name_list */ + case 287: /* duration_list */ + case 288: /* rollup_func_list */ + case 300: /* func_list */ + case 304: /* expression_list */ + case 315: /* dnode_list */ + case 327: /* star_func_para_list */ + case 329: /* other_para_list */ + case 349: /* select_list */ + case 350: /* partition_by_clause_opt */ + case 355: /* group_by_clause_opt */ + case 357: /* select_sublist */ + case 360: /* group_by_list */ + case 362: /* order_by_clause_opt */ + case 366: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy368)); + nodesDestroyList((yypminor->yy404)); } break; - case 264: /* alter_db_option */ - case 287: /* alter_table_option */ + case 266: /* alter_db_option */ + case 289: /* alter_table_option */ { } break; - case 276: /* type_name */ + case 278: /* type_name */ { } break; - case 329: /* compare_op */ - case 330: /* in_op */ + case 332: /* compare_op */ + case 333: /* in_op */ { } break; - case 342: /* join_type */ + case 345: /* join_type */ { } break; - case 356: /* fill_mode */ + case 359: /* fill_mode */ { } break; - case 365: /* ordering_specification_opt */ + case 368: /* ordering_specification_opt */ { } break; - case 366: /* null_ordering_opt */ + case 369: /* null_ordering_opt */ { } @@ -2637,479 +2639,483 @@ 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[] = { - { 244, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 244, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 245, 0 }, /* (2) account_options ::= */ - { 245, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 245, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 245, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 245, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 245, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 245, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 245, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 245, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 245, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 246, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 246, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 248, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 248, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 248, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 248, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 248, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 248, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 248, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 248, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 248, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 248, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 244, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 244, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 244, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 244, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 244, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 250, 0 }, /* (29) sysinfo_opt ::= */ - { 250, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 244, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 244, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 251, -1 }, /* (33) privileges ::= ALL */ - { 251, -1 }, /* (34) privileges ::= priv_type_list */ - { 253, -1 }, /* (35) priv_type_list ::= priv_type */ - { 253, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 254, -1 }, /* (37) priv_type ::= READ */ - { 254, -1 }, /* (38) priv_type ::= WRITE */ - { 252, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 252, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 244, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 244, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 244, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 244, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 244, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 244, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 244, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 244, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 256, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 256, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 256, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 244, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 244, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 244, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 244, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 244, -2 }, /* (64) cmd ::= USE db_name */ - { 244, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 257, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ - { 257, 0 }, /* (67) not_exists_opt ::= */ - { 259, -2 }, /* (68) exists_opt ::= IF EXISTS */ - { 259, 0 }, /* (69) exists_opt ::= */ - { 258, 0 }, /* (70) db_options ::= */ - { 258, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ - { 258, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ - { 258, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ - { 258, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ - { 258, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ - { 258, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ - { 258, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ - { 258, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ - { 258, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ - { 258, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ - { 258, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ - { 258, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 258, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ - { 258, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ - { 258, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ - { 258, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ - { 258, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ - { 258, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 258, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ - { 258, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 260, -1 }, /* (91) alter_db_options ::= alter_db_option */ - { 260, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ - { 264, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ - { 264, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ - { 264, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ - { 264, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ - { 264, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ - { 264, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ - { 264, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ - { 264, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ - { 264, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ - { 261, -1 }, /* (102) integer_list ::= NK_INTEGER */ - { 261, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 262, -1 }, /* (104) variable_list ::= NK_VARIABLE */ - { 262, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 263, -1 }, /* (106) retention_list ::= retention */ - { 263, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ - { 265, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 244, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 244, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ - { 244, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 244, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ - { 244, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ - { 244, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ - { 244, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ - { 273, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ - { 273, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 273, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 273, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 273, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 273, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 273, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 273, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 273, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 273, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 270, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ - { 270, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 278, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 272, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ - { 272, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 281, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ - { 279, 0 }, /* (132) specific_tags_opt ::= */ - { 279, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 266, -1 }, /* (134) full_table_name ::= table_name */ - { 266, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ - { 267, -1 }, /* (136) column_def_list ::= column_def */ - { 267, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ - { 284, -2 }, /* (138) column_def ::= column_name type_name */ - { 284, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ - { 276, -1 }, /* (140) type_name ::= BOOL */ - { 276, -1 }, /* (141) type_name ::= TINYINT */ - { 276, -1 }, /* (142) type_name ::= SMALLINT */ - { 276, -1 }, /* (143) type_name ::= INT */ - { 276, -1 }, /* (144) type_name ::= INTEGER */ - { 276, -1 }, /* (145) type_name ::= BIGINT */ - { 276, -1 }, /* (146) type_name ::= FLOAT */ - { 276, -1 }, /* (147) type_name ::= DOUBLE */ - { 276, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (149) type_name ::= TIMESTAMP */ - { 276, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 276, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ - { 276, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ - { 276, -2 }, /* (153) type_name ::= INT UNSIGNED */ - { 276, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ - { 276, -1 }, /* (155) type_name ::= JSON */ - { 276, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (157) type_name ::= MEDIUMBLOB */ - { 276, -1 }, /* (158) type_name ::= BLOB */ - { 276, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (160) type_name ::= DECIMAL */ - { 276, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 276, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 268, 0 }, /* (163) tags_def_opt ::= */ - { 268, -1 }, /* (164) tags_def_opt ::= tags_def */ - { 271, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 269, 0 }, /* (166) table_options ::= */ - { 269, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ - { 269, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ - { 269, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ - { 269, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 269, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ - { 269, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 274, -1 }, /* (173) alter_table_options ::= alter_table_option */ - { 274, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ - { 287, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ - { 287, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ - { 285, -1 }, /* (177) duration_list ::= duration_literal */ - { 285, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ - { 286, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ - { 286, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 289, -1 }, /* (181) rollup_func_name ::= function_name */ - { 289, -1 }, /* (182) rollup_func_name ::= FIRST */ - { 289, -1 }, /* (183) rollup_func_name ::= LAST */ - { 282, -1 }, /* (184) col_name_list ::= col_name */ - { 282, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ - { 291, -1 }, /* (186) col_name ::= column_name */ - { 244, -2 }, /* (187) cmd ::= SHOW DNODES */ - { 244, -2 }, /* (188) cmd ::= SHOW USERS */ - { 244, -2 }, /* (189) cmd ::= SHOW DATABASES */ - { 244, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 244, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 244, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 244, -2 }, /* (193) cmd ::= SHOW MNODES */ - { 244, -2 }, /* (194) cmd ::= SHOW MODULES */ - { 244, -2 }, /* (195) cmd ::= SHOW QNODES */ - { 244, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ - { 244, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 244, -2 }, /* (198) cmd ::= SHOW STREAMS */ - { 244, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ - { 244, -2 }, /* (200) cmd ::= SHOW APPS */ - { 244, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ - { 244, -2 }, /* (202) cmd ::= SHOW LICENCE */ - { 244, -2 }, /* (203) cmd ::= SHOW GRANTS */ - { 244, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ - { 244, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ - { 244, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ - { 244, -2 }, /* (207) cmd ::= SHOW QUERIES */ - { 244, -2 }, /* (208) cmd ::= SHOW SCORES */ - { 244, -2 }, /* (209) cmd ::= SHOW TOPICS */ - { 244, -2 }, /* (210) cmd ::= SHOW VARIABLES */ - { 244, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ - { 244, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 244, -2 }, /* (213) cmd ::= SHOW BNODES */ - { 244, -2 }, /* (214) cmd ::= SHOW SNODES */ - { 244, -2 }, /* (215) cmd ::= SHOW CLUSTER */ - { 244, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ - { 244, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 292, 0 }, /* (218) db_name_cond_opt ::= */ - { 292, -2 }, /* (219) db_name_cond_opt ::= db_name NK_DOT */ - { 293, 0 }, /* (220) like_pattern_opt ::= */ - { 293, -2 }, /* (221) like_pattern_opt ::= LIKE NK_STRING */ - { 294, -1 }, /* (222) table_name_cond ::= table_name */ - { 295, 0 }, /* (223) from_db_opt ::= */ - { 295, -2 }, /* (224) from_db_opt ::= FROM db_name */ - { 244, -8 }, /* (225) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 244, -4 }, /* (226) cmd ::= DROP INDEX exists_opt index_name */ - { 297, 0 }, /* (227) index_options ::= */ - { 297, -9 }, /* (228) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 297, -11 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 298, -1 }, /* (230) func_list ::= func */ - { 298, -3 }, /* (231) func_list ::= func_list NK_COMMA func */ - { 300, -4 }, /* (232) func ::= function_name NK_LP expression_list NK_RP */ - { 244, -6 }, /* (233) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 244, -7 }, /* (234) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 244, -9 }, /* (235) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 244, -7 }, /* (236) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 244, -9 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 244, -4 }, /* (238) cmd ::= DROP TOPIC exists_opt topic_name */ - { 244, -7 }, /* (239) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 244, -2 }, /* (240) cmd ::= DESC full_table_name */ - { 244, -2 }, /* (241) cmd ::= DESCRIBE full_table_name */ - { 244, -3 }, /* (242) cmd ::= RESET QUERY CACHE */ - { 244, -4 }, /* (243) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 305, 0 }, /* (244) analyze_opt ::= */ - { 305, -1 }, /* (245) analyze_opt ::= ANALYZE */ - { 306, 0 }, /* (246) explain_options ::= */ - { 306, -3 }, /* (247) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 306, -3 }, /* (248) explain_options ::= explain_options RATIO NK_FLOAT */ - { 244, -6 }, /* (249) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 244, -10 }, /* (250) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 244, -4 }, /* (251) cmd ::= DROP FUNCTION exists_opt function_name */ - { 307, 0 }, /* (252) agg_func_opt ::= */ - { 307, -1 }, /* (253) agg_func_opt ::= AGGREGATE */ - { 308, 0 }, /* (254) bufsize_opt ::= */ - { 308, -2 }, /* (255) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 244, -8 }, /* (256) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 244, -4 }, /* (257) cmd ::= DROP STREAM exists_opt stream_name */ - { 311, 0 }, /* (258) into_opt ::= */ - { 311, -2 }, /* (259) into_opt ::= INTO full_table_name */ - { 310, 0 }, /* (260) stream_options ::= */ - { 310, -3 }, /* (261) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 310, -3 }, /* (262) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 310, -4 }, /* (263) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 310, -3 }, /* (264) stream_options ::= stream_options WATERMARK duration_literal */ - { 244, -3 }, /* (265) cmd ::= KILL CONNECTION NK_INTEGER */ - { 244, -3 }, /* (266) cmd ::= KILL QUERY NK_STRING */ - { 244, -3 }, /* (267) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 244, -2 }, /* (268) cmd ::= BALANCE VGROUP */ - { 244, -4 }, /* (269) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 244, -4 }, /* (270) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 244, -3 }, /* (271) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 312, -2 }, /* (272) dnode_list ::= DNODE NK_INTEGER */ - { 312, -3 }, /* (273) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 244, -3 }, /* (274) cmd ::= SYNCDB db_name REPLICA */ - { 244, -4 }, /* (275) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 244, -1 }, /* (276) cmd ::= query_expression */ - { 247, -1 }, /* (277) literal ::= NK_INTEGER */ - { 247, -1 }, /* (278) literal ::= NK_FLOAT */ - { 247, -1 }, /* (279) literal ::= NK_STRING */ - { 247, -1 }, /* (280) literal ::= NK_BOOL */ - { 247, -2 }, /* (281) literal ::= TIMESTAMP NK_STRING */ - { 247, -1 }, /* (282) literal ::= duration_literal */ - { 247, -1 }, /* (283) literal ::= NULL */ - { 247, -1 }, /* (284) literal ::= NK_QUESTION */ - { 288, -1 }, /* (285) duration_literal ::= NK_VARIABLE */ - { 314, -1 }, /* (286) signed ::= NK_INTEGER */ - { 314, -2 }, /* (287) signed ::= NK_PLUS NK_INTEGER */ - { 314, -2 }, /* (288) signed ::= NK_MINUS NK_INTEGER */ - { 314, -1 }, /* (289) signed ::= NK_FLOAT */ - { 314, -2 }, /* (290) signed ::= NK_PLUS NK_FLOAT */ - { 314, -2 }, /* (291) signed ::= NK_MINUS NK_FLOAT */ - { 277, -1 }, /* (292) signed_literal ::= signed */ - { 277, -1 }, /* (293) signed_literal ::= NK_STRING */ - { 277, -1 }, /* (294) signed_literal ::= NK_BOOL */ - { 277, -2 }, /* (295) signed_literal ::= TIMESTAMP NK_STRING */ - { 277, -1 }, /* (296) signed_literal ::= duration_literal */ - { 277, -1 }, /* (297) signed_literal ::= NULL */ - { 277, -1 }, /* (298) signed_literal ::= literal_func */ - { 280, -1 }, /* (299) literal_list ::= signed_literal */ - { 280, -3 }, /* (300) literal_list ::= literal_list NK_COMMA signed_literal */ - { 255, -1 }, /* (301) db_name ::= NK_ID */ - { 283, -1 }, /* (302) table_name ::= NK_ID */ - { 275, -1 }, /* (303) column_name ::= NK_ID */ - { 290, -1 }, /* (304) function_name ::= NK_ID */ - { 316, -1 }, /* (305) table_alias ::= NK_ID */ - { 317, -1 }, /* (306) column_alias ::= NK_ID */ - { 249, -1 }, /* (307) user_name ::= NK_ID */ - { 296, -1 }, /* (308) index_name ::= NK_ID */ - { 302, -1 }, /* (309) topic_name ::= NK_ID */ - { 309, -1 }, /* (310) stream_name ::= NK_ID */ - { 304, -1 }, /* (311) cgroup_name ::= NK_ID */ - { 318, -1 }, /* (312) expression ::= literal */ - { 318, -1 }, /* (313) expression ::= pseudo_column */ - { 318, -1 }, /* (314) expression ::= column_reference */ - { 318, -1 }, /* (315) expression ::= function_expression */ - { 318, -1 }, /* (316) expression ::= subquery */ - { 318, -3 }, /* (317) expression ::= NK_LP expression NK_RP */ - { 318, -2 }, /* (318) expression ::= NK_PLUS expression */ - { 318, -2 }, /* (319) expression ::= NK_MINUS expression */ - { 318, -3 }, /* (320) expression ::= expression NK_PLUS expression */ - { 318, -3 }, /* (321) expression ::= expression NK_MINUS expression */ - { 318, -3 }, /* (322) expression ::= expression NK_STAR expression */ - { 318, -3 }, /* (323) expression ::= expression NK_SLASH expression */ - { 318, -3 }, /* (324) expression ::= expression NK_REM expression */ - { 318, -3 }, /* (325) expression ::= column_reference NK_ARROW NK_STRING */ - { 318, -3 }, /* (326) expression ::= expression NK_BITAND expression */ - { 318, -3 }, /* (327) expression ::= expression NK_BITOR expression */ - { 301, -1 }, /* (328) expression_list ::= expression */ - { 301, -3 }, /* (329) expression_list ::= expression_list NK_COMMA expression */ - { 320, -1 }, /* (330) column_reference ::= column_name */ - { 320, -3 }, /* (331) column_reference ::= table_name NK_DOT column_name */ - { 319, -1 }, /* (332) pseudo_column ::= ROWTS */ - { 319, -1 }, /* (333) pseudo_column ::= TBNAME */ - { 319, -3 }, /* (334) pseudo_column ::= table_name NK_DOT TBNAME */ - { 319, -1 }, /* (335) pseudo_column ::= QSTARTTS */ - { 319, -1 }, /* (336) pseudo_column ::= QENDTS */ - { 319, -1 }, /* (337) pseudo_column ::= WSTARTTS */ - { 319, -1 }, /* (338) pseudo_column ::= WENDTS */ - { 319, -1 }, /* (339) pseudo_column ::= WDURATION */ - { 321, -4 }, /* (340) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 321, -4 }, /* (341) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 321, -6 }, /* (342) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 321, -1 }, /* (343) function_expression ::= literal_func */ - { 315, -3 }, /* (344) literal_func ::= noarg_func NK_LP NK_RP */ - { 315, -1 }, /* (345) literal_func ::= NOW */ - { 325, -1 }, /* (346) noarg_func ::= NOW */ - { 325, -1 }, /* (347) noarg_func ::= TODAY */ - { 325, -1 }, /* (348) noarg_func ::= TIMEZONE */ - { 323, -1 }, /* (349) star_func ::= COUNT */ - { 323, -1 }, /* (350) star_func ::= FIRST */ - { 323, -1 }, /* (351) star_func ::= LAST */ - { 323, -1 }, /* (352) star_func ::= LAST_ROW */ - { 324, -1 }, /* (353) star_func_para_list ::= NK_STAR */ - { 324, -1 }, /* (354) star_func_para_list ::= other_para_list */ - { 326, -1 }, /* (355) other_para_list ::= star_func_para */ - { 326, -3 }, /* (356) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 327, -1 }, /* (357) star_func_para ::= expression */ - { 327, -3 }, /* (358) star_func_para ::= table_name NK_DOT NK_STAR */ - { 328, -3 }, /* (359) predicate ::= expression compare_op expression */ - { 328, -5 }, /* (360) predicate ::= expression BETWEEN expression AND expression */ - { 328, -6 }, /* (361) predicate ::= expression NOT BETWEEN expression AND expression */ - { 328, -3 }, /* (362) predicate ::= expression IS NULL */ - { 328, -4 }, /* (363) predicate ::= expression IS NOT NULL */ - { 328, -3 }, /* (364) predicate ::= expression in_op in_predicate_value */ - { 329, -1 }, /* (365) compare_op ::= NK_LT */ - { 329, -1 }, /* (366) compare_op ::= NK_GT */ - { 329, -1 }, /* (367) compare_op ::= NK_LE */ - { 329, -1 }, /* (368) compare_op ::= NK_GE */ - { 329, -1 }, /* (369) compare_op ::= NK_NE */ - { 329, -1 }, /* (370) compare_op ::= NK_EQ */ - { 329, -1 }, /* (371) compare_op ::= LIKE */ - { 329, -2 }, /* (372) compare_op ::= NOT LIKE */ - { 329, -1 }, /* (373) compare_op ::= MATCH */ - { 329, -1 }, /* (374) compare_op ::= NMATCH */ - { 329, -1 }, /* (375) compare_op ::= CONTAINS */ - { 330, -1 }, /* (376) in_op ::= IN */ - { 330, -2 }, /* (377) in_op ::= NOT IN */ - { 331, -3 }, /* (378) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 332, -1 }, /* (379) boolean_value_expression ::= boolean_primary */ - { 332, -2 }, /* (380) boolean_value_expression ::= NOT boolean_primary */ - { 332, -3 }, /* (381) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 332, -3 }, /* (382) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 333, -1 }, /* (383) boolean_primary ::= predicate */ - { 333, -3 }, /* (384) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 334, -1 }, /* (385) common_expression ::= expression */ - { 334, -1 }, /* (386) common_expression ::= boolean_value_expression */ - { 335, 0 }, /* (387) from_clause_opt ::= */ - { 335, -2 }, /* (388) from_clause_opt ::= FROM table_reference_list */ - { 336, -1 }, /* (389) table_reference_list ::= table_reference */ - { 336, -3 }, /* (390) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 337, -1 }, /* (391) table_reference ::= table_primary */ - { 337, -1 }, /* (392) table_reference ::= joined_table */ - { 338, -2 }, /* (393) table_primary ::= table_name alias_opt */ - { 338, -4 }, /* (394) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 338, -2 }, /* (395) table_primary ::= subquery alias_opt */ - { 338, -1 }, /* (396) table_primary ::= parenthesized_joined_table */ - { 340, 0 }, /* (397) alias_opt ::= */ - { 340, -1 }, /* (398) alias_opt ::= table_alias */ - { 340, -2 }, /* (399) alias_opt ::= AS table_alias */ - { 341, -3 }, /* (400) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 341, -3 }, /* (401) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 339, -6 }, /* (402) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 342, 0 }, /* (403) join_type ::= */ - { 342, -1 }, /* (404) join_type ::= INNER */ - { 344, -12 }, /* (405) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 345, 0 }, /* (406) set_quantifier_opt ::= */ - { 345, -1 }, /* (407) set_quantifier_opt ::= DISTINCT */ - { 345, -1 }, /* (408) set_quantifier_opt ::= ALL */ - { 346, -1 }, /* (409) select_list ::= NK_STAR */ - { 346, -1 }, /* (410) select_list ::= select_sublist */ - { 354, -1 }, /* (411) select_sublist ::= select_item */ - { 354, -3 }, /* (412) select_sublist ::= select_sublist NK_COMMA select_item */ - { 355, -1 }, /* (413) select_item ::= common_expression */ - { 355, -2 }, /* (414) select_item ::= common_expression column_alias */ - { 355, -3 }, /* (415) select_item ::= common_expression AS column_alias */ - { 355, -3 }, /* (416) select_item ::= table_name NK_DOT NK_STAR */ - { 313, 0 }, /* (417) where_clause_opt ::= */ - { 313, -2 }, /* (418) where_clause_opt ::= WHERE search_condition */ - { 347, 0 }, /* (419) partition_by_clause_opt ::= */ - { 347, -3 }, /* (420) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 351, 0 }, /* (421) twindow_clause_opt ::= */ - { 351, -6 }, /* (422) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 351, -4 }, /* (423) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 351, -6 }, /* (424) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 351, -8 }, /* (425) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 299, 0 }, /* (426) sliding_opt ::= */ - { 299, -4 }, /* (427) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 350, 0 }, /* (428) fill_opt ::= */ - { 350, -4 }, /* (429) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 350, -6 }, /* (430) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 356, -1 }, /* (431) fill_mode ::= NONE */ - { 356, -1 }, /* (432) fill_mode ::= PREV */ - { 356, -1 }, /* (433) fill_mode ::= NULL */ - { 356, -1 }, /* (434) fill_mode ::= LINEAR */ - { 356, -1 }, /* (435) fill_mode ::= NEXT */ - { 352, 0 }, /* (436) group_by_clause_opt ::= */ - { 352, -3 }, /* (437) group_by_clause_opt ::= GROUP BY group_by_list */ - { 357, -1 }, /* (438) group_by_list ::= expression */ - { 357, -3 }, /* (439) group_by_list ::= group_by_list NK_COMMA expression */ - { 353, 0 }, /* (440) having_clause_opt ::= */ - { 353, -2 }, /* (441) having_clause_opt ::= HAVING search_condition */ - { 348, 0 }, /* (442) range_opt ::= */ - { 348, -6 }, /* (443) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 349, 0 }, /* (444) every_opt ::= */ - { 349, -4 }, /* (445) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 303, -4 }, /* (446) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 358, -1 }, /* (447) query_expression_body ::= query_primary */ - { 358, -4 }, /* (448) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 358, -3 }, /* (449) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 362, -1 }, /* (450) query_primary ::= query_specification */ - { 362, -6 }, /* (451) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 359, 0 }, /* (452) order_by_clause_opt ::= */ - { 359, -3 }, /* (453) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 360, 0 }, /* (454) slimit_clause_opt ::= */ - { 360, -2 }, /* (455) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 360, -4 }, /* (456) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 360, -4 }, /* (457) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 361, 0 }, /* (458) limit_clause_opt ::= */ - { 361, -2 }, /* (459) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 361, -4 }, /* (460) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 361, -4 }, /* (461) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 322, -3 }, /* (462) subquery ::= NK_LP query_expression NK_RP */ - { 343, -1 }, /* (463) search_condition ::= common_expression */ - { 363, -1 }, /* (464) sort_specification_list ::= sort_specification */ - { 363, -3 }, /* (465) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 364, -3 }, /* (466) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 365, 0 }, /* (467) ordering_specification_opt ::= */ - { 365, -1 }, /* (468) ordering_specification_opt ::= ASC */ - { 365, -1 }, /* (469) ordering_specification_opt ::= DESC */ - { 366, 0 }, /* (470) null_ordering_opt ::= */ - { 366, -2 }, /* (471) null_ordering_opt ::= NULLS FIRST */ - { 366, -2 }, /* (472) null_ordering_opt ::= NULLS LAST */ + { 246, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 246, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 247, 0 }, /* (2) account_options ::= */ + { 247, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 247, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 247, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 247, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 247, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 247, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 247, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 247, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 247, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 248, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 248, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 250, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 250, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 250, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 250, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 250, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 250, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 250, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 250, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 250, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 250, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 246, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 246, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 246, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 246, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 246, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 252, 0 }, /* (29) sysinfo_opt ::= */ + { 252, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 246, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 246, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 253, -1 }, /* (33) privileges ::= ALL */ + { 253, -1 }, /* (34) privileges ::= priv_type_list */ + { 255, -1 }, /* (35) priv_type_list ::= priv_type */ + { 255, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 256, -1 }, /* (37) priv_type ::= READ */ + { 256, -1 }, /* (38) priv_type ::= WRITE */ + { 254, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 254, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 246, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 246, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 246, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 246, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 246, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 246, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 246, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 246, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 258, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 258, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 258, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 246, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 246, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 246, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 246, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 246, -2 }, /* (64) cmd ::= USE db_name */ + { 246, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 259, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ + { 259, 0 }, /* (67) not_exists_opt ::= */ + { 261, -2 }, /* (68) exists_opt ::= IF EXISTS */ + { 261, 0 }, /* (69) exists_opt ::= */ + { 260, 0 }, /* (70) db_options ::= */ + { 260, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ + { 260, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ + { 260, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ + { 260, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ + { 260, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ + { 260, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ + { 260, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ + { 260, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ + { 260, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ + { 260, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ + { 260, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ + { 260, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 260, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ + { 260, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ + { 260, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ + { 260, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ + { 260, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ + { 260, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 260, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ + { 260, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 262, -1 }, /* (91) alter_db_options ::= alter_db_option */ + { 262, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ + { 266, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ + { 266, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ + { 266, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ + { 266, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ + { 266, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ + { 266, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ + { 266, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ + { 266, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ + { 266, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ + { 263, -1 }, /* (102) integer_list ::= NK_INTEGER */ + { 263, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 264, -1 }, /* (104) variable_list ::= NK_VARIABLE */ + { 264, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 265, -1 }, /* (106) retention_list ::= retention */ + { 265, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ + { 267, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 246, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 246, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ + { 246, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 246, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ + { 246, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ + { 246, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ + { 246, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ + { 275, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ + { 275, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 275, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 275, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 275, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 275, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 275, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 275, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 275, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 275, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 272, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ + { 272, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 280, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 274, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ + { 274, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 283, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ + { 281, 0 }, /* (132) specific_tags_opt ::= */ + { 281, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 268, -1 }, /* (134) full_table_name ::= table_name */ + { 268, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ + { 269, -1 }, /* (136) column_def_list ::= column_def */ + { 269, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ + { 286, -2 }, /* (138) column_def ::= column_name type_name */ + { 286, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ + { 278, -1 }, /* (140) type_name ::= BOOL */ + { 278, -1 }, /* (141) type_name ::= TINYINT */ + { 278, -1 }, /* (142) type_name ::= SMALLINT */ + { 278, -1 }, /* (143) type_name ::= INT */ + { 278, -1 }, /* (144) type_name ::= INTEGER */ + { 278, -1 }, /* (145) type_name ::= BIGINT */ + { 278, -1 }, /* (146) type_name ::= FLOAT */ + { 278, -1 }, /* (147) type_name ::= DOUBLE */ + { 278, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (149) type_name ::= TIMESTAMP */ + { 278, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 278, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ + { 278, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ + { 278, -2 }, /* (153) type_name ::= INT UNSIGNED */ + { 278, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ + { 278, -1 }, /* (155) type_name ::= JSON */ + { 278, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (157) type_name ::= MEDIUMBLOB */ + { 278, -1 }, /* (158) type_name ::= BLOB */ + { 278, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (160) type_name ::= DECIMAL */ + { 278, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 278, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 270, 0 }, /* (163) tags_def_opt ::= */ + { 270, -1 }, /* (164) tags_def_opt ::= tags_def */ + { 273, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 271, 0 }, /* (166) table_options ::= */ + { 271, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ + { 271, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ + { 271, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ + { 271, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 271, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ + { 271, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 276, -1 }, /* (173) alter_table_options ::= alter_table_option */ + { 276, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ + { 289, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ + { 289, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ + { 287, -1 }, /* (177) duration_list ::= duration_literal */ + { 287, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ + { 288, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ + { 288, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 291, -1 }, /* (181) rollup_func_name ::= function_name */ + { 291, -1 }, /* (182) rollup_func_name ::= FIRST */ + { 291, -1 }, /* (183) rollup_func_name ::= LAST */ + { 284, -1 }, /* (184) col_name_list ::= col_name */ + { 284, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ + { 293, -1 }, /* (186) col_name ::= column_name */ + { 246, -2 }, /* (187) cmd ::= SHOW DNODES */ + { 246, -2 }, /* (188) cmd ::= SHOW USERS */ + { 246, -2 }, /* (189) cmd ::= SHOW DATABASES */ + { 246, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 246, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 246, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 246, -2 }, /* (193) cmd ::= SHOW MNODES */ + { 246, -2 }, /* (194) cmd ::= SHOW MODULES */ + { 246, -2 }, /* (195) cmd ::= SHOW QNODES */ + { 246, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ + { 246, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 246, -2 }, /* (198) cmd ::= SHOW STREAMS */ + { 246, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ + { 246, -2 }, /* (200) cmd ::= SHOW APPS */ + { 246, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ + { 246, -2 }, /* (202) cmd ::= SHOW LICENCE */ + { 246, -2 }, /* (203) cmd ::= SHOW GRANTS */ + { 246, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ + { 246, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ + { 246, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ + { 246, -2 }, /* (207) cmd ::= SHOW QUERIES */ + { 246, -2 }, /* (208) cmd ::= SHOW SCORES */ + { 246, -2 }, /* (209) cmd ::= SHOW TOPICS */ + { 246, -2 }, /* (210) cmd ::= SHOW VARIABLES */ + { 246, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ + { 246, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 246, -2 }, /* (213) cmd ::= SHOW BNODES */ + { 246, -2 }, /* (214) cmd ::= SHOW SNODES */ + { 246, -2 }, /* (215) cmd ::= SHOW CLUSTER */ + { 246, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ + { 246, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 246, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ + { 246, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ + { 294, 0 }, /* (220) db_name_cond_opt ::= */ + { 294, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ + { 295, 0 }, /* (222) like_pattern_opt ::= */ + { 295, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ + { 296, -1 }, /* (224) table_name_cond ::= table_name */ + { 297, 0 }, /* (225) from_db_opt ::= */ + { 297, -2 }, /* (226) from_db_opt ::= FROM db_name */ + { 246, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 246, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ + { 299, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 299, -12 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 300, -1 }, /* (231) func_list ::= func */ + { 300, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ + { 303, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ + { 302, 0 }, /* (234) sma_stream_opt ::= */ + { 302, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 302, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 246, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 246, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 246, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 246, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 246, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 246, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ + { 246, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 246, -2 }, /* (244) cmd ::= DESC full_table_name */ + { 246, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ + { 246, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ + { 246, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 309, 0 }, /* (248) analyze_opt ::= */ + { 309, -1 }, /* (249) analyze_opt ::= ANALYZE */ + { 310, 0 }, /* (250) explain_options ::= */ + { 310, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 310, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ + { 246, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 246, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 246, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ + { 311, 0 }, /* (256) agg_func_opt ::= */ + { 311, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ + { 312, 0 }, /* (258) bufsize_opt ::= */ + { 312, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 246, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 246, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ + { 314, 0 }, /* (262) into_opt ::= */ + { 314, -2 }, /* (263) into_opt ::= INTO full_table_name */ + { 305, 0 }, /* (264) stream_options ::= */ + { 305, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 305, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 305, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 305, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ + { 246, -3 }, /* (269) cmd ::= KILL CONNECTION NK_INTEGER */ + { 246, -3 }, /* (270) cmd ::= KILL QUERY NK_STRING */ + { 246, -3 }, /* (271) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 246, -2 }, /* (272) cmd ::= BALANCE VGROUP */ + { 246, -4 }, /* (273) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 246, -4 }, /* (274) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 246, -3 }, /* (275) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 315, -2 }, /* (276) dnode_list ::= DNODE NK_INTEGER */ + { 315, -3 }, /* (277) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 246, -3 }, /* (278) cmd ::= SYNCDB db_name REPLICA */ + { 246, -4 }, /* (279) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 246, -1 }, /* (280) cmd ::= query_expression */ + { 249, -1 }, /* (281) literal ::= NK_INTEGER */ + { 249, -1 }, /* (282) literal ::= NK_FLOAT */ + { 249, -1 }, /* (283) literal ::= NK_STRING */ + { 249, -1 }, /* (284) literal ::= NK_BOOL */ + { 249, -2 }, /* (285) literal ::= TIMESTAMP NK_STRING */ + { 249, -1 }, /* (286) literal ::= duration_literal */ + { 249, -1 }, /* (287) literal ::= NULL */ + { 249, -1 }, /* (288) literal ::= NK_QUESTION */ + { 290, -1 }, /* (289) duration_literal ::= NK_VARIABLE */ + { 317, -1 }, /* (290) signed ::= NK_INTEGER */ + { 317, -2 }, /* (291) signed ::= NK_PLUS NK_INTEGER */ + { 317, -2 }, /* (292) signed ::= NK_MINUS NK_INTEGER */ + { 317, -1 }, /* (293) signed ::= NK_FLOAT */ + { 317, -2 }, /* (294) signed ::= NK_PLUS NK_FLOAT */ + { 317, -2 }, /* (295) signed ::= NK_MINUS NK_FLOAT */ + { 279, -1 }, /* (296) signed_literal ::= signed */ + { 279, -1 }, /* (297) signed_literal ::= NK_STRING */ + { 279, -1 }, /* (298) signed_literal ::= NK_BOOL */ + { 279, -2 }, /* (299) signed_literal ::= TIMESTAMP NK_STRING */ + { 279, -1 }, /* (300) signed_literal ::= duration_literal */ + { 279, -1 }, /* (301) signed_literal ::= NULL */ + { 279, -1 }, /* (302) signed_literal ::= literal_func */ + { 282, -1 }, /* (303) literal_list ::= signed_literal */ + { 282, -3 }, /* (304) literal_list ::= literal_list NK_COMMA signed_literal */ + { 257, -1 }, /* (305) db_name ::= NK_ID */ + { 285, -1 }, /* (306) table_name ::= NK_ID */ + { 277, -1 }, /* (307) column_name ::= NK_ID */ + { 292, -1 }, /* (308) function_name ::= NK_ID */ + { 319, -1 }, /* (309) table_alias ::= NK_ID */ + { 320, -1 }, /* (310) column_alias ::= NK_ID */ + { 251, -1 }, /* (311) user_name ::= NK_ID */ + { 298, -1 }, /* (312) index_name ::= NK_ID */ + { 306, -1 }, /* (313) topic_name ::= NK_ID */ + { 313, -1 }, /* (314) stream_name ::= NK_ID */ + { 308, -1 }, /* (315) cgroup_name ::= NK_ID */ + { 321, -1 }, /* (316) expression ::= literal */ + { 321, -1 }, /* (317) expression ::= pseudo_column */ + { 321, -1 }, /* (318) expression ::= column_reference */ + { 321, -1 }, /* (319) expression ::= function_expression */ + { 321, -1 }, /* (320) expression ::= subquery */ + { 321, -3 }, /* (321) expression ::= NK_LP expression NK_RP */ + { 321, -2 }, /* (322) expression ::= NK_PLUS expression */ + { 321, -2 }, /* (323) expression ::= NK_MINUS expression */ + { 321, -3 }, /* (324) expression ::= expression NK_PLUS expression */ + { 321, -3 }, /* (325) expression ::= expression NK_MINUS expression */ + { 321, -3 }, /* (326) expression ::= expression NK_STAR expression */ + { 321, -3 }, /* (327) expression ::= expression NK_SLASH expression */ + { 321, -3 }, /* (328) expression ::= expression NK_REM expression */ + { 321, -3 }, /* (329) expression ::= column_reference NK_ARROW NK_STRING */ + { 321, -3 }, /* (330) expression ::= expression NK_BITAND expression */ + { 321, -3 }, /* (331) expression ::= expression NK_BITOR expression */ + { 304, -1 }, /* (332) expression_list ::= expression */ + { 304, -3 }, /* (333) expression_list ::= expression_list NK_COMMA expression */ + { 323, -1 }, /* (334) column_reference ::= column_name */ + { 323, -3 }, /* (335) column_reference ::= table_name NK_DOT column_name */ + { 322, -1 }, /* (336) pseudo_column ::= ROWTS */ + { 322, -1 }, /* (337) pseudo_column ::= TBNAME */ + { 322, -3 }, /* (338) pseudo_column ::= table_name NK_DOT TBNAME */ + { 322, -1 }, /* (339) pseudo_column ::= QSTARTTS */ + { 322, -1 }, /* (340) pseudo_column ::= QENDTS */ + { 322, -1 }, /* (341) pseudo_column ::= WSTARTTS */ + { 322, -1 }, /* (342) pseudo_column ::= WENDTS */ + { 322, -1 }, /* (343) pseudo_column ::= WDURATION */ + { 324, -4 }, /* (344) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 324, -4 }, /* (345) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 324, -6 }, /* (346) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 324, -1 }, /* (347) function_expression ::= literal_func */ + { 318, -3 }, /* (348) literal_func ::= noarg_func NK_LP NK_RP */ + { 318, -1 }, /* (349) literal_func ::= NOW */ + { 328, -1 }, /* (350) noarg_func ::= NOW */ + { 328, -1 }, /* (351) noarg_func ::= TODAY */ + { 328, -1 }, /* (352) noarg_func ::= TIMEZONE */ + { 326, -1 }, /* (353) star_func ::= COUNT */ + { 326, -1 }, /* (354) star_func ::= FIRST */ + { 326, -1 }, /* (355) star_func ::= LAST */ + { 326, -1 }, /* (356) star_func ::= LAST_ROW */ + { 327, -1 }, /* (357) star_func_para_list ::= NK_STAR */ + { 327, -1 }, /* (358) star_func_para_list ::= other_para_list */ + { 329, -1 }, /* (359) other_para_list ::= star_func_para */ + { 329, -3 }, /* (360) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 330, -1 }, /* (361) star_func_para ::= expression */ + { 330, -3 }, /* (362) star_func_para ::= table_name NK_DOT NK_STAR */ + { 331, -3 }, /* (363) predicate ::= expression compare_op expression */ + { 331, -5 }, /* (364) predicate ::= expression BETWEEN expression AND expression */ + { 331, -6 }, /* (365) predicate ::= expression NOT BETWEEN expression AND expression */ + { 331, -3 }, /* (366) predicate ::= expression IS NULL */ + { 331, -4 }, /* (367) predicate ::= expression IS NOT NULL */ + { 331, -3 }, /* (368) predicate ::= expression in_op in_predicate_value */ + { 332, -1 }, /* (369) compare_op ::= NK_LT */ + { 332, -1 }, /* (370) compare_op ::= NK_GT */ + { 332, -1 }, /* (371) compare_op ::= NK_LE */ + { 332, -1 }, /* (372) compare_op ::= NK_GE */ + { 332, -1 }, /* (373) compare_op ::= NK_NE */ + { 332, -1 }, /* (374) compare_op ::= NK_EQ */ + { 332, -1 }, /* (375) compare_op ::= LIKE */ + { 332, -2 }, /* (376) compare_op ::= NOT LIKE */ + { 332, -1 }, /* (377) compare_op ::= MATCH */ + { 332, -1 }, /* (378) compare_op ::= NMATCH */ + { 332, -1 }, /* (379) compare_op ::= CONTAINS */ + { 333, -1 }, /* (380) in_op ::= IN */ + { 333, -2 }, /* (381) in_op ::= NOT IN */ + { 334, -3 }, /* (382) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 335, -1 }, /* (383) boolean_value_expression ::= boolean_primary */ + { 335, -2 }, /* (384) boolean_value_expression ::= NOT boolean_primary */ + { 335, -3 }, /* (385) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 335, -3 }, /* (386) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 336, -1 }, /* (387) boolean_primary ::= predicate */ + { 336, -3 }, /* (388) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 337, -1 }, /* (389) common_expression ::= expression */ + { 337, -1 }, /* (390) common_expression ::= boolean_value_expression */ + { 338, 0 }, /* (391) from_clause_opt ::= */ + { 338, -2 }, /* (392) from_clause_opt ::= FROM table_reference_list */ + { 339, -1 }, /* (393) table_reference_list ::= table_reference */ + { 339, -3 }, /* (394) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 340, -1 }, /* (395) table_reference ::= table_primary */ + { 340, -1 }, /* (396) table_reference ::= joined_table */ + { 341, -2 }, /* (397) table_primary ::= table_name alias_opt */ + { 341, -4 }, /* (398) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 341, -2 }, /* (399) table_primary ::= subquery alias_opt */ + { 341, -1 }, /* (400) table_primary ::= parenthesized_joined_table */ + { 343, 0 }, /* (401) alias_opt ::= */ + { 343, -1 }, /* (402) alias_opt ::= table_alias */ + { 343, -2 }, /* (403) alias_opt ::= AS table_alias */ + { 344, -3 }, /* (404) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 344, -3 }, /* (405) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 342, -6 }, /* (406) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 345, 0 }, /* (407) join_type ::= */ + { 345, -1 }, /* (408) join_type ::= INNER */ + { 347, -12 }, /* (409) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 348, 0 }, /* (410) set_quantifier_opt ::= */ + { 348, -1 }, /* (411) set_quantifier_opt ::= DISTINCT */ + { 348, -1 }, /* (412) set_quantifier_opt ::= ALL */ + { 349, -1 }, /* (413) select_list ::= NK_STAR */ + { 349, -1 }, /* (414) select_list ::= select_sublist */ + { 357, -1 }, /* (415) select_sublist ::= select_item */ + { 357, -3 }, /* (416) select_sublist ::= select_sublist NK_COMMA select_item */ + { 358, -1 }, /* (417) select_item ::= common_expression */ + { 358, -2 }, /* (418) select_item ::= common_expression column_alias */ + { 358, -3 }, /* (419) select_item ::= common_expression AS column_alias */ + { 358, -3 }, /* (420) select_item ::= table_name NK_DOT NK_STAR */ + { 316, 0 }, /* (421) where_clause_opt ::= */ + { 316, -2 }, /* (422) where_clause_opt ::= WHERE search_condition */ + { 350, 0 }, /* (423) partition_by_clause_opt ::= */ + { 350, -3 }, /* (424) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 354, 0 }, /* (425) twindow_clause_opt ::= */ + { 354, -6 }, /* (426) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 354, -4 }, /* (427) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 354, -6 }, /* (428) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 354, -8 }, /* (429) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 301, 0 }, /* (430) sliding_opt ::= */ + { 301, -4 }, /* (431) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 353, 0 }, /* (432) fill_opt ::= */ + { 353, -4 }, /* (433) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 353, -6 }, /* (434) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 359, -1 }, /* (435) fill_mode ::= NONE */ + { 359, -1 }, /* (436) fill_mode ::= PREV */ + { 359, -1 }, /* (437) fill_mode ::= NULL */ + { 359, -1 }, /* (438) fill_mode ::= LINEAR */ + { 359, -1 }, /* (439) fill_mode ::= NEXT */ + { 355, 0 }, /* (440) group_by_clause_opt ::= */ + { 355, -3 }, /* (441) group_by_clause_opt ::= GROUP BY group_by_list */ + { 360, -1 }, /* (442) group_by_list ::= expression */ + { 360, -3 }, /* (443) group_by_list ::= group_by_list NK_COMMA expression */ + { 356, 0 }, /* (444) having_clause_opt ::= */ + { 356, -2 }, /* (445) having_clause_opt ::= HAVING search_condition */ + { 351, 0 }, /* (446) range_opt ::= */ + { 351, -6 }, /* (447) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 352, 0 }, /* (448) every_opt ::= */ + { 352, -4 }, /* (449) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 307, -4 }, /* (450) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 361, -1 }, /* (451) query_expression_body ::= query_primary */ + { 361, -4 }, /* (452) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 361, -3 }, /* (453) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 365, -1 }, /* (454) query_primary ::= query_specification */ + { 365, -6 }, /* (455) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 362, 0 }, /* (456) order_by_clause_opt ::= */ + { 362, -3 }, /* (457) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 363, 0 }, /* (458) slimit_clause_opt ::= */ + { 363, -2 }, /* (459) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 363, -4 }, /* (460) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 363, -4 }, /* (461) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 364, 0 }, /* (462) limit_clause_opt ::= */ + { 364, -2 }, /* (463) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 364, -4 }, /* (464) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 364, -4 }, /* (465) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 325, -3 }, /* (466) subquery ::= NK_LP query_expression NK_RP */ + { 346, -1 }, /* (467) search_condition ::= common_expression */ + { 366, -1 }, /* (468) sort_specification_list ::= sort_specification */ + { 366, -3 }, /* (469) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 367, -3 }, /* (470) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 368, 0 }, /* (471) ordering_specification_opt ::= */ + { 368, -1 }, /* (472) ordering_specification_opt ::= ASC */ + { 368, -1 }, /* (473) ordering_specification_opt ::= DESC */ + { 369, 0 }, /* (474) null_ordering_opt ::= */ + { 369, -2 }, /* (475) null_ordering_opt ::= NULLS FIRST */ + { 369, -2 }, /* (476) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3198,11 +3204,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,245,&yymsp[0].minor); + yy_destructor(yypParser,247,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,246,&yymsp[0].minor); + yy_destructor(yypParser,248,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3216,20 +3222,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,245,&yymsp[-2].minor); +{ yy_destructor(yypParser,247,&yymsp[-2].minor); { } - yy_destructor(yypParser,247,&yymsp[0].minor); + yy_destructor(yypParser,249,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,248,&yymsp[0].minor); +{ yy_destructor(yypParser,250,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,246,&yymsp[-1].minor); +{ yy_destructor(yypParser,248,&yymsp[-1].minor); { } - yy_destructor(yypParser,248,&yymsp[0].minor); + yy_destructor(yypParser,250,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3243,72 +3249,72 @@ 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,247,&yymsp[0].minor); + yy_destructor(yypParser,249,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy0, yymsp[0].minor.yy629); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy0, yymsp[0].minor.yy323); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy109); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy629 = 1; } +{ yymsp[1].minor.yy323 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy629 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy323 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy683 = yymsp[0].minor.yy683; } - yymsp[0].minor.yy683 = yylhsminor.yy683; +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy683 = yymsp[-2].minor.yy683 | yymsp[0].minor.yy683; } - yymsp[-2].minor.yy683 = yylhsminor.yy683; +{ yylhsminor.yy209 = yymsp[-2].minor.yy209 | yymsp[0].minor.yy209; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy241 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy241 = yylhsminor.yy241; +{ yylhsminor.yy109 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy109 = yylhsminor.yy109; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy241 = yymsp[-2].minor.yy241; } - yymsp[-2].minor.yy241 = yylhsminor.yy241; +{ yylhsminor.yy109 = yymsp[-2].minor.yy109; } + yymsp[-2].minor.yy109 = yylhsminor.yy109; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy241, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy109, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy109); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3325,26 +3331,26 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 301: /* db_name ::= NK_ID */ yytestcase(yyruleno==301); - case 302: /* table_name ::= NK_ID */ yytestcase(yyruleno==302); - case 303: /* column_name ::= NK_ID */ yytestcase(yyruleno==303); - case 304: /* function_name ::= NK_ID */ yytestcase(yyruleno==304); - case 305: /* table_alias ::= NK_ID */ yytestcase(yyruleno==305); - case 306: /* column_alias ::= NK_ID */ yytestcase(yyruleno==306); - case 307: /* user_name ::= NK_ID */ yytestcase(yyruleno==307); - case 308: /* index_name ::= NK_ID */ yytestcase(yyruleno==308); - case 309: /* topic_name ::= NK_ID */ yytestcase(yyruleno==309); - case 310: /* stream_name ::= NK_ID */ yytestcase(yyruleno==310); - case 311: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==311); - case 346: /* noarg_func ::= NOW */ yytestcase(yyruleno==346); - case 347: /* noarg_func ::= TODAY */ yytestcase(yyruleno==347); - case 348: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==348); - case 349: /* star_func ::= COUNT */ yytestcase(yyruleno==349); - case 350: /* star_func ::= FIRST */ yytestcase(yyruleno==350); - case 351: /* star_func ::= LAST */ yytestcase(yyruleno==351); - case 352: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==352); -{ yylhsminor.yy241 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 305: /* db_name ::= NK_ID */ yytestcase(yyruleno==305); + case 306: /* table_name ::= NK_ID */ yytestcase(yyruleno==306); + case 307: /* column_name ::= NK_ID */ yytestcase(yyruleno==307); + case 308: /* function_name ::= NK_ID */ yytestcase(yyruleno==308); + case 309: /* table_alias ::= NK_ID */ yytestcase(yyruleno==309); + case 310: /* column_alias ::= NK_ID */ yytestcase(yyruleno==310); + case 311: /* user_name ::= NK_ID */ yytestcase(yyruleno==311); + case 312: /* index_name ::= NK_ID */ yytestcase(yyruleno==312); + case 313: /* topic_name ::= NK_ID */ yytestcase(yyruleno==313); + case 314: /* stream_name ::= NK_ID */ yytestcase(yyruleno==314); + case 315: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==315); + case 350: /* noarg_func ::= NOW */ yytestcase(yyruleno==350); + case 351: /* noarg_func ::= TODAY */ yytestcase(yyruleno==351); + case 352: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==352); + case 353: /* star_func ::= COUNT */ yytestcase(yyruleno==353); + case 354: /* star_func ::= FIRST */ yytestcase(yyruleno==354); + case 355: /* star_func ::= LAST */ yytestcase(yyruleno==355); + case 356: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==356); +{ yylhsminor.yy109 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy109 = yylhsminor.yy109; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3377,156 +3383,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy197, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy437, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } break; case 66: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy197 = true; } +{ yymsp[-2].minor.yy437 = true; } break; case 67: /* not_exists_opt ::= */ case 69: /* exists_opt ::= */ yytestcase(yyruleno==69); - case 244: /* analyze_opt ::= */ yytestcase(yyruleno==244); - case 252: /* agg_func_opt ::= */ yytestcase(yyruleno==252); - case 406: /* set_quantifier_opt ::= */ yytestcase(yyruleno==406); -{ yymsp[1].minor.yy197 = false; } + case 248: /* analyze_opt ::= */ yytestcase(yyruleno==248); + case 256: /* agg_func_opt ::= */ yytestcase(yyruleno==256); + case 410: /* set_quantifier_opt ::= */ yytestcase(yyruleno==410); +{ yymsp[1].minor.yy437 = false; } break; case 68: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy197 = true; } +{ yymsp[-1].minor.yy437 = true; } break; case 70: /* db_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy452 = createDefaultDatabaseOptions(pCxt); } break; case 71: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 72: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 73: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 74: /* db_options ::= db_options DURATION NK_INTEGER */ case 75: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==75); -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 76: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 77: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 78: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 79: /* db_options ::= db_options KEEP integer_list */ case 80: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==80); -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_KEEP, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_KEEP, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 81: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 82: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 83: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 84: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 85: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 86: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 87: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 88: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 89: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_RETENTIONS, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_RETENTIONS, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 90: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 91: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy442 = createAlterDatabaseOptions(pCxt); yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yylhsminor.yy442, &yymsp[0].minor.yy301); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterDatabaseOptions(pCxt); yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yylhsminor.yy452, &yymsp[0].minor.yy85); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 92: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy442, &yymsp[0].minor.yy301); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy452, &yymsp[0].minor.yy85); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 93: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 94: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 95: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= KEEP integer_list */ case 97: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==97); -{ yymsp[-1].minor.yy301.type = DB_OPTION_KEEP; yymsp[-1].minor.yy301.pList = yymsp[0].minor.yy368; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_KEEP; yymsp[-1].minor.yy85.pList = yymsp[0].minor.yy404; } break; case 98: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_PAGES; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_PAGES; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 99: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 100: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_STRICT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_STRICT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 101: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_WAL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_WAL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 102: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 273: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==273); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 277: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==277); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 104: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy368 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 106: /* retention_list ::= retention */ case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); @@ -3534,266 +3540,266 @@ static YYACTIONTYPE yy_reduce( case 136: /* column_def_list ::= column_def */ yytestcase(yyruleno==136); case 179: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==179); case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); - case 230: /* func_list ::= func */ yytestcase(yyruleno==230); - case 299: /* literal_list ::= signed_literal */ yytestcase(yyruleno==299); - case 355: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==355); - case 411: /* select_sublist ::= select_item */ yytestcase(yyruleno==411); - case 464: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==464); -{ yylhsminor.yy368 = createNodeList(pCxt, yymsp[0].minor.yy442); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 231: /* func_list ::= func */ yytestcase(yyruleno==231); + case 303: /* literal_list ::= signed_literal */ yytestcase(yyruleno==303); + case 359: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==359); + case 415: /* select_sublist ::= select_item */ yytestcase(yyruleno==415); + case 468: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==468); +{ yylhsminor.yy404 = createNodeList(pCxt, yymsp[0].minor.yy452); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 107: /* retention_list ::= retention_list NK_COMMA retention */ case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); case 180: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==180); case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); - case 231: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==231); - case 300: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==300); - case 356: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==356); - case 412: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==412); - case 465: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==465); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 232: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==232); + case 304: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==304); + case 360: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==360); + case 416: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==416); + case 469: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==469); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy442 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-5].minor.yy442, yymsp[-3].minor.yy368, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-5].minor.yy452, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } break; case 110: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy368); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy404); } break; case 112: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy368); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy404); } break; case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } break; case 114: /* cmd ::= ALTER TABLE alter_table_clause */ case 115: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==115); - case 276: /* cmd ::= query_expression */ yytestcase(yyruleno==276); -{ pCxt->pRootNode = yymsp[0].minor.yy442; } + case 280: /* cmd ::= query_expression */ yytestcase(yyruleno==280); +{ pCxt->pRootNode = yymsp[0].minor.yy452; } break; case 116: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy442 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy442 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy442, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy452, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; case 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy404 = yylhsminor.yy404; break; case 128: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy442 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy197, yymsp[-8].minor.yy442, yymsp[-6].minor.yy442, yymsp[-5].minor.yy368, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-9].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy437, yymsp[-8].minor.yy452, yymsp[-6].minor.yy452, yymsp[-5].minor.yy404, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-9].minor.yy452 = yylhsminor.yy452; break; case 131: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy442 = createDropTableClause(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createDropTableClause(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 132: /* specific_tags_opt ::= */ case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); - case 419: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==419); - case 436: /* group_by_clause_opt ::= */ yytestcase(yyruleno==436); - case 452: /* order_by_clause_opt ::= */ yytestcase(yyruleno==452); -{ yymsp[1].minor.yy368 = NULL; } + case 423: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==423); + case 440: /* group_by_clause_opt ::= */ yytestcase(yyruleno==440); + case 456: /* order_by_clause_opt ::= */ yytestcase(yyruleno==456); +{ yymsp[1].minor.yy404 = NULL; } break; case 133: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy368 = yymsp[-1].minor.yy368; } +{ yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404; } break; case 134: /* full_table_name ::= table_name */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy109, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 135: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, NULL); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, NULL); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 138: /* column_def ::= column_name type_name */ -{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392, NULL); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504, NULL); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-2].minor.yy392, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-2].minor.yy504, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 140: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 141: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 142: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 143: /* type_name ::= INT */ case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_INT); } break; case 145: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 146: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 147: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 149: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 151: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 152: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 153: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 154: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 155: /* type_name ::= JSON */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 158: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 160: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 164: /* tags_def_opt ::= tags_def */ - case 354: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==354); - case 410: /* select_list ::= select_sublist */ yytestcase(yyruleno==410); -{ yylhsminor.yy368 = yymsp[0].minor.yy368; } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 358: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==358); + case 414: /* select_list ::= select_sublist */ yytestcase(yyruleno==414); +{ yylhsminor.yy404 = yymsp[0].minor.yy404; } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy368 = yymsp[-1].minor.yy368; } +{ yymsp[-3].minor.yy404 = yymsp[-1].minor.yy404; } break; case 166: /* table_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy452 = createDefaultTableOptions(pCxt); } break; case 167: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 168: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 169: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy368); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy404); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 171: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_SMA, yymsp[-1].minor.yy368); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_SMA, yymsp[-1].minor.yy404); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 173: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy442 = createAlterTableOptions(pCxt); yylhsminor.yy442 = setTableOption(pCxt, yylhsminor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableOptions(pCxt); yylhsminor.yy452 = setTableOption(pCxt, yylhsminor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 174: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 175: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 176: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 177: /* duration_list ::= duration_literal */ - case 328: /* expression_list ::= expression */ yytestcase(yyruleno==328); -{ yylhsminor.yy368 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 332: /* expression_list ::= expression */ yytestcase(yyruleno==332); +{ yylhsminor.yy404 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 329: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==329); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 333: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==333); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 181: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy109, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 182: /* rollup_func_name ::= FIRST */ case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 186: /* col_name ::= column_name */ -{ yylhsminor.yy442 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 187: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -3805,13 +3811,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } break; case 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } break; case 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy442, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy452, NULL, OP_TYPE_LIKE); } break; case 193: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -3826,7 +3832,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy442, yymsp[-1].minor.yy442, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy452, yymsp[-1].minor.yy452, OP_TYPE_EQUAL); } break; case 198: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -3845,13 +3851,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } break; case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy452); } break; case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy452); } break; case 207: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -3884,697 +3890,708 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy452); } break; - case 218: /* db_name_cond_opt ::= */ - case 223: /* from_db_opt ::= */ yytestcase(yyruleno==223); -{ yymsp[1].minor.yy442 = createDefaultDatabaseCondValue(pCxt); } + case 218: /* cmd ::= SHOW CONSUMERS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 219: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 219: /* cmd ::= SHOW SUBSCRIPTIONS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 220: /* like_pattern_opt ::= */ - case 227: /* index_options ::= */ yytestcase(yyruleno==227); - case 258: /* into_opt ::= */ yytestcase(yyruleno==258); - case 387: /* from_clause_opt ::= */ yytestcase(yyruleno==387); - case 417: /* where_clause_opt ::= */ yytestcase(yyruleno==417); - case 421: /* twindow_clause_opt ::= */ yytestcase(yyruleno==421); - case 426: /* sliding_opt ::= */ yytestcase(yyruleno==426); - case 428: /* fill_opt ::= */ yytestcase(yyruleno==428); - case 440: /* having_clause_opt ::= */ yytestcase(yyruleno==440); - case 442: /* range_opt ::= */ yytestcase(yyruleno==442); - case 444: /* every_opt ::= */ yytestcase(yyruleno==444); - case 454: /* slimit_clause_opt ::= */ yytestcase(yyruleno==454); - case 458: /* limit_clause_opt ::= */ yytestcase(yyruleno==458); -{ yymsp[1].minor.yy442 = NULL; } + case 220: /* db_name_cond_opt ::= */ + case 225: /* from_db_opt ::= */ yytestcase(yyruleno==225); +{ yymsp[1].minor.yy452 = createDefaultDatabaseCondValue(pCxt); } break; - case 221: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 221: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 222: /* table_name_cond ::= table_name */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 222: /* like_pattern_opt ::= */ + case 262: /* into_opt ::= */ yytestcase(yyruleno==262); + case 391: /* from_clause_opt ::= */ yytestcase(yyruleno==391); + case 421: /* where_clause_opt ::= */ yytestcase(yyruleno==421); + case 425: /* twindow_clause_opt ::= */ yytestcase(yyruleno==425); + case 430: /* sliding_opt ::= */ yytestcase(yyruleno==430); + case 432: /* fill_opt ::= */ yytestcase(yyruleno==432); + case 444: /* having_clause_opt ::= */ yytestcase(yyruleno==444); + case 446: /* range_opt ::= */ yytestcase(yyruleno==446); + case 448: /* every_opt ::= */ yytestcase(yyruleno==448); + case 458: /* slimit_clause_opt ::= */ yytestcase(yyruleno==458); + case 462: /* limit_clause_opt ::= */ yytestcase(yyruleno==462); +{ yymsp[1].minor.yy452 = NULL; } break; - case 224: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } + case 223: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 225: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, NULL, yymsp[0].minor.yy442); } + case 224: /* table_name_cond ::= table_name */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 226: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 226: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } break; - case 228: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy442 = createIndexOption(pCxt, yymsp[-6].minor.yy368, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), NULL, yymsp[0].minor.yy442); } + case 227: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, NULL, yymsp[0].minor.yy452); } break; - case 229: /* 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.yy442 = createIndexOption(pCxt, yymsp[-8].minor.yy368, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[0].minor.yy442); } + case 228: /* cmd ::= DROP INDEX exists_opt index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 232: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy452 = createIndexOption(pCxt, yymsp[-7].minor.yy404, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 233: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } + case 230: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy452 = createIndexOption(pCxt, yymsp[-9].minor.yy404, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 234: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy241, false); } + case 233: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 235: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[0].minor.yy241, true); } + case 234: /* sma_stream_opt ::= */ + case 264: /* stream_options ::= */ yytestcase(yyruleno==264); +{ yymsp[1].minor.yy452 = createStreamOptions(pCxt); } break; - case 236: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, yymsp[0].minor.yy442, false); } + case 235: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 268: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==268); +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, yymsp[0].minor.yy442, true); } + case 236: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 238: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } break; - case 239: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } + case 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy109, false); } break; - case 240: /* cmd ::= DESC full_table_name */ - case 241: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==241); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy442); } + case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[0].minor.yy109, true); } break; - case 242: /* cmd ::= RESET QUERY CACHE */ + case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, yymsp[0].minor.yy452, false); } + break; + case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, yymsp[0].minor.yy452, true); } + break; + case 242: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } + break; + case 243: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } + break; + case 244: /* cmd ::= DESC full_table_name */ + case 245: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==245); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy452); } + break; + case 246: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 243: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy197, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 247: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy437, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 245: /* analyze_opt ::= ANALYZE */ - case 253: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==253); - case 407: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==407); -{ yymsp[0].minor.yy197 = true; } + case 249: /* analyze_opt ::= ANALYZE */ + case 257: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==257); + case 411: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==411); +{ yymsp[0].minor.yy437 = true; } break; - case 246: /* explain_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultExplainOptions(pCxt); } + case 250: /* explain_options ::= */ +{ yymsp[1].minor.yy452 = createDefaultExplainOptions(pCxt); } break; - case 247: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy442 = setExplainVerbose(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 251: /* 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; break; - case 248: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy442 = setExplainRatio(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 252: /* 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; break; - case 249: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy368); } + case 253: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy404); } break; - case 250: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-8].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy578); } + case 254: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-8].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy504, yymsp[0].minor.yy100); } break; - case 251: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 255: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 254: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy578 = 0; } + case 258: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy100 = 0; } break; - case 255: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy578 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 259: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy100 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 256: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy197, &yymsp[-4].minor.yy241, yymsp[-2].minor.yy442, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } + case 260: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy437, &yymsp[-4].minor.yy109, yymsp[-2].minor.yy452, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } break; - case 257: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 261: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 259: /* into_opt ::= INTO full_table_name */ - case 388: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==388); - case 418: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==418); - case 441: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==441); -{ yymsp[-1].minor.yy442 = yymsp[0].minor.yy442; } + case 263: /* into_opt ::= INTO full_table_name */ + case 392: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==392); + case 422: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==422); + case 445: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==445); +{ yymsp[-1].minor.yy452 = yymsp[0].minor.yy452; } break; - case 260: /* stream_options ::= */ -{ yymsp[1].minor.yy442 = createStreamOptions(pCxt); } + case 265: /* 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; break; - case 261: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 266: /* 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; break; - case 262: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 267: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy452)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-3].minor.yy452; } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 263: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy442)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy442)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-3].minor.yy442; } - yymsp[-3].minor.yy442 = yylhsminor.yy442; - break; - case 264: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; - break; - case 265: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 269: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 266: /* cmd ::= KILL QUERY NK_STRING */ + case 270: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 267: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 271: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 268: /* cmd ::= BALANCE VGROUP */ + case 272: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 269: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 273: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 270: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy368); } + case 274: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy404); } break; - case 271: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 275: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 272: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 276: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 274: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy241); } + case 278: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy109); } break; - case 275: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 279: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 277: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 281: /* 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; break; - case 278: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 282: /* 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; break; - case 279: /* literal ::= NK_STRING */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 283: /* 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; break; - case 280: /* literal ::= NK_BOOL */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 284: /* 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; break; - case 281: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 285: /* 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; break; - case 282: /* literal ::= duration_literal */ - case 292: /* signed_literal ::= signed */ yytestcase(yyruleno==292); - case 312: /* expression ::= literal */ yytestcase(yyruleno==312); - case 313: /* expression ::= pseudo_column */ yytestcase(yyruleno==313); - case 314: /* expression ::= column_reference */ yytestcase(yyruleno==314); - case 315: /* expression ::= function_expression */ yytestcase(yyruleno==315); - case 316: /* expression ::= subquery */ yytestcase(yyruleno==316); - case 343: /* function_expression ::= literal_func */ yytestcase(yyruleno==343); - case 379: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==379); - case 383: /* boolean_primary ::= predicate */ yytestcase(yyruleno==383); - case 385: /* common_expression ::= expression */ yytestcase(yyruleno==385); - case 386: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==386); - case 389: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==389); - case 391: /* table_reference ::= table_primary */ yytestcase(yyruleno==391); - case 392: /* table_reference ::= joined_table */ yytestcase(yyruleno==392); - case 396: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==396); - case 447: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==447); - case 450: /* query_primary ::= query_specification */ yytestcase(yyruleno==450); -{ yylhsminor.yy442 = yymsp[0].minor.yy442; } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 286: /* literal ::= duration_literal */ + case 296: /* signed_literal ::= signed */ yytestcase(yyruleno==296); + case 316: /* expression ::= literal */ yytestcase(yyruleno==316); + case 317: /* expression ::= pseudo_column */ yytestcase(yyruleno==317); + case 318: /* expression ::= column_reference */ yytestcase(yyruleno==318); + case 319: /* expression ::= function_expression */ yytestcase(yyruleno==319); + case 320: /* expression ::= subquery */ yytestcase(yyruleno==320); + case 347: /* function_expression ::= literal_func */ yytestcase(yyruleno==347); + case 383: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==383); + case 387: /* boolean_primary ::= predicate */ yytestcase(yyruleno==387); + case 389: /* common_expression ::= expression */ yytestcase(yyruleno==389); + case 390: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==390); + case 393: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==393); + case 395: /* table_reference ::= table_primary */ yytestcase(yyruleno==395); + case 396: /* table_reference ::= joined_table */ yytestcase(yyruleno==396); + case 400: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==400); + case 451: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==451); + case 454: /* query_primary ::= query_specification */ yytestcase(yyruleno==454); +{ yylhsminor.yy452 = yymsp[0].minor.yy452; } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 283: /* literal ::= NULL */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 287: /* literal ::= NULL */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 284: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 288: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 285: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 289: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 286: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 290: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 287: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 291: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 288: /* signed ::= NK_MINUS NK_INTEGER */ + case 292: /* 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.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 289: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 293: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 290: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 294: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 291: /* signed ::= NK_MINUS NK_FLOAT */ + case 295: /* 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.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 293: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 297: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 294: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 298: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 295: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 299: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 296: /* signed_literal ::= duration_literal */ - case 298: /* signed_literal ::= literal_func */ yytestcase(yyruleno==298); - case 357: /* star_func_para ::= expression */ yytestcase(yyruleno==357); - case 413: /* select_item ::= common_expression */ yytestcase(yyruleno==413); - case 463: /* search_condition ::= common_expression */ yytestcase(yyruleno==463); -{ yylhsminor.yy442 = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 300: /* signed_literal ::= duration_literal */ + case 302: /* signed_literal ::= literal_func */ yytestcase(yyruleno==302); + case 361: /* star_func_para ::= expression */ yytestcase(yyruleno==361); + case 417: /* select_item ::= common_expression */ yytestcase(yyruleno==417); + case 467: /* search_condition ::= common_expression */ yytestcase(yyruleno==467); +{ yylhsminor.yy452 = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 297: /* signed_literal ::= NULL */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 301: /* signed_literal ::= NULL */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 317: /* expression ::= NK_LP expression NK_RP */ - case 384: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==384); -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 321: /* expression ::= NK_LP expression NK_RP */ + case 388: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==388); +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 318: /* expression ::= NK_PLUS expression */ + case 322: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 319: /* expression ::= NK_MINUS expression */ + case 323: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); + 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)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 320: /* expression ::= expression NK_PLUS expression */ + case 324: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 321: /* expression ::= expression NK_MINUS expression */ + case 325: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 322: /* expression ::= expression NK_STAR expression */ + case 326: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 323: /* expression ::= expression NK_SLASH expression */ + case 327: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 324: /* expression ::= expression NK_REM expression */ + case 328: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 325: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 329: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 326: /* expression ::= expression NK_BITAND expression */ + case 330: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 327: /* expression ::= expression NK_BITOR expression */ + case 331: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 330: /* column_reference ::= column_name */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 334: /* column_reference ::= column_name */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy109, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 331: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 335: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 332: /* pseudo_column ::= ROWTS */ - case 333: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==333); - case 335: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==335); - case 336: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==336); - case 337: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==337); - case 338: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==338); - case 339: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==339); - case 345: /* literal_func ::= NOW */ yytestcase(yyruleno==345); -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 336: /* pseudo_column ::= ROWTS */ + case 337: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==337); + case 339: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==339); + case 340: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==340); + case 341: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==341); + case 342: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==342); + case 343: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==343); + case 349: /* literal_func ::= NOW */ yytestcase(yyruleno==349); +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 334: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy241)))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 338: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy109)))); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 340: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 341: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==341); -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368)); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 344: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 345: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==345); +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404)); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 342: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy392)); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + case 346: /* 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.yy504)); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 344: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy241, NULL)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 348: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy109, NULL)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 353: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy368 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 357: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy404 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; - case 358: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 416: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==416); -{ yylhsminor.yy442 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 362: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 420: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==420); +{ yylhsminor.yy452 = createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 359: /* predicate ::= expression compare_op expression */ - case 364: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==364); + case 363: /* predicate ::= expression compare_op expression */ + case 368: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==368); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy412, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 360: /* predicate ::= expression BETWEEN expression AND expression */ + case 364: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; - case 361: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 365: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 362: /* predicate ::= expression IS NULL */ + case 366: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), 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)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 363: /* predicate ::= expression IS NOT NULL */ + case 367: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), 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)); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 365: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_THAN; } + case 369: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_THAN; } break; - case 366: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_THAN; } + case 370: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_THAN; } break; - case 367: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_EQUAL; } + case 371: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_EQUAL; } break; - case 368: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_EQUAL; } + case 372: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_EQUAL; } break; - case 369: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy412 = OP_TYPE_NOT_EQUAL; } + case 373: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy440 = OP_TYPE_NOT_EQUAL; } break; - case 370: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy412 = OP_TYPE_EQUAL; } + case 374: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy440 = OP_TYPE_EQUAL; } break; - case 371: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy412 = OP_TYPE_LIKE; } + case 375: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LIKE; } break; - case 372: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_LIKE; } + case 376: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_LIKE; } break; - case 373: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy412 = OP_TYPE_MATCH; } + case 377: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_MATCH; } break; - case 374: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy412 = OP_TYPE_NMATCH; } + case 378: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_NMATCH; } break; - case 375: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy412 = OP_TYPE_JSON_CONTAINS; } + case 379: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy440 = OP_TYPE_JSON_CONTAINS; } break; - case 376: /* in_op ::= IN */ -{ yymsp[0].minor.yy412 = OP_TYPE_IN; } + case 380: /* in_op ::= IN */ +{ yymsp[0].minor.yy440 = OP_TYPE_IN; } break; - case 377: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_IN; } + case 381: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_IN; } break; - case 378: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 382: /* 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.yy404)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 380: /* boolean_value_expression ::= NOT boolean_primary */ + case 384: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); + 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)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 381: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 385: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 382: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 386: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + 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))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 390: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy442 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, NULL); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 394: /* 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; break; - case 393: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 397: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 394: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 398: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 395: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy442 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 399: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy452 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 397: /* alias_opt ::= */ -{ yymsp[1].minor.yy241 = nil_token; } + case 401: /* alias_opt ::= */ +{ yymsp[1].minor.yy109 = nil_token; } break; - case 398: /* alias_opt ::= table_alias */ -{ yylhsminor.yy241 = yymsp[0].minor.yy241; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 402: /* alias_opt ::= table_alias */ +{ yylhsminor.yy109 = yymsp[0].minor.yy109; } + yymsp[0].minor.yy109 = yylhsminor.yy109; break; - case 399: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } + case 403: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy109 = yymsp[0].minor.yy109; } break; - case 400: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 401: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==401); -{ yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442; } + case 404: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 405: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==405); +{ yymsp[-2].minor.yy452 = yymsp[-1].minor.yy452; } break; - case 402: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy442 = createJoinTableNode(pCxt, yymsp[-4].minor.yy208, yymsp[-5].minor.yy442, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + case 406: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy452 = createJoinTableNode(pCxt, yymsp[-4].minor.yy532, yymsp[-5].minor.yy452, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 403: /* join_type ::= */ -{ yymsp[1].minor.yy208 = JOIN_TYPE_INNER; } + case 407: /* join_type ::= */ +{ yymsp[1].minor.yy532 = JOIN_TYPE_INNER; } break; - case 404: /* join_type ::= INNER */ -{ yymsp[0].minor.yy208 = JOIN_TYPE_INNER; } + case 408: /* join_type ::= INNER */ +{ yymsp[0].minor.yy532 = JOIN_TYPE_INNER; } break; - case 405: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 409: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy442 = createSelectStmt(pCxt, yymsp[-10].minor.yy197, yymsp[-9].minor.yy368, yymsp[-8].minor.yy442); - yymsp[-11].minor.yy442 = addWhereClause(pCxt, yymsp[-11].minor.yy442, yymsp[-7].minor.yy442); - yymsp[-11].minor.yy442 = addPartitionByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-6].minor.yy368); - yymsp[-11].minor.yy442 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy442, yymsp[-2].minor.yy442); - yymsp[-11].minor.yy442 = addGroupByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-1].minor.yy368); - yymsp[-11].minor.yy442 = addHavingClause(pCxt, yymsp[-11].minor.yy442, yymsp[0].minor.yy442); - yymsp[-11].minor.yy442 = addRangeClause(pCxt, yymsp[-11].minor.yy442, yymsp[-5].minor.yy442); - yymsp[-11].minor.yy442 = addEveryClause(pCxt, yymsp[-11].minor.yy442, yymsp[-4].minor.yy442); - yymsp[-11].minor.yy442 = addFillClause(pCxt, yymsp[-11].minor.yy442, yymsp[-3].minor.yy442); + yymsp[-11].minor.yy452 = createSelectStmt(pCxt, yymsp[-10].minor.yy437, yymsp[-9].minor.yy404, yymsp[-8].minor.yy452); + yymsp[-11].minor.yy452 = addWhereClause(pCxt, yymsp[-11].minor.yy452, yymsp[-7].minor.yy452); + yymsp[-11].minor.yy452 = addPartitionByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-6].minor.yy404); + yymsp[-11].minor.yy452 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy452, yymsp[-2].minor.yy452); + yymsp[-11].minor.yy452 = addGroupByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-1].minor.yy404); + yymsp[-11].minor.yy452 = addHavingClause(pCxt, yymsp[-11].minor.yy452, yymsp[0].minor.yy452); + yymsp[-11].minor.yy452 = addRangeClause(pCxt, yymsp[-11].minor.yy452, yymsp[-5].minor.yy452); + yymsp[-11].minor.yy452 = addEveryClause(pCxt, yymsp[-11].minor.yy452, yymsp[-4].minor.yy452); + yymsp[-11].minor.yy452 = addFillClause(pCxt, yymsp[-11].minor.yy452, yymsp[-3].minor.yy452); } break; - case 408: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy197 = false; } + case 412: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy437 = false; } break; - case 409: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy368 = NULL; } + case 413: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy404 = NULL; } break; - case 414: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 418: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 415: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 419: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 420: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 437: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==437); - case 453: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==453); -{ yymsp[-2].minor.yy368 = yymsp[0].minor.yy368; } + case 424: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 441: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==441); + case 457: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==457); +{ yymsp[-2].minor.yy404 = yymsp[0].minor.yy404; } break; - case 422: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy442 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 426: /* 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)); } break; - case 423: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy442 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 427: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy452 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } break; - case 424: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), NULL, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 428: /* 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); } break; - case 425: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 429: /* 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); } break; - case 427: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 445: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==445); -{ yymsp[-3].minor.yy442 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy442); } + case 431: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 449: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==449); +{ yymsp[-3].minor.yy452 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy452); } break; - case 429: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy442 = createFillNode(pCxt, yymsp[-1].minor.yy388, NULL); } + case 433: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy452 = createFillNode(pCxt, yymsp[-1].minor.yy614, NULL); } break; - case 430: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy442 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } + case 434: /* 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.yy404)); } break; - case 431: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy388 = FILL_MODE_NONE; } + case 435: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy614 = FILL_MODE_NONE; } break; - case 432: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy388 = FILL_MODE_PREV; } + case 436: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy614 = FILL_MODE_PREV; } break; - case 433: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy388 = FILL_MODE_NULL; } + case 437: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy614 = FILL_MODE_NULL; } break; - case 434: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy388 = FILL_MODE_LINEAR; } + case 438: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy614 = FILL_MODE_LINEAR; } break; - case 435: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy388 = FILL_MODE_NEXT; } + case 439: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy614 = FILL_MODE_NEXT; } break; - case 438: /* group_by_list ::= expression */ -{ yylhsminor.yy368 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 442: /* group_by_list ::= expression */ +{ yylhsminor.yy404 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; - case 439: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 443: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; - case 443: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy442 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 447: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy452 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } break; - case 446: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 450: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy442 = addOrderByClause(pCxt, yymsp[-3].minor.yy442, yymsp[-2].minor.yy368); - yylhsminor.yy442 = addSlimitClause(pCxt, yylhsminor.yy442, yymsp[-1].minor.yy442); - yylhsminor.yy442 = addLimitClause(pCxt, yylhsminor.yy442, yymsp[0].minor.yy442); + yylhsminor.yy452 = addOrderByClause(pCxt, yymsp[-3].minor.yy452, yymsp[-2].minor.yy404); + yylhsminor.yy452 = addSlimitClause(pCxt, yylhsminor.yy452, yymsp[-1].minor.yy452); + yylhsminor.yy452 = addLimitClause(pCxt, yylhsminor.yy452, yymsp[0].minor.yy452); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 448: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 452: /* 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; break; - case 449: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 453: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 451: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy442 = yymsp[-4].minor.yy442; } - yy_destructor(yypParser,359,&yymsp[-3].minor); - yy_destructor(yypParser,360,&yymsp[-2].minor); - yy_destructor(yypParser,361,&yymsp[-1].minor); + case 455: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy452 = yymsp[-4].minor.yy452; } + yy_destructor(yypParser,362,&yymsp[-3].minor); + yy_destructor(yypParser,363,&yymsp[-2].minor); + yy_destructor(yypParser,364,&yymsp[-1].minor); break; - case 455: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 459: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==459); -{ yymsp[-1].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 459: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 463: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==463); +{ yymsp[-1].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 456: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 460: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==460); -{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 460: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 464: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==464); +{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 457: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 461: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==461); -{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 461: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 465: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==465); +{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 462: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy442); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 466: /* 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; break; - case 466: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy442 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[-1].minor.yy362, yymsp[0].minor.yy417); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 470: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy452 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), yymsp[-1].minor.yy178, yymsp[0].minor.yy77); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 467: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy362 = ORDER_ASC; } + case 471: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy178 = ORDER_ASC; } break; - case 468: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy362 = ORDER_ASC; } + case 472: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy178 = ORDER_ASC; } break; - case 469: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy362 = ORDER_DESC; } + case 473: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy178 = ORDER_DESC; } break; - case 470: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy417 = NULL_ORDER_DEFAULT; } + case 474: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy77 = NULL_ORDER_DEFAULT; } break; - case 471: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_FIRST; } + case 475: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy77 = NULL_ORDER_FIRST; } break; - case 472: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_LAST; } + case 476: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy77 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 8802f91bdf..36a2eb3808 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -25,95 +25,125 @@ #ifdef WINDOWS #define TD_USE_WINSOCK #endif + #include "mockCatalog.h" + +#include "systable.h" namespace { void generateInformationSchema(MockCatalogService* mcs) { { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); builder.done(); } { ITableBuilder& builder = - mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_DATABASES, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_FUNCTIONS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_INDEXES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_STABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1) .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1) - .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS, TSDB_SYSTEM_TABLE, 1) + .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "configs", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnode_variables", TSDB_SYSTEM_TABLE, 1) - .addColumn("dnode_id", TSDB_DATA_TYPE_INT); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1) + .addColumn("dnode_id", TSDB_DATA_TYPE_INT); builder.done(); } } void generatePerformanceSchema(MockCatalogService* mcs) { { - ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "trans", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "streams", TSDB_SYSTEM_TABLE, 1) - .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); } } @@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra return g_mockCatalogService->catalogGetDnodeList(pDnodeList); } -int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) { +int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + STableCfg** pCfg) { *pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg)); return 0; } diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index dd154427c6..5c8439f846 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) { TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) { useDb("root", "test"); - run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - // run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)"); + run("SELECT CSUM(c3) FROM t1 STATE_WINDOW(c1)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC); + + run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC); } TEST_F(ParserSelectTest, useDefinedFunc) { @@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) { run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1"); } +TEST_F(ParserSelectTest, setOperatorSemanticCheck) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1 ORDER BY ts", TSDB_CODE_PAR_INVALID_COLUMN); +} + TEST_F(ParserSelectTest, informationSchema) { useDb("root", "test"); diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index 81a09114e3..e109781169 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {}; // todo SHOW apps // todo SHOW connections +TEST_F(ParserShowToUseTest, showConsumers) { + useDb("root", "test"); + + setCheckDdlFunc( + [&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); }); + + run("SHOW CONSUMERS"); +} + TEST_F(ParserShowToUseTest, showCreateDatabase) { useDb("root", "test"); @@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) { run("SHOW streams"); } +TEST_F(ParserShowToUseTest, showSubscriptions) { + useDb("root", "test"); + + setCheckDdlFunc( + [&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); }); + + run("SHOW SUBSCRIPTIONS"); +} + TEST_F(ParserShowToUseTest, showTransactions) { useDb("root", "test"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index eafc6ba37a..524572ee3f 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -19,6 +19,7 @@ typedef struct SLogicPlanContext { SPlanContext* pPlanCxt; + SLogicNode* pCurrRoot; } SLogicPlanContext; typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**); @@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t if (TSDB_CODE_SUCCESS == code && NULL != pNode) { pNode->precision = precision; code = pushLogicNode(pCxt, pRoot, pNode); + pCxt->pCurrRoot = pNode; } if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pNode); @@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot); } -static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols, - int8_t tableType) { +static EScanType getScanType(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pScanPseudoCols, + SNodeList* pScanCols, int8_t tableType) { if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { return SCAN_TYPE_STREAM; } + if (pSelect->hasLastRowFunc) { + return SCAN_TYPE_LAST_ROW; + } + if (NULL == pScanCols) { // select count(*) from t return NULL == pScanPseudoCols @@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM); } - pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); + pScan->scanType = getScanType(pCxt, pSelect, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); if (TSDB_CODE_SUCCESS == code) { code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols); @@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) { return code; } -static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, - SLogicNode** pLogicNode) { - SScanLogicNode* pScan = NULL; - int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan); - - SNodeList* pFuncs = NULL; - if (TSDB_CODE_SUCCESS == code) { - pScan->scanType = SCAN_TYPE_LAST_ROW; - code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs); - } - if (TSDB_CODE_SUCCESS == code) { - code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM); - } - if (TSDB_CODE_SUCCESS == code) { - code = createColumnByLastRow(pFuncs, &pScan->pScanCols); - } - if (TSDB_CODE_SUCCESS == code) { - code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets); - } - - if (TSDB_CODE_SUCCESS == code) { - *pLogicNode = (SLogicNode*)pScan; - } else { - nodesDestroyNode((SNode*)pScan); - } - nodesDestroyList(pFuncs); - - return code; -} - static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); @@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS SLogicNode** pLogicNode) { switch (nodeType(pTable)) { case QUERY_NODE_REAL_TABLE: - if (pSelect->hasLastRowFunc) { - return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); - } else { - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); - } + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); case QUERY_NODE_TEMP_TABLE: return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); case QUERY_NODE_JOIN_TABLE: @@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel } pNode->precision = pSelect->precision; *pLogicNode = pNode; + pCxt->pCurrRoot = pNode; } return code; } @@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) { + code = nodesListMakeStrictAppend(&pFill->node.pTargets, + nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); + } pFill->mode = pFillNode->mode; pFill->timeRange = pFillNode->timeRange; @@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pSort->node.pTargets) { + code = nodesListMakeStrictAppend(&pSort->node.pTargets, + nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); + } if (TSDB_CODE_SUCCESS == code) { pSort->pSortKeys = nodesCloneList(pSelect->pOrderByList); @@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel return TSDB_CODE_OUT_OF_MEMORY; } - if (NULL != pSelect->pLimit) { - pProject->limit = pSelect->pLimit->limit; - pProject->offset = pSelect->pLimit->offset; - } else { - pProject->limit = -1; - pProject->offset = -1; - } - - if (NULL != pSelect->pSlimit) { - pProject->slimit = ((SLimitNode*)pSelect->pSlimit)->limit; - pProject->soffset = ((SLimitNode*)pSelect->pSlimit)->offset; - } else { - pProject->slimit = -1; - pProject->soffset = -1; - } + pProject->node.pLimit = (SNode*)pSelect->pLimit; + pProject->node.pSlimit = (SNode*)pSelect->pSlimit; int32_t code = TSDB_CODE_SUCCESS; @@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pPartition->node.pTargets) { + code = nodesListMakeStrictAppend(&pPartition->node.pTargets, nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)); + } if (TSDB_CODE_SUCCESS == code) { pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList); @@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p return TSDB_CODE_OUT_OF_MEMORY; } + pSort->node.pLimit = pSetOperator->pLimit; + int32_t code = TSDB_CODE_SUCCESS; pSort->node.pTargets = nodesCloneList(pSetOperator->pProjectionList); @@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator return TSDB_CODE_OUT_OF_MEMORY; } - if (NULL != pSetOperator->pLimit) { - pProject->limit = ((SLimitNode*)pSetOperator->pLimit)->limit; - pProject->offset = ((SLimitNode*)pSetOperator->pLimit)->offset; - } else { - pProject->limit = -1; - pProject->offset = -1; + if (NULL == pSetOperator->pOrderByList) { + pProject->node.pLimit = pSetOperator->pLimit; } int32_t code = TSDB_CODE_SUCCESS; @@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS return TSDB_CODE_OUT_OF_MEMORY; } + if (NULL == pSetOperator->pOrderByList) { + pAgg->node.pLimit = pSetOperator->pLimit; + } + int32_t code = TSDB_CODE_SUCCESS; pAgg->pGroupKeys = nodesCloneList(pSetOperator->pProjectionList); if (NULL == pAgg->pGroupKeys) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 6a71b1370e..31071c802d 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1147,8 +1147,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { } SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode; - if (-1 != pProjectNode->limit || -1 != pProjectNode->slimit || -1 != pProjectNode->offset || - -1 != pProjectNode->soffset) { + if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) { return false; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 37765edfc5..2eb89ce384 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode return NULL; } + pPhysiNode->pLimit = pLogicNode->pLimit; + pPhysiNode->pSlimit = pLogicNode->pSlimit; + int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pPhysiNode); @@ -912,11 +915,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild return TSDB_CODE_OUT_OF_MEMORY; } - pProject->limit = pProjectLogicNode->limit; - pProject->offset = pProjectLogicNode->offset; - pProject->slimit = pProjectLogicNode->slimit; - pProject->soffset = pProjectLogicNode->soffset; - int32_t code = TSDB_CODE_SUCCESS; if (0 == LIST_LENGTH(pChildren)) { pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index f0e0e84bd9..cb3a93087d 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -965,6 +965,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS if (NULL == pExchange->node.pTargets) { return TSDB_CODE_OUT_OF_MEMORY; } + TSWAP(pExchange->node.pLimit, pProject->node.pLimit); pSubplan->subplanType = SUBPLAN_TYPE_MERGE; diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 790c418b17..ea40567dae 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -37,13 +37,6 @@ TEST_F(PlanBasicTest, whereClause) { run("SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'"); } -TEST_F(PlanBasicTest, joinClause) { - useDb("root", "test"); - - run("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts"); - run("SELECT t1.c1, t2.c2 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts"); -} - TEST_F(PlanBasicTest, func) { useDb("root", "test"); diff --git a/source/libs/planner/test/planOrderByTest.cpp b/source/libs/planner/test/planOrderByTest.cpp index 2ca662cf86..e542f4772f 100644 --- a/source/libs/planner/test/planOrderByTest.cpp +++ b/source/libs/planner/test/planOrderByTest.cpp @@ -31,6 +31,8 @@ TEST_F(PlanOrderByTest, basic) { run("SELECT c1 AS a FROM t1 ORDER BY a"); run("SELECT c1 + 10 AS a FROM t1 ORDER BY a"); + + run("SELECT 1 FROM t1 ORDER BY c1"); } TEST_F(PlanOrderByTest, expr) { diff --git a/source/libs/planner/test/planSetOpTest.cpp b/source/libs/planner/test/planSetOpTest.cpp index bf26f55c02..62e017052e 100644 --- a/source/libs/planner/test/planSetOpTest.cpp +++ b/source/libs/planner/test/planSetOpTest.cpp @@ -54,6 +54,14 @@ TEST_F(PlanSetOpTest, unionAllWithOrderBy) { run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1"); } +TEST_F(PlanSetOpTest, unionAllWithLimit) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"); +} + TEST_F(PlanSetOpTest, union) { useDb("root", "test"); @@ -65,6 +73,14 @@ TEST_F(PlanSetOpTest, union) { "UNION SELECT c1, c2 FROM t1 WHERE c1 > 30"); } +TEST_F(PlanSetOpTest, unionWithLimit) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"); +} + TEST_F(PlanSetOpTest, unionContainJoin) { useDb("root", "test"); diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 7d1ac84aea..4d4f780473 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -33,7 +33,9 @@ TEST_F(PlanSubqeuryTest, basic) { run("SELECT NOW() FROM (SELECT * FROM t1)"); - // run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"); + run("SELECT * FROM (SELECT NOW() FROM t1)"); + + run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"); } TEST_F(PlanSubqeuryTest, doubleGroupBy) { From 9462c80508612104016b463d3b1bda689228db9e Mon Sep 17 00:00:00 2001 From: tomchon Date: Thu, 23 Jun 2022 18:25:49 +0800 Subject: [PATCH 16/81] test: modify testcase of muti-mnodes --- tests/pytest/util/cluster.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/pytest/util/cluster.py b/tests/pytest/util/cluster.py index 6d3be8c7a9..6eb78f0771 100644 --- a/tests/pytest/util/cluster.py +++ b/tests/pytest/util/cluster.py @@ -50,12 +50,10 @@ class ConfigureyCluster: dnode.addExtraCfg("fqdn", f"{hostname}") dnode.addExtraCfg("serverPort", f"{self.startPort + (num-1)*self.portStep}") dnode.addExtraCfg("secondEp", f"{hostname}:{startPort_sec}") - print(num,self.mnodeNums) # configure dnoe of independent mnodes if num <= self.mnodeNums and self.mnodeNums != 0 : dnode.addExtraCfg("supportVnodes", 0) - print("-----------------88888123131231320999999") # print(dnode) self.dnodes.append(dnode) return self.dnodes From bcf477d33fd05df904db74f8870404e7bbfe6cd6 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 19:26:23 +0800 Subject: [PATCH 17/81] feat: sql command 'show consumers' and 'show subscriptions' --- source/libs/parser/src/parUtil.c | 8 ++++---- source/libs/parser/test/mockCatalogService.cpp | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 689ff08ab1..c4f4624355 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) { if (pNew->pFuncs) { pNew->pFuncs = taosArrayDup(pNew->pFuncs); } - + int32_t schemaSize = (pCfg->numOfColumns + pCfg->numOfTags) * sizeof(SSchema); SSchema* pSchema = taosMemoryMalloc(schemaSize); @@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); STableCfg* pCfg = NULL; - int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); + int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); if (TSDB_CODE_SUCCESS == code) { *pOutput = tableCfgDup(pCfg); if (NULL == *pOutput) { @@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) { int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) { SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0); - if (pRes->code) { + if (TSDB_CODE_SUCCESS != pRes->code) { return pRes->code; } - + *pDnodes = taosArrayDup((SArray*)pRes->pRes); if (NULL == *pDnodes) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 4263b59cc3..db33381f5e 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -166,13 +166,10 @@ class MockCatalogServiceImpl { } int32_t catalogGetDnodeList(SArray** pDnodes) const { - SMetaRes res = {0}; - res.pRes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); + *pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); for (const auto& dnode : dnode_) { - taosArrayPush((SArray*)res.pRes, &dnode.second); + taosArrayPush(*pDnodes, &dnode.second); } - *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); - taosArrayPush(*pDnodes, &res); return TSDB_CODE_SUCCESS; } @@ -200,7 +197,7 @@ class MockCatalogServiceImpl { code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex); } if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) { - code = catalogGetDnodeList(&pMetaData->pDnodeList); + code = getAllDnodeList(&pMetaData->pDnodeList); } if (TSDB_CODE_SUCCESS == code) { code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg); @@ -565,6 +562,13 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } + int32_t getAllDnodeList(SArray** pDnodes) const { + SMetaRes res = {0}; + *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); + taosArrayPush(*pDnodes, &res); + return catalogGetDnodeList((SArray**)&res.pRes); + } + uint64_t id_; std::unique_ptr builder_; DbMetaCache meta_; From 41ae1e30fac35797d2ce59dae2e2f2656cfffe22 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 19:29:28 +0800 Subject: [PATCH 18/81] feat: sql command 'show consumers' and 'show subscriptions' --- source/libs/parser/test/mockCatalogService.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index db33381f5e..8830bc7cb3 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -564,9 +564,10 @@ class MockCatalogServiceImpl { int32_t getAllDnodeList(SArray** pDnodes) const { SMetaRes res = {0}; + catalogGetDnodeList((SArray**)&res.pRes); *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); taosArrayPush(*pDnodes, &res); - return catalogGetDnodeList((SArray**)&res.pRes); + return TSDB_CODE_SUCCESS; } uint64_t id_; From 1278282a7819d4bfbefc08f4f5539c93762dd3b2 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 23 Jun 2022 19:53:54 +0800 Subject: [PATCH 19/81] fix(query): math function invalid input should have null output TD-15216 --- source/libs/scalar/src/sclfunc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index d335b04ea4..88ec4a078e 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -130,7 +130,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) { int32_t type = GET_PARAM_TYPE(pInput); - if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) { + if (inputNum != 1 || (!IS_NUMERIC_TYPE(type) && !IS_NULL_TYPE(type))) { return TSDB_CODE_FAILED; } @@ -142,7 +142,7 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS double *out = (double *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { - if (colDataIsNull_s(pInputData, i)) { + if (colDataIsNull_s(pInputData, i) || IS_NULL_TYPE(type)) { colDataAppendNULL(pOutputData, i); continue; } From 26cceaf172553ddfbf8d1ec4c67d38e698f62e12 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 23 Jun 2022 19:58:12 +0800 Subject: [PATCH 20/81] feat:sort table group if needed --- include/common/tcommon.h | 2 +- source/dnode/mnode/impl/src/mndMain.c | 2 +- source/dnode/vnode/inc/vnode.h | 4 +- source/dnode/vnode/src/inc/vnodeInt.h | 2 +- source/dnode/vnode/src/tsdb/tsdbRead.c | 37 ++--- source/libs/executor/inc/executorimpl.h | 13 +- source/libs/executor/src/executil.c | 10 +- source/libs/executor/src/executorimpl.c | 117 +++++--------- source/libs/executor/src/scanoperator.c | 196 ++++++++++-------------- 9 files changed, 157 insertions(+), 226 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 3b8e8e91cb..1ff3d08b7e 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -50,7 +50,7 @@ typedef enum EStreamType { } EStreamType; typedef struct { - SArray *pGroupList; + SArray* pGroupList; SArray* pTableList; SHashObj* map; // speedup acquire the tableQueryInfo by table uid bool needSortTableByGroupId; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index dede1c45e6..d54d05c378 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -100,7 +100,7 @@ static void *mndThreadFp(void *param) { taosMsleep(100); if (mndGetStop(pMnode)) break; - if (lastTime % (tsTransPullupInterval * 10) == 1) { + if (lastTime % (tsTtlPushInterval * 10) == 1) { mndTtlTimer(pMnode); } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index d5d6f7c58a..99854522e1 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -116,7 +116,8 @@ typedef void *tsdbReaderT; #define BLOCK_LOAD_TABLE_SEQ_ORDER 2 #define BLOCK_LOAD_TABLE_RR_ORDER 3 -tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *tableInfoGroup, uint64_t qId, +int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList); +tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableInfoGroup, uint64_t qId, uint64_t taskId); tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *groupList, uint64_t qId, void *pMemRef); @@ -195,7 +196,6 @@ struct SVnodeCfg { typedef struct { TSKEY lastKey; uint64_t uid; - uint64_t groupId; } STableKeyInfo; struct SMetaEntry { diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index f8bdb63c86..defca947df 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -121,7 +121,7 @@ int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSub int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp); int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey); -tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId, +tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId, uint64_t taskId); tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId, void* pMemRef); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index ce39b35aaa..a76f7af7ef 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -224,8 +224,8 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) { return rows; } -static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, STableListInfo* pTableList) { - size_t tableSize = taosArrayGetSize(pTableList->pTableList); +static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) { + size_t tableSize = taosArrayGetSize(pTableList); assert(tableSize >= 1); // allocate buffer in order to load data blocks from file @@ -236,7 +236,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S // todo apply the lastkey of table check to avoid to load header file for (int32_t j = 0; j < tableSize; ++j) { - STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(pTableList->pTableList, j); + STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(pTableList, j); STableCheckInfo info = {.lastKey = pKeyInfo->lastKey, .tableId = pKeyInfo->uid}; info.suid = pTsdbReadHandle->suid; @@ -255,8 +255,6 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S pTsdbReadHandle->idStr); } - // TODO group table according to the tag value. - taosArraySort(pTableCheckInfo, tsdbCheckInfoCompar); return pTableCheckInfo; } @@ -500,7 +498,17 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle return TSDB_CODE_SUCCESS; } -tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId, +int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){ + STsdbReadHandle* pTsdbReadHandle = reader; + if(pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo); + pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, tableList); + if (pTsdbReadHandle->pTableCheckInfo == NULL) { + return TSDB_CODE_TDB_OUT_OF_MEMORY; + } + return TDB_CODE_SUCCESS; +} + +tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId, uint64_t taskId) { STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId); if (pTsdbReadHandle == NULL) { @@ -546,7 +554,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLis } tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle, - taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList->pTableList), + taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList), pTsdbReadHandle->idStr); return (tsdbReaderT)pTsdbReadHandle; @@ -642,7 +650,7 @@ tsdbReaderT tsdbQueryLastRow(SVnode* pVnode, SQueryTableDataCond* pCond, STableL return NULL; } - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbReaderOpen(pVnode, pCond, pList, qId, taskId); + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbReaderOpen(pVnode, pCond, pList->pTableList, qId, taskId); if (pTsdbReadHandle == NULL) { return NULL; } @@ -2845,7 +2853,7 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) { break; } - STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id, .groupId = 0}; + STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id}; taosArrayPush(list, &info); } @@ -3647,17 +3655,6 @@ SArray* tsdbRetrieveDataBlock(tsdbReaderT* pTsdbReadHandle, SArray* pIdList) { } } -static int tsdbCheckInfoCompar(const void* key1, const void* key2) { - if (((STableCheckInfo*)key1)->tableId < ((STableCheckInfo*)key2)->tableId) { - return -1; - } else if (((STableCheckInfo*)key1)->tableId > ((STableCheckInfo*)key2)->tableId) { - return 1; - } else { - ASSERT(false); - return 0; - } -} - static void* doFreeColumnInfoData(SArray* pColumnInfoData) { if (pColumnInfoData == NULL) { return NULL; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 286bcea820..47b383155d 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -273,6 +273,10 @@ typedef struct STableScanInfo { SSampleExecInfo sample; // sample execution info int32_t curTWinIdx; + + int32_t currentGroupId; + uint64_t queryId; + uint64_t taskId; } STableScanInfo; typedef struct STagScanInfo { @@ -336,7 +340,6 @@ typedef struct SStreamBlockScanInfo { int32_t numOfPseudoExpr; int32_t primaryTsIndex; // primary time stamp slot id - void* pDataReader; SReadHandle readHandle; uint64_t tableUid; // queried super table uid EStreamScanMode scanMode; @@ -707,7 +710,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo, uint64_t queryId, uint64_t taskId); SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo); @@ -750,8 +753,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* readHandle, uint64_t uid, SBlockDistScanPhysiNode* pBlockScanNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, - STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup); +SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, + STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup, uint64_t queryId, uint64_t taskId); SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, bool multigroupResult, SExecTaskInfo* pTaskInfo); @@ -846,7 +849,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex); -int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey); +int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey); #ifdef __cplusplus } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 0282d9cccb..80be8b3404 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -297,6 +297,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo) { int32_t code = TSDB_CODE_SUCCESS; pListInfo->pTableList = taosArrayInit(8, sizeof(STableKeyInfo)); + if(pListInfo->pTableList == NULL) return TSDB_CODE_OUT_OF_MEMORY; uint64_t tableUid = pScanNode->uid; @@ -322,7 +323,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo } for (int i = 0; i < taosArrayGetSize(res); i++) { - STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0}; + STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)}; taosArrayPush(pListInfo->pTableList, &info); } taosArrayDestroy(res); @@ -343,9 +344,14 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo } } }else { // Create one table group. - STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0}; + STableKeyInfo info = {.lastKey = 0, .uid = tableUid}; taosArrayPush(pListInfo->pTableList, &info); } + pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES); + if(pListInfo->pGroupList == NULL) return TSDB_CODE_OUT_OF_MEMORY; + + //put into list as default group, remove it if grouping sorting is required later + taosArrayPush(pListInfo->pGroupList, &pListInfo->pTableList); return code; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f89064897c..0ece71b3b8 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3871,9 +3871,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT return pTaskInfo; } -static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, - STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId); - static SArray* extractColumnInfo(SNodeList* pNodeList); int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) { @@ -3989,9 +3986,9 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, taosMemoryFree(keyBuf); if(pTableListInfo->needSortTableByGroupId){ - pTableListInfo->pGroupList = taosArrayInit(groupNum, POINTER_BYTES); + taosArrayClear(pTableListInfo->pGroupList); SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); - if(pTableListInfo->pGroupList == NULL || sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if(sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); @@ -3999,11 +3996,15 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ); if (index == -1){ void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); - SArray *tGroup = taosArrayInit(8, sizeof(uint64_t)); + SArray *tGroup = taosArrayInit(8, sizeof(STableKeyInfo)); if(tGroup == NULL) { taosArrayDestroy(sortSupport); return TSDB_CODE_OUT_OF_MEMORY; } + if(taosArrayPush(tGroup, info) == NULL){ + qError("taos push info array error"); + return TSDB_CODE_QRY_APP_ERROR; + } if(p == NULL){ if(taosArrayPush(sortSupport, groupId) != NULL){ qError("taos push support array error"); @@ -4030,7 +4031,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } }else{ SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index); - if(taosArrayPush(tGroup, &info->uid) == NULL){ + if(taosArrayPush(tGroup, info) == NULL){ qError("taos push uid array error"); return TSDB_CODE_QRY_APP_ERROR; } @@ -4051,35 +4052,31 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) { STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; - tsdbReaderT pDataReader = - doCreateDataReader(pTableScanNode, pHandle, pTableListInfo, (uint64_t)queryId, taskId); - if (pDataReader == NULL && terrno != 0) { + int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); + if(code){ + return NULL; + } + code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); + if (code) { pTaskInfo->code = terrno; return NULL; } - int32_t code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); - if (code) { - tsdbCleanupReadHandle(pDataReader); - pTaskInfo->code = terrno; - return NULL; - } - - code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); - if (code) { - tsdbCleanupReadHandle(pDataReader); - pTaskInfo->code = code; - return NULL; - } - - SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); + SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; - createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); - extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); + int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); + if(code){ + return NULL; + } + code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); + if (code) { + pTaskInfo->code = terrno; + return NULL; + } SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo, queryId, taskId); STableScanInfo* pScanInfo = pOperator->info; @@ -4095,33 +4092,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .calTrigger = pTableScanNode->triggerType, .maxTs = INT64_MIN, }; - tsdbReaderT pDataReader = NULL; - if (pHandle) { - if (pHandle->vnode) { - // for stram - pDataReader = - doCreateDataReader(pTableScanNode, pHandle, pTableListInfo, (uint64_t)queryId, taskId); - } else { - // for tq - getTableList(pHandle->meta, pScanPhyNode, pTableListInfo); - } + createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); } - if (pDataReader == NULL && terrno != 0) { - qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo)); - // return NULL; - } else { - qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo)); - } - - int32_t code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); - if (code) { - tsdbCleanupReadHandle(pDataReader); - return NULL; - } - SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup); - + SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTaskInfo, &twSup, queryId, taskId); return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; @@ -4147,7 +4122,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } } else { // Create one table group. - STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid, .groupId = 0}; + STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid}; taosArrayPush(pTableListInfo->pTableList, &info); } @@ -4172,7 +4147,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo cond.suid = pBlockNode->suid; cond.type = BLOCK_LOAD_OFFSET_SEQ_ORDER; } - tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo, queryId, taskId); + tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, queryId, taskId); cleanupQueryTableDataCond(&cond); return createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo); @@ -4390,35 +4365,6 @@ SArray* extractColumnInfo(SNodeList* pNodeList) { return pList; } -tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, - STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId) { - int32_t code = getTableList(pHandle->meta, &pTableScanNode->scan, pTableListInfo); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - if (taosArrayGetSize(pTableListInfo->pTableList) == 0) { - code = 0; - qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId); - goto _error; - } - - SQueryTableDataCond cond = {0}; - code = initQueryTableDataCond(&cond, pTableScanNode); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo, queryId, taskId); - cleanupQueryTableDataCond(&cond); - - return pReader; - -_error: - terrno = code; - return NULL; -} - int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { int32_t code = TDB_CODE_SUCCESS; char* pCurrent = NULL; @@ -4575,6 +4521,13 @@ _complete: static void doDestroyTableList(STableListInfo* pTableqinfoList) { taosArrayDestroy(pTableqinfoList->pTableList); taosHashCleanup(pTableqinfoList->map); + if(pTableqinfoList->needSortTableByGroupId){ + for(int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++){ + SArray* tmp = taosArrayGetP(pTableqinfoList->pGroupList, i); + taosArrayDestroy(tmp); + } + } + taosArrayDestroy(pTableqinfoList->pGroupList); pTableqinfoList->pTableList = NULL; pTableqinfoList->map = NULL; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 4c0f5520ca..bde438f9d5 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -419,7 +419,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { return NULL; } -static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { +static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { STableScanInfo* pTableScanInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -501,7 +501,44 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { } } - setTaskStatus(pTaskInfo, TASK_COMPLETED); + return NULL; +} + +static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { + STableScanInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + if(pInfo->currentGroupId == -1){ + pInfo->currentGroupId++; + SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId); + tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId); + pInfo->dataReader = pReader; + } + + SSDataBlock* result = doTableScanGroup(pOperator); + if(result){ + return result; + } + + pInfo->currentGroupId++; + if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) { + doSetOperatorCompleted(pOperator); + return NULL; + } + + SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId); + tsdbSetTableList(pInfo->dataReader, tableList); + + tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0); + pInfo->curTWinIdx = 0; + pInfo->scanTimes = 0; + + result = doTableScanGroup(pOperator); + if(result){ + return result; + } + + doSetOperatorCompleted(pOperator); return NULL; } @@ -526,8 +563,8 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) { } } -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, - SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, + SExecTaskInfo* pTaskInfo, uint64_t queryId, uint64_t taskId) { STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -562,10 +599,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired; pInfo->pResBlock = createResDataBlock(pDescNode); pInfo->pFilterNode = pTableScanNode->scan.node.pConditions; - pInfo->dataReader = pDataReader; pInfo->scanFlag = MAIN_SCAN; pInfo->pColMatchInfo = pColList; pInfo->curTWinIdx = 0; + pInfo->queryId = queryId; + pInfo->taskId = taskId; + pInfo->currentGroupId = -1; pOperator->name = "TableScanOperator"; // for debug purpose pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN; @@ -1077,9 +1116,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) { return tableIdList; } -SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, +SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, - STimeWindowAggSupp* pTwSup) { + STimeWindowAggSupp* pTwSup, uint64_t queryId, uint64_t taskId) { SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -1119,7 +1158,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan } if (pHandle) { - SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); + SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId); STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info; if (pSTInfo->interval.interval > 0) { pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark); @@ -1153,7 +1192,6 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan pInfo->pRes = createResDataBlock(pDescNode); pInfo->pUpdateRes = createResDataBlock(pDescNode); pInfo->pCondition = pScanPhyNode->node.pConditions; - pInfo->pDataReader = pDataReader; pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; pInfo->sessionSup = (SessionWindowSupporter){.pStreamAggSup = NULL, .gap = -1}; pInfo->groupId = 0; @@ -1918,10 +1956,7 @@ _error: typedef struct STableMergeScanInfo { STableListInfo* tableListInfo; - int32_t tableStartIndex; - int32_t tableEndIndex; - bool hasGroupId; - uint64_t groupId; + int32_t currentGroupId; SArray* dataReaders; // array of tsdbReaderT* SReadHandle readHandle; @@ -1967,12 +2002,6 @@ typedef struct STableMergeScanInfo { SSampleExecInfo sample; // sample execution info } STableMergeScanInfo; -int32_t compareTableKeyInfoByGid(const void* p1, const void* p2) { - const STableKeyInfo* info1 = p1; - const STableKeyInfo* info2 = p2; - return info1->groupId - info2->groupId; -} - int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId) { int32_t code = getTableList(pHandle->meta, &pTableScanNode->scan, pTableListInfo); @@ -1984,55 +2013,9 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId); return TSDB_CODE_SUCCESS; } - SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); - generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json - if (groupKeys) { - taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid); - } - taosArrayDestroy(groupKeys); - return TSDB_CODE_SUCCESS; -} - -int32_t doCreateMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, - STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId, - uint64_t taskId) { - SQueryTableDataCond cond = {0}; - int32_t code = initQueryTableDataCond(&cond, pTableScanNode); + code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pPartitionTags); if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) { - STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo)); - subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo)); - taosArrayPush(subListInfo->pTableList, taosArrayGet(pTableListInfo->pTableList, i)); - - tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, &cond, subListInfo, queryId, taskId); - taosArrayPush(arrayReader, &pReader); - - taosArrayDestroy(subListInfo->pTableList); - taosMemoryFree(subListInfo); - } - cleanupQueryTableDataCond(&cond); - - return TSDB_CODE_SUCCESS; - -_error: - return code; -} - -int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, STableListInfo* pTableListInfo, - int32_t tableStartIdx, int32_t tableEndIdx, SArray* arrayReader, uint64_t queryId, - uint64_t taskId) { - for (int32_t i = tableStartIdx; i <= tableEndIdx; ++i) { - STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo)); - subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo)); - taosArrayPush(subListInfo->pTableList, taosArrayGet(pTableListInfo->pTableList, i)); - - tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, pQueryCond, subListInfo, queryId, taskId); - taosArrayPush(arrayReader, &pReader); - - taosArrayDestroy(subListInfo->pTableList); - taosMemoryFree(subListInfo); + return code; } return TSDB_CODE_SUCCESS; @@ -2221,28 +2204,15 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { STableMergeScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - { - size_t tableListSize = taosArrayGetSize(pInfo->tableListInfo->pTableList); - int32_t i = pInfo->tableStartIndex + 1; - for (; i < tableListSize; ++i) { - STableKeyInfo* tableKeyInfo = taosArrayGet(pInfo->tableListInfo->pTableList, i); - if (tableKeyInfo->groupId != pInfo->groupId) { - break; - } - } - pInfo->tableEndIndex = i - 1; - } + SArray* tableList = taosArrayGetP(pInfo->tableListInfo->pGroupList, pInfo->currentGroupId); - int32_t tableStartIdx = pInfo->tableStartIndex; - int32_t tableEndIdx = pInfo->tableEndIndex; - - STableListInfo* tableListInfo = pInfo->tableListInfo; - createMultipleDataReaders(&pInfo->cond, &pInfo->readHandle, tableListInfo, tableStartIdx, tableEndIdx, - pInfo->dataReaders, pInfo->queryId, pInfo->taskId); + tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId); + taosArrayPush(pInfo->dataReaders, &pReader); // todo the total available buffer should be determined by total capacity of buffer of this task. // the additional one is reserved for merge result - pInfo->sortBufSize = pInfo->bufPageSize * (tableEndIdx - tableStartIdx + 1 + 1); + int32_t tableLen = taosArrayGetSize(tableList); + pInfo->sortBufSize = pInfo->bufPageSize * (tableLen + 1); int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage, pInfo->pSortInputBlock, pTaskInfo->id.str); @@ -2329,38 +2299,39 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { if (code != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, code); } - size_t tableListSize = taosArrayGetSize(pInfo->tableListInfo->pTableList); - if (!pInfo->hasGroupId) { - pInfo->hasGroupId = true; - if (tableListSize == 0) { - doSetOperatorCompleted(pOperator); - return NULL; - } - pInfo->tableStartIndex = 0; - pInfo->groupId = ((STableKeyInfo*)taosArrayGet(pInfo->tableListInfo->pTableList, pInfo->tableStartIndex))->groupId; + if (pInfo->currentGroupId == -1) { + pInfo->currentGroupId++; startGroupTableMergeScan(pOperator); } - SSDataBlock* pBlock = NULL; - while (pInfo->tableStartIndex < tableListSize) { - pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator); - if (pBlock != NULL) { - pBlock->info.groupId = pInfo->groupId; - pOperator->resultInfo.totalRows += pBlock->info.rows; - return pBlock; - } else { - stopGroupTableMergeScan(pOperator); - if (pInfo->tableEndIndex >= tableListSize - 1) { - doSetOperatorCompleted(pOperator); - break; - } - pInfo->tableStartIndex = pInfo->tableEndIndex + 1; - pInfo->groupId = - ((STableKeyInfo*)taosArrayGet(pInfo->tableListInfo->pTableList, pInfo->tableStartIndex))->groupId; - startGroupTableMergeScan(pOperator); - } + SSDataBlock* pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator); + if (pBlock != NULL) { + uint64_t* groupId = taosHashGet(pInfo->tableListInfo->map, &(pBlock->info.uid), sizeof(uint64_t)); + if(groupId) pBlock->info.groupId = *groupId; + + pOperator->resultInfo.totalRows += pBlock->info.rows; + return pBlock; } + pInfo->currentGroupId++; + stopGroupTableMergeScan(pOperator); + if (pInfo->currentGroupId >= taosArrayGetSize(pInfo->tableListInfo->pGroupList)) { + doSetOperatorCompleted(pOperator); + return NULL; + } + startGroupTableMergeScan(pOperator); + + pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator); + if (pBlock != NULL) { + uint64_t* groupId = taosHashGet(pInfo->tableListInfo->map, &(pBlock->info.uid), sizeof(uint64_t)); + if(groupId) pBlock->info.groupId = *groupId; + + pOperator->resultInfo.totalRows += pBlock->info.rows; + return pBlock; + } + + doSetOperatorCompleted(pOperator); + return pBlock; } @@ -2437,6 +2408,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo->dataReaders = taosArrayInit(64, POINTER_BYTES); pInfo->queryId = queryId; pInfo->taskId = taskId; + pInfo->currentGroupId = -1; pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam)); From 60d0229d3d26c0ea85ce8580adba5439d9610afd Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 23 Jun 2022 19:56:03 +0800 Subject: [PATCH 21/81] fix: abs function handling invalid constant input TD-15216 --- source/libs/scalar/src/sclfunc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 88ec4a078e..bc6270a3a3 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -36,9 +36,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); - if (!IS_NUMERIC_TYPE(type)) { - return TSDB_CODE_FAILED; - } switch (type) { case TSDB_DATA_TYPE_FLOAT: { @@ -119,6 +116,13 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu break; } + case TSDB_DATA_TYPE_NULL: { + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + colDataAppendNULL(pOutputData, i); + } + break; + } + default: { colDataAssign(pOutputData, pInputData, pInput->numOfRows); } From 52d19df7b28dcf6f8a4f80b60a1a10e85ee34fea Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 23 Jun 2022 20:26:20 +0800 Subject: [PATCH 22/81] test: modify test case --- tests/system-test/7-tmq/tmq3mnodeSwitch.py | 5 ++--- tests/system-test/fulltest.sh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py index 8aab6db1a4..2769c3867b 100644 --- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -13,7 +13,6 @@ from util.cases import * from util.dnodes import * from util.common import * from util.cluster import * -from test import tdDnodes sys.path.append("./7-tmq") from tmqCommon import * @@ -165,7 +164,7 @@ class TDTestCase: else: break return - + def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") paraDict = {'dbName': 'db1', @@ -237,7 +236,7 @@ class TDTestCase: self.check3mnode1off() tdLog.info("switch end and wait insert data end ................") - pThread.join() + pThread.join() tdLog.info("check the consume result") tdSql.query(queryString) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index fe4c162054..d90a730c59 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -134,4 +134,4 @@ python3 ./test.py -f 7-tmq/schema.py python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py python3 ./test.py -f 7-tmq/tmqUdf.py -python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 +#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 From 53eefc1ba27272c0e87ea63863bc475989248e37 Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Thu, 23 Jun 2022 20:27:46 +0800 Subject: [PATCH 23/81] add test case for irate and check value of all --- tests/system-test/2-query/irate.py | 279 +++++++++++++++++++++++++++++ tests/system-test/fulltest.sh | 1 + 2 files changed, 280 insertions(+) create mode 100644 tests/system-test/2-query/irate.py diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py new file mode 100644 index 0000000000..3a451d069c --- /dev/null +++ b/tests/system-test/2-query/irate.py @@ -0,0 +1,279 @@ +import taos +import sys +import datetime +import inspect + +from util.log import * +from util.sql import * +from util.cases import * +import random + + +class TDTestCase: + updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, + "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + self.tb_nums = 10 + self.row_nums = 20 + self.ts = 1434938400000 + self.time_step = 1000 + + def insert_datas_and_check_irate(self ,tbnums , rownums , time_step ): + + tdLog.info(" prepare datas for auto check irate function ") + + tdSql.execute(" create database test ") + tdSql.execute(" use test ") + tdSql.execute(" create stable stb (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)") + for tbnum in range(tbnums): + tbname = "sub_tb_%d"%tbnum + tdSql.execute(" create table %s using stb tags(%d) "%(tbname , tbnum)) + + ts = self.ts + for row in range(rownums): + ts = self.ts + time_step*row + c1 = random.randint(0,1000) + c2 = random.randint(0,100000) + c3 = random.randint(0,125) + c4 = random.randint(0,125) + c5 = random.random()/1.0 + c6 = random.random()/1.0 + c7 = "'true'" + c8 = "'binary_val'" + c9 = "'nchar_val'" + c10 = ts + tdSql.execute(f" insert into {tbname} values ({ts},{c1},{c2},{c3},{c4},{c5},{c6},{c7},{c8},{c9},{c10})") + + tdSql.execute("use test") + tbnames = ["stb", "sub_tb_1"] + support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"] + for tbname in tbnames: + tdSql.query("desc {}".format(tbname)) + coltypes = tdSql.queryResult + for coltype in coltypes: + colname = coltype[0] + if coltype[1] in support_types and coltype[-1] != "TAG" : + irate_sql = "select irate({}) from (select * from {} order by tbname ) ".format(colname, tbname) + origin_sql = "select ts , {} , cast(ts as bigint) from (select ts , {} from {} order by ts desc limit 2 offset 0 ) order by ts".format(colname,colname, tbname) + + tdSql.query(irate_sql) + irate_result = tdSql.queryResult + tdSql.query(origin_sql) + origin_result = tdSql.queryResult + irate_value = irate_result[0][0] + if origin_result[1][-1] - origin_result[0][-1] == 0: + comput_irate_value = 0 + elif (origin_result[1][1] - origin_result[0][1])<0: + comput_irate_value = origin_result[1][1]*1000/( origin_result[1][-1] - origin_result[0][-1]) + else: + comput_irate_value = (origin_result[1][1] - origin_result[0][1])*1000/( origin_result[1][-1] - origin_result[0][-1]) + if comput_irate_value ==irate_value: + tdLog.info(" irate work as expected , sql is %s "% irate_sql) + else: + tdLog.exit(" irate work not as expected , sql is %s "% irate_sql) + + def prepare_tag_datas(self): + # prepare datas + tdSql.execute( + "create database if not exists testdb keep 3650 duration 1000") + tdSql.execute(" use testdb ") + tdSql.execute( + '''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 (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + tdSql.execute( + ''' + 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) + ''' + ) + for i in range(4): + tdSql.execute( + f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + "insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute( + "insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute( + "insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '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" ) + ( '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" ) + ( '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" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + + def test_errors(self): + tdSql.execute("use testdb") + error_sql_lists = [ + "select irate from t1", + "select irate(-+--+c1) from t1", + # "select +-irate(c1) from t1", + # "select ++-irate(c1) from t1", + # "select ++--irate(c1) from t1", + # "select - -irate(c1)*0 from t1", + # "select irate(tbname+1) from t1 ", + "select irate(123--123)==1 from t1", + "select irate(c1) as 'd1' from t1", + "select irate(c1 ,c2 ) from t1", + "select irate(c1 ,NULL) from t1", + "select irate(,) from t1;", + "select irate(irate(c1) ab from t1)", + "select irate(c1) as int from t1", + "select irate from stb1", + # "select irate(-+--+c1) from stb1", + # "select +-irate(c1) from stb1", + # "select ++-irate(c1) from stb1", + # "select ++--irate(c1) from stb1", + # "select - -irate(c1)*0 from stb1", + # "select irate(tbname+1) from stb1 ", + "select irate(123--123)==1 from stb1", + "select irate(c1) as 'd1' from stb1", + "select irate(c1 ,c2 ) from stb1", + "select irate(c1 ,NULL) from stb1", + "select irate(,) from stb1;", + "select irate(abs(c1) ab from stb1)", + "select irate(c1) as int from stb1" + ] + for error_sql in error_sql_lists: + tdSql.error(error_sql) + + def support_types(self): + tdSql.execute("use testdb") + tbnames = ["stb1", "t1", "ct1", "ct2"] + support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"] + for tbname in tbnames: + tdSql.query("desc {}".format(tbname)) + coltypes = tdSql.queryResult + for coltype in coltypes: + colname = coltype[0] + irate_sql = "select irate({}) from {}".format(colname, tbname) + if coltype[1] in support_types: + tdSql.query(irate_sql) + else: + tdSql.error(irate_sql) + + def basic_irate_function(self): + + # used for empty table , ct3 is empty + tdSql.query("select irate(c1) from ct3") + tdSql.checkRows(0) + tdSql.query("select irate(c2) from ct3") + tdSql.checkRows(0) + + # used for regular table + tdSql.query("select irate(c1) from t1") + tdSql.checkData(0, 0, 0.000000386) + + # used for sub table + tdSql.query("select irate(abs(c1+c2)) from ct1") + tdSql.checkData(0, 0, 0.000000000) + + + # mix with common col + tdSql.error("select c1, irate(c1) from ct1") + + # mix with common functions + tdSql.error("select irate(c1), abs(c1) from ct4 ") + + # agg functions mix with agg functions + tdSql.query("select irate(c1), count(c5) from stb1 partition by tbname ") + tdSql.checkData(0, 0, 0.000000000) + tdSql.checkData(1, 0, 0.000000000) + tdSql.checkData(0, 1, 13) + tdSql.checkData(1, 1, 9) + + + def irate_func_filter(self): + tdSql.execute("use testdb") + tdSql.query( + "select irate(c1+2)/2 from ct4 where c1>5 ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.000000514) + + tdSql.query( + "select irate(c1+c2)/10 from ct4 where c1=5 ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.000000000) + + tdSql.query( + "select irate(c1+c2)/10 from stb1 where c1 = 5 partition by tbname ") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0.000000000) + + + def irate_Arithmetic(self): + pass + + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table ==============") + + self.prepare_tag_datas() + + tdLog.printNoPrefix("==========step2:test errors ==============") + + self.test_errors() + + tdLog.printNoPrefix("==========step3:support types ============") + + self.support_types() + + tdLog.printNoPrefix("==========step4: irate basic query ============") + + self.basic_irate_function() + + tdLog.printNoPrefix("==========step5: irate filter query ============") + + self.irate_func_filter() + + + tdLog.printNoPrefix("==========step6: check result of query ============") + + self.insert_datas_and_check_irate(self.tb_nums,self.row_nums,self.time_step) + + 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 index 19a67e924c..8d651ec35c 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -109,6 +109,7 @@ python3 ./test.py -f 2-query/distribute_agg_apercentile.py python3 ./test.py -f 2-query/distribute_agg_avg.py python3 ./test.py -f 2-query/distribute_agg_stddev.py python3 ./test.py -f 2-query/twa.py +python3 ./test.py -f 2-query/irate.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py From 9399f5fd70dac2b03370768d67da32f515796fea Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 23 Jun 2022 20:28:51 +0800 Subject: [PATCH 24/81] fix: ceil/floor/round function invalid input handling --- source/libs/scalar/src/sclfunc.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index bc6270a3a3..e8011bf572 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -134,9 +134,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) { int32_t type = GET_PARAM_TYPE(pInput); - if (inputNum != 1 || (!IS_NUMERIC_TYPE(type) && !IS_NULL_TYPE(type))) { - return TSDB_CODE_FAILED; - } SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; @@ -163,10 +160,6 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS } static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn_2 valFn) { - if (inputNum != 2 || !IS_NUMERIC_TYPE(GET_PARAM_TYPE(&pInput[0])) || !IS_NUMERIC_TYPE(GET_PARAM_TYPE(&pInput[1]))) { - return TSDB_CODE_FAILED; - } - SColumnInfoData *pInputData[2]; SColumnInfoData *pOutputData = pOutput->columnData; _getDoubleValue_fn_t getValueFn[2]; @@ -240,9 +233,6 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _float_fn f1, _double_fn d1) { int32_t type = GET_PARAM_TYPE(pInput); - if (inputNum != 1 || !IS_NUMERIC_TYPE(type)) { - return TSDB_CODE_FAILED; - } SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; @@ -276,6 +266,13 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP break; } + case TSDB_DATA_TYPE_NULL: { + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + colDataAppendNULL(pOutputData, i); + } + break; + } + default: { colDataAssign(pOutputData, pInputData, pInput->numOfRows); } From d9b88d6c4808cd8e53db17768c9c081693f9fdb0 Mon Sep 17 00:00:00 2001 From: tomchon Date: Thu, 23 Jun 2022 20:46:09 +0800 Subject: [PATCH 25/81] test:modify test.py and set dnode number default value --- tests/system-test/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 4414265811..7d78f5ab21 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -59,7 +59,7 @@ if __name__ == "__main__": logSql = True stop = 0 restart = False - dnodeNums = 5 + dnodeNums = 1 mnodeNums = 0 updateCfgDict = {} execCmd = "" From 3799db4366d954d36bd8d1fa14140a8ed7201838 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 23 Jun 2022 20:46:11 +0800 Subject: [PATCH 26/81] feat:sort table group if needed --- source/dnode/vnode/src/tsdb/tsdbRead.c | 4 +++- source/libs/executor/src/scanoperator.c | 31 +++++++++++++++++++++---- tests/system-test/2-query/json_tag.py | 7 ++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index a76f7af7ef..d6e339c92a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -226,7 +226,6 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) { static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) { size_t tableSize = taosArrayGetSize(pTableList); - assert(tableSize >= 1); // allocate buffer in order to load data blocks from file SArray* pTableCheckInfo = taosArrayInit(tableSize, sizeof(STableCheckInfo)); @@ -510,6 +509,9 @@ int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId, uint64_t taskId) { + if(taosArrayGetSize(tableList) == 0){ + return NULL; + } STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId); if (pTsdbReadHandle == NULL) { return NULL; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index bde438f9d5..ccc9f4a3ef 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -510,6 +510,10 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { if(pInfo->currentGroupId == -1){ pInfo->currentGroupId++; + if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) { + doSetOperatorCompleted(pOperator); + return NULL; + } SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId); tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId); pInfo->dataReader = pReader; @@ -2200,19 +2204,34 @@ SArray* generateSortByTsInfo(int32_t order) { return pList; } +static int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, SArray* tableList, SArray* arrayReader, uint64_t queryId, + uint64_t taskId) { + for (int32_t i = 0; i < taosArrayGetSize(tableList); ++i) { + SArray* tmp = taosArrayInit(1, sizeof(STableKeyInfo)); + taosArrayPush(tmp, taosArrayGet(tableList, i)); + + tsdbReaderT* pReader = tsdbReaderOpen(pHandle->vnode, pQueryCond, tmp, queryId, taskId); + taosArrayPush(arrayReader, &pReader); + + taosArrayDestroy(tmp); + } + + return TSDB_CODE_SUCCESS; +} + int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { STableMergeScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SArray* tableList = taosArrayGetP(pInfo->tableListInfo->pGroupList, pInfo->currentGroupId); - tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId); - taosArrayPush(pInfo->dataReaders, &pReader); + createMultipleDataReaders(&pInfo->cond, &pInfo->readHandle, tableList, + pInfo->dataReaders, pInfo->queryId, pInfo->taskId); // todo the total available buffer should be determined by total capacity of buffer of this task. // the additional one is reserved for merge result int32_t tableLen = taosArrayGetSize(tableList); - pInfo->sortBufSize = pInfo->bufPageSize * (tableLen + 1); + pInfo->sortBufSize = pInfo->bufPageSize * ((tableLen==0?1:tableLen) + 1); int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage, pInfo->pSortInputBlock, pTaskInfo->id.str); @@ -2302,6 +2321,10 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { if (pInfo->currentGroupId == -1) { pInfo->currentGroupId++; + if (pInfo->currentGroupId >= taosArrayGetSize(pInfo->tableListInfo->pGroupList)) { + doSetOperatorCompleted(pOperator); + return NULL; + } startGroupTableMergeScan(pOperator); } SSDataBlock* pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pOperator->resultInfo.capacity, pOperator); @@ -2313,8 +2336,8 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { return pBlock; } - pInfo->currentGroupId++; stopGroupTableMergeScan(pOperator); + pInfo->currentGroupId++; if (pInfo->currentGroupId >= taosArrayGetSize(pInfo->tableListInfo->pGroupList)) { doSetOperatorCompleted(pOperator); return NULL; diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 0c649f2008..6816d4a3a3 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -412,6 +412,13 @@ class TDTestCase: tdSql.checkColNameList(res, cname_list) # # test group by & order by json tag + tdSql.query("select ts,jtag->'tag1' from jsons1 partition by jtag->'tag1' order by jtag->'tag1' desc") + tdSql.checkRows(11) + tdSql.checkData(0, 1, '"femail"') + tdSql.checkData(2, 1, '"收到货"') + tdSql.checkData(7, 1, "false") + + # tdSql.error("select count(*) from jsons1 group by jtag") # tdSql.error("select count(*) from jsons1 partition by jtag") # tdSql.error("select count(*) from jsons1 group by jtag order by jtag") From 38c61a1a25a1bf60c56fe5ae88618259e2ab3a2d Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 23 Jun 2022 20:58:43 +0800 Subject: [PATCH 27/81] fix: pow/log function invalid input handling --- source/libs/function/src/builtins.c | 7 ++++--- source/libs/scalar/src/sclfunc.c | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 6baf45a5b3..51ed461f04 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -79,7 +79,8 @@ static int32_t translateIn2NumOutDou(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_NUMERIC_TYPE(para1Type) || !IS_NUMERIC_TYPE(para2Type)) { + if ((!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) || + (!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type))) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -109,13 +110,13 @@ static int32_t translateLogarithm(SFunctionNode* pFunc, char* pErrBuf, int32_t l } uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(para1Type)) { + if (!IS_NUMERIC_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } if (2 == numOfParams) { uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; - if (!IS_NUMERIC_TYPE(para2Type)) { + if (!IS_NUMERIC_TYPE(para2Type) && !IS_NULL_TYPE(para2Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } } diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index e8011bf572..ae6eb9f456 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -172,11 +172,15 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S double *out = (double *)pOutputData->pData; double result; + bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || + IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1]))); + int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows); if (pInput[0].numOfRows == pInput[1].numOfRows) { for (int32_t i = 0; i < numOfRows; ++i) { if (colDataIsNull_s(pInputData[0], i) || - colDataIsNull_s(pInputData[1], i)) { + colDataIsNull_s(pInputData[1], i) || + hasNullType) { colDataAppendNULL(pOutputData, i); continue; } @@ -188,7 +192,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S } } } else if (pInput[0].numOfRows == 1) { //left operand is constant - if (colDataIsNull_s(pInputData[0], 0)) { + if (colDataIsNull_s(pInputData[0], 0) || hasNullType) { colDataAppendNNULL(pOutputData, 0, pInput[1].numOfRows); } else { for (int32_t i = 0; i < numOfRows; ++i) { @@ -207,7 +211,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S } } } else if (pInput[1].numOfRows == 1) { - if (colDataIsNull_s(pInputData[1], 0)) { + if (colDataIsNull_s(pInputData[1], 0) || hasNullType) { colDataAppendNNULL(pOutputData, 0, pInput[0].numOfRows); } else { for (int32_t i = 0; i < numOfRows; ++i) { From abc69e1e2b13b33ffe4dcfaaf19c8d33d5fe8904 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 24 Jun 2022 08:20:54 +0800 Subject: [PATCH 28/81] feat: add new api --- include/client/taos.h | 1 - include/common/tglobal.h | 1 + include/common/tname.h | 2 + include/libs/qcom/query.h | 6 +- source/client/inc/clientInt.h | 10 +- source/client/src/clientImpl.c | 286 ++++++++++++++++++++++- source/client/src/clientMain.c | 161 +++++++------ source/common/src/tglobal.c | 367 ++++++++++++++++++++++++++++++ source/common/src/tname.c | 14 ++ source/libs/command/src/command.c | 4 + 10 files changed, 752 insertions(+), 100 deletions(-) diff --git a/include/client/taos.h b/include/client/taos.h index 9d4da221f4..5ca0b5e02b 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -128,7 +128,6 @@ typedef struct setConfRet { DLL_EXPORT void taos_cleanup(void); DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); -DLL_EXPORT setConfRet taos_set_config(const char *config); DLL_EXPORT int taos_init(void); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 8c03d3ff42..ed6dd97df7 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -149,6 +149,7 @@ void taosCfgDynamicOptions(const char *option, const char *value); void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary); struct SConfig *taosGetCfg(); +int32_t taosSetCfg(SConfig *pCfg, char* name); #ifdef __cplusplus } diff --git a/include/common/tname.h b/include/common/tname.h index c691c2f7b2..3bf1cee870 100644 --- a/include/common/tname.h +++ b/include/common/tname.h @@ -57,6 +57,8 @@ void tNameAssign(SName* dst, const SName* src); int32_t tNameSetDbName(SName* dst, int32_t acctId, const char* dbName, size_t nameLen); +int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen); + int32_t tNameFromString(SName* dst, const char* str, uint32_t type); int32_t tNameSetAcctId(SName* dst, int32_t acctId); diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 26f2758033..d86a8dae6e 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -266,19 +266,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define qDebug(...) \ do { \ if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ } \ } while (0) #define qTrace(...) \ do { \ if (qDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \ } \ } while (0) #define qDebugL(...) \ do { \ if (qDebugFlag & DEBUG_DEBUG) { \ - taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \ + taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ } \ } while (0) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index cfe507e505..2b918412fe 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -215,6 +215,7 @@ typedef struct SRequestObj { SQueryExecMetric metric; SRequestSendRecvBody body; bool stableQuery; + bool validateOnly; bool killed; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog @@ -235,7 +236,12 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveT bool freeAfterUse); void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); void doFreeReqResultInfo(SReqResultInfo* pResInfo); -SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen); +int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq); +void syncCatalogFn(SMetaData* pResult, void* param, int32_t code); + +SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly); +TAOS_RES *taosQueryImpl(TAOS *taos, const char *sql, bool validateOnly); +void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, bool validateOnly); static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) { SMqRspObj* msg = (SMqRspObj*)res; @@ -301,7 +307,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet); STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, uint16_t port, int connType); -SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen); +SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly); int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 37b8866e25..baafcd418d 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -237,6 +237,10 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscOb void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; + if (pRequest->validateOnly) { + pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + return; + } int32_t code = qExecCommand(pQuery->pRoot, &pRsp); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { @@ -261,6 +265,11 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { } int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { + if (pRequest->validateOnly) { + pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + return TSDB_CODE_SUCCESS; + } + // drop table if exists not_exists_table if (NULL == pQuery->pCmdMsg) { pRequest->body.queryFp(pRequest->body.param, pRequest, 0); @@ -276,8 +285,11 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest); int64_t transporterId = 0; - asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg); - return TSDB_CODE_SUCCESS; + int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg); + if (code) { + pRequest->body.queryFp(pRequest->body.param, pRequest, code); + } + return code; } int compareQueryNodeLoad(const void* elem1, const void* elem2) { @@ -851,15 +863,19 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue switch (pQuery->execMode) { case QUERY_EXEC_MODE_LOCAL: - code = execLocalCmd(pRequest, pQuery); + if (!pRequest->validateOnly) { + code = execLocalCmd(pRequest, pQuery); + } break; case QUERY_EXEC_MODE_RPC: - code = execDdlQuery(pRequest, pQuery); + if (!pRequest->validateOnly) { + code = execDdlQuery(pRequest, pQuery); + } break; case QUERY_EXEC_MODE_SCHEDULE: { SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pMnodeList); - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildSyncExecNodeList(pRequest, &pNodeList, pMnodeList); @@ -894,7 +910,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue return pRequest; } -SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) { +SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) { SRequestObj* pRequest = NULL; SQuery* pQuery = NULL; @@ -904,6 +920,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) { return NULL; } + pRequest->validateOnly = validateOnly; + code = parseSql(pRequest, false, &pQuery, NULL); if (code != TSDB_CODE_SUCCESS) { pRequest->code = code; @@ -945,7 +963,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM pRequest->requestId); } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta); @@ -962,7 +980,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); taosArrayDestroy(pNodeList); } else { - tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), + tscDebug("0x%" PRIx64 " plan not executed, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); pRequest->body.queryFp(pRequest->body.param, pRequest, code); } @@ -1045,14 +1063,14 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) { return TSDB_CODE_SUCCESS; } -SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) { +SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) { SRequestObj* pRequest = NULL; int32_t retryNum = 0; int32_t code = 0; do { destroyRequest(pRequest); - pRequest = launchQuery(pTscObj, sql, sqlLen); + pRequest = launchQuery(pTscObj, sql, sqlLen, validateOnly); if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) { break; } @@ -1819,3 +1837,251 @@ _OVER: } return code; } + +int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str, int32_t acctId, char* db) { + SName name; + + if (len1 <= 0) { + return -1; + } + + const char *dbName = db; + const char *tbName = NULL; + int32_t dbLen = 0; + int32_t tbLen = 0; + if (len2 > 0) { + dbName = str + pos1; + dbLen = len1; + tbName = str + pos2; + tbLen = len2; + } else { + dbLen = strlen(db); + tbName = str + pos1; + tbLen = len1; + } + + if (tNameSetDbName(&name, acctId, dbName, dbLen)) { + return -1; + } + + if (tNameAddTbName(&name, tbName, tbLen)) { + return -1; + } + + taosArrayPush(pList, &name); + + return TSDB_CODE_SUCCESS; +} + +int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq) { + *pReq = taosArrayInit(10, sizeof(SName)); + if (NULL == *pReq) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return terrno; + } + + bool inEscape = false; + int32_t code = 0; + + int32_t vIdx = 0; + int32_t vPos[2]; + int32_t vLen[2]; + + memset(vPos, -1, sizeof(vPos)); + memset(vLen, 0, sizeof(vLen)); + + for (int32_t i = 0; ; ++i) { + if (0 == *(tbList + i)) { + if (vPos[vIdx] >= 0 && vLen[vIdx] <= 0) { + vLen[vIdx] = i - vPos[vIdx]; + } + + code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName); + if (code) { + goto _return; + } + + break; + } + + if ('`' == *(tbList + i)) { + inEscape = !inEscape; + if (!inEscape) { + if (vPos[vIdx] >= 0) { + vLen[vIdx] = i - vPos[vIdx]; + } else { + goto _return; + } + } + + continue; + } + + if (inEscape) { + if (vPos[vIdx] < 0) { + vPos[vIdx] = i; + } + continue; + } + + if ('.' == *(tbList + i)) { + if (vPos[vIdx] < 0) { + goto _return; + } + if (vLen[vIdx] <= 0) { + vLen[vIdx] = i - vPos[vIdx]; + } + vIdx++; + if (vIdx >= 2) { + goto _return; + } + continue; + } + + if (',' == *(tbList + i)) { + if (vPos[vIdx] < 0) { + goto _return; + } + if (vLen[vIdx] <= 0) { + vLen[vIdx] = i - vPos[vIdx]; + } + + code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName); + if (code) { + goto _return; + } + + memset(vPos, -1, sizeof(vPos)); + memset(vLen, 0, sizeof(vLen)); + vIdx = 0; + continue; + } + + if (' ' == *(tbList + i) || '\r' == *(tbList + i) || '\t' == *(tbList + i) || '\n' == *(tbList + i)) { + if (vPos[vIdx] >= 0 && vLen[vIdx] <= 0) { + vLen[vIdx] = i - vPos[vIdx]; + } + continue; + } + + if (('a' <= *(tbList + i) && 'z' >= *(tbList + i)) || + ('A' <= *(tbList + i) && 'Z' >= *(tbList + i)) || + ('0' <= *(tbList + i) && '9' >= *(tbList + i))) { + if (vLen[vIdx] > 0) { + goto _return; + } + if (vPos[vIdx] < 0) { + vPos[vIdx] = i; + } + continue; + } + + goto _return; + } + + return TSDB_CODE_SUCCESS; + +_return: + + terrno = TSDB_CODE_TSC_INVALID_OPERATION; + + taosArrayDestroy(*pReq); + *pReq = NULL; + + return terrno; +} + +void syncCatalogFn(SMetaData* pResult, void* param, int32_t code) { + SSyncQueryParam *pParam = param; + pParam->pRequest->code = code; + + tsem_post(&pParam->sem); +} + + +void syncQueryFn(void *param, void *res, int32_t code) { + SSyncQueryParam *pParam = param; + pParam->pRequest = res; + pParam->pRequest->code = code; + + tsem_post(&pParam->sem); +} + +void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, bool validateOnly) { + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + if (pTscObj == NULL || sql == NULL || NULL == fp) { + terrno = TSDB_CODE_INVALID_PARA; + if (pTscObj) { + releaseTscObj(*(int64_t *)taos); + } else { + terrno = TSDB_CODE_TSC_DISCONNECTED; + } + fp(param, NULL, terrno); + return; + } + + size_t sqlLen = strlen(sql); + if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { + tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); + terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; + + fp(param, NULL, terrno); + return; + } + + SRequestObj *pRequest = NULL; + int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + fp(param, NULL, terrno); + return; + } + + pRequest->validateOnly = validateOnly; + pRequest->body.queryFp = fp; + pRequest->body.param = param; + doAsyncQuery(pRequest, false); +} + + +TAOS_RES *taosQueryImpl(TAOS *taos, const char *sql, bool validateOnly) { + if (NULL == taos) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + if (pTscObj == NULL || sql == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + +#if SYNC_ON_TOP_OF_ASYNC + SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + tsem_init(¶m->sem, 0, 0); + + taosAsyncQueryImpl(taos, sql, syncQueryFn, param, validateOnly); + tsem_wait(¶m->sem); + + releaseTscObj(*(int64_t *)taos); + + return param->pRequest; +#else + size_t sqlLen = strlen(sql); + if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { + releaseTscObj(*(int64_t *)taos); + tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); + terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; + return NULL; + } + + TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen, validateOnly); + + releaseTscObj(*(int64_t *)taos); + + return pRes; +#endif +} + + + diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index ab4d14b1cc..da311b6b83 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -81,12 +81,6 @@ void taos_cleanup(void) { taosCloseLog(); } -setConfRet taos_set_config(const char *config) { - // TODO - setConfRet ret = {SET_CONF_RET_SUCC, {0}}; - return ret; -} - TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db); if (user == NULL) { @@ -205,51 +199,9 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { return pResInfo->userFields; } -static void syncQueryFn(void *param, void *res, int32_t code) { - SSyncQueryParam *pParam = param; - pParam->pRequest = res; - pParam->pRequest->code = code; - - tsem_post(&pParam->sem); -} TAOS_RES *taos_query(TAOS *taos, const char *sql) { - if (NULL == taos) { - terrno = TSDB_CODE_TSC_DISCONNECTED; - return NULL; - } - - STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); - if (pTscObj == NULL || sql == NULL) { - terrno = TSDB_CODE_TSC_DISCONNECTED; - return NULL; - } - -#if SYNC_ON_TOP_OF_ASYNC - SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); - tsem_init(¶m->sem, 0, 0); - - taos_query_a(taos, sql, syncQueryFn, param); - tsem_wait(¶m->sem); - - releaseTscObj(*(int64_t *)taos); - - return param->pRequest; -#else - size_t sqlLen = strlen(sql); - if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { - releaseTscObj(*(int64_t *)taos); - tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); - terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; - return NULL; - } - - TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen); - - releaseTscObj(*(int64_t *)taos); - - return pRes; -#endif + return taosQueryImpl(taos, sql, false); } TAOS_ROW taos_fetch_row(TAOS_RES *res) { @@ -639,7 +591,14 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) { return pResInfo->pCol[columnIndex].offset; } -int taos_validate_sql(TAOS *taos, const char *sql) { return true; } +int taos_validate_sql(TAOS *taos, const char *sql) { + TAOS_RES* pObj = taosQueryImpl(taos, sql, true); + + int code = taos_errno(pObj); + + taos_free_result(pObj); + return code; +} void taos_reset_current_db(TAOS *taos) { STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); @@ -729,38 +688,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { } void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) { - STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); - if (pTscObj == NULL || sql == NULL || NULL == fp) { - terrno = TSDB_CODE_INVALID_PARA; - if (pTscObj) { - releaseTscObj(*(int64_t *)taos); - } else { - terrno = TSDB_CODE_TSC_DISCONNECTED; - } - fp(param, NULL, terrno); - return; - } - - size_t sqlLen = strlen(sql); - if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { - tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); - terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; - - fp(param, NULL, terrno); - return; - } - - SRequestObj *pRequest = NULL; - int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - fp(param, NULL, terrno); - return; - } - - pRequest->body.queryFp = fp; - pRequest->body.param = param; - doAsyncQuery(pRequest, false); + taosAsyncQueryImpl(taos, sql, fp, param, false); } int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { @@ -953,10 +881,75 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { } int taos_load_table_info(TAOS *taos, const char *tableNameList) { - // TODO - return -1; + const int32_t MAX_TABLE_NAME_LENGTH = 12 * 1024 * 1024; // 12MB list + int32_t code = 0; + SRequestObj *pRequest = NULL; + SCatalogReq catalogReq = {0}; + + if (NULL == tableNameList) { + return TSDB_CODE_SUCCESS; + } + + int32_t length = (int32_t)strlen(tableNameList); + if (0 == length) { + return TSDB_CODE_SUCCESS; + } else if (length > MAX_TABLE_NAME_LENGTH) { + tscError("tableNameList too long, length:%d, maximum allowed:%d", length, MAX_TABLE_NAME_LENGTH); + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + if (pTscObj == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return terrno; + } + + code = transferTableNameList(tableNameList, pTscObj->acctId, pTscObj->db, &catalogReq.pTableMeta); + if (code) { + goto _return; + } + + SCatalog* pCtg = NULL; + code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg); + if (code != TSDB_CODE_SUCCESS) { + goto _return; + } + + char* sql = "taos_load_table_info"; + code = buildRequest(pTscObj, sql, strlen(sql), &pRequest); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + goto _return; + } + + SSyncQueryParam param = {0}; + tsem_init(¶m.sem, 0, 0); + param.pRequest = pRequest; + + SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self}; + + conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); + + code = catalogAsyncGetAllMeta(pCtg, &conn, pRequest->requestId, &catalogReq, syncCatalogFn, ¶m, NULL); + if (code) { + goto _return; + } + + tsem_wait(¶m.sem); + +_return: + + taosArrayDestroy(catalogReq.pTableMeta); + destroyRequest(pRequest); + + releaseTscObj(*(int64_t *)taos); + + return code; } + TAOS_STMT *taos_stmt_init(TAOS *taos) { STscObj *pObj = acquireTscObj(*(int64_t *)taos); if (NULL == pObj) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 269c92a670..985fbec385 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -629,6 +629,373 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { return 0; } +int32_t taosSetCfg(SConfig *pCfg, char* name) { + int32_t len = strlen(name); + char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; + strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); + + switch (lowcaseName[0]) { + case 'a': { + if (strcasecmp("asyncLog", name) == 0) { + tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval; + } + break; + } + case 'b': { + if (strcasecmp("bnodeShmSize", name) == 0) { + tsBnodeShmSize = cfgGetItem(pCfg, "bnodeShmSize")->i32; + } + break; + } + case 'c': { + if (strcasecmp("charset", name) == 0) { + const char *locale = cfgGetItem(pCfg, "locale")->str; + const char *charset = cfgGetItem(pCfg, "charset")->str; + taosSetSystemLocale(locale, charset); + osSetSystemLocale(locale, charset); + } else if (strcasecmp("compressMsgSize", name) == 0) { + tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; + } else if (strcasecmp("compressColData", name) == 0) { + tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32; + } else if (strcasecmp("countAlwaysReturnValue", name) == 0) { + tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; + } else if (strcasecmp("cDebugFlag", name) == 0) { + cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32; + } + break; + } + case 'd': { + if (strcasecmp("deadLockKillQuery", name) == 0) { + tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32; + } else if (strcasecmp("dDebugFlag", name) == 0) { + dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; + } + break; + } + case 'e': { + if (strcasecmp("enableCoreFile", name) == 0) { + bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval; + taosSetConsoleEcho(enableCore); + } + break; + } + case 'f': { + if (strcasecmp("fqdn", name) == 0) { + tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN); + tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; + snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort); + + char defaultFirstEp[TSDB_EP_LEN] = {0}; + snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); + + SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); + SEp firstEp = {0}; + taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp); + snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port); + cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype); + } else if (strcasecmp("firstEp", name) == 0) { + tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN); + tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; + snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort); + + char defaultFirstEp[TSDB_EP_LEN] = {0}; + snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); + + SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); + SEp firstEp = {0}; + taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp); + snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port); + cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype); + } else if (strcasecmp("fsDebugFlag", name) == 0) { + fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32; + } else if (strcasecmp("fnDebugFlag", name) == 0) { + fnDebugFlag = cfgGetItem(pCfg, "fnDebugFlag")->i32; + } + break; + } + case 'i': { + if (strcasecmp("idxDebugFlag", name) == 0) { + idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; + } + break; + } + case 'j': { + if (strcasecmp("jniDebugFlag", name) == 0) { + jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32; + } + break; + } + case 'k': { + if (strcasecmp("keepColumnName", name) == 0) { + tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; + } + break; + } + case 'l': { + if (strcasecmp("locale", name) == 0) { + const char *locale = cfgGetItem(pCfg, "locale")->str; + const char *charset = cfgGetItem(pCfg, "charset")->str; + taosSetSystemLocale(locale, charset); + osSetSystemLocale(locale, charset); + } else if (strcasecmp("logDir", name) == 0) { + tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX); + taosExpandDir(tsLogDir, tsLogDir, PATH_MAX); + } else if (strcasecmp("logKeepDays", name) == 0) { + tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32; + } + break; + } + case 'm': { + switch (lowcaseName[1]) { + case 'a': { + if (strcasecmp("maxShellConns", name) == 0) { + tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32; + } else if (strcasecmp("maxNumOfDistinctRes", name) == 0) { + tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; + } else if (strcasecmp("maxStreamCompDelay", name) == 0) { + tsMaxStreamComputDelay = cfgGetItem(pCfg, "maxStreamCompDelay")->i32; + } else if (strcasecmp("maxFirstStreamCompDelay", name) == 0) { + tsStreamCompStartDelay = cfgGetItem(pCfg, "maxFirstStreamCompDelay")->i32; + } + break; + } + case 'd': { + if (strcasecmp("mDebugFlag", name) == 0) { + mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32; + } + break; + } + case 'i': { + if (strcasecmp("minimalTempDirGB", name) == 0) { + tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval; + } else if (strcasecmp("minimalDataDirGB", name) == 0) { + tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval; + } else if (strcasecmp("minSlidingTime", name) == 0) { + tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32; + } else if (strcasecmp("minIntervalTime", name) == 0) { + tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32; + } else if (strcasecmp("minimalLogDirGB", name) == 0) { + tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval; + } + break; + } + case 'n': { + if (strcasecmp("mnodeShmSize", name) == 0) { + tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32; + } + break; + } + case 'o': { + if (strcasecmp("monitor", name) == 0) { + tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; + } else if (strcasecmp("monitorInterval", name) == 0) { + tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; + } else if (strcasecmp("monitorFqdn", name) == 0) { + tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN); + } else if (strcasecmp("monitorPort", name) == 0) { + tsMonitorPort = (uint16_t)cfgGetItem(pCfg, "monitorPort")->i32; + } else if (strcasecmp("monitorMaxLogs", name) == 0) { + tsMonitorMaxLogs = cfgGetItem(pCfg, "monitorMaxLogs")->i32; + } else if (strcasecmp("monitorComp", name) == 0) { + tsMonitorComp = cfgGetItem(pCfg, "monitorComp")->bval; + } + break; + } + case 'q': { + if (strcasecmp("mqRebalanceInterval", name) == 0) { + tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32; + } + break; + } + case 'u': { + if (strcasecmp("multiProcess", name) == 0) { + tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; + } + break; + } + default: + terrno = TSDB_CODE_CFG_NOT_FOUND; + return -1; + } + break; + } + case 'n': { + if (strcasecmp("numOfTaskQueueThreads", name) == 0) { + tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32; + } else if (strcasecmp("numOfRpcThreads", name) == 0) { + tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; + } else if (strcasecmp("numOfCommitThreads", name) == 0) { + tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; + } else if (strcasecmp("numOfMnodeQueryThreads", name) == 0) { + tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32; + } else if (strcasecmp("numOfMnodeReadThreads", name) == 0) { + tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; + } else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) { + tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; + } else if (strcasecmp("numOfVnodeFetchThreads", name) == 0) { + tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32; + } else if (strcasecmp("numOfVnodeWriteThreads", name) == 0) { + tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32; + } else if (strcasecmp("numOfVnodeSyncThreads", name) == 0) { + tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32; + } else if (strcasecmp("numOfVnodeMergeThreads", name) == 0) { + tsNumOfVnodeMergeThreads = cfgGetItem(pCfg, "numOfVnodeMergeThreads")->i32; + } else if (strcasecmp("numOfQnodeQueryThreads", name) == 0) { + tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32; + } else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) { + tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32; + } else if (strcasecmp("numOfSnodeSharedThreads", name) == 0) { + tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32; + } else if (strcasecmp("numOfSnodeUniqueThreads", name) == 0) { + tsNumOfSnodeUniqueThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; + } else if (strcasecmp("numOfLogLines", name) == 0) { + tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32; + } + break; + } + case 'p': { + if (strcasecmp("printAuth", name) == 0) { + tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; + } + break; + } + case 'q': { + if (strcasecmp("queryPolicy", name) == 0) { + tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; + } else if (strcasecmp("querySmaOptimize", name) == 0) { + tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; + } else if (strcasecmp("queryBufferSize", name) == 0) { + tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; + if (tsQueryBufferSize >= 0) { + tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; + } + } else if (strcasecmp("qnodeShmSize", name) == 0) { + tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32; + } else if (strcasecmp("qDebugFlag", name) == 0) { + qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32; + } + break; + } + case 'r': { + if (strcasecmp("retryStreamCompDelay", name) == 0) { + tsRetryStreamCompDelay = cfgGetItem(pCfg, "retryStreamCompDelay")->i32; + } else if (strcasecmp("retrieveBlockingModel", name) == 0) { + tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; + } else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { + tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; + } else if (strcasecmp("rpcDebugFlag", name) == 0) { + rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; + } + break; + } + case 's': { + if (strcasecmp("secondEp", name) == 0) { + SConfigItem *pSecondpItem = cfgGetItem(pCfg, "secondEp"); + SEp secondEp = {0}; + taosGetFqdnPortFromEp(strlen(pSecondpItem->str) == 0 ? tsFirst : pSecondpItem->str, &secondEp); + snprintf(tsSecond, sizeof(tsSecond), "%s:%u", secondEp.fqdn, secondEp.port); + cfgSetItem(pCfg, "secondEp", tsSecond, pSecondpItem->stype); + } else if (strcasecmp("smlChildTableName", name) == 0) { + tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN); + } else if (strcasecmp("smlTagName", name) == 0) { + tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); + } else if (strcasecmp("smlDataFormat", name) == 0) { + tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; + } else if (strcasecmp("shellActivityTimer", name) == 0) { + tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; + } else if (strcasecmp("supportVnodes", name) == 0) { + tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32; + } else if (strcasecmp("statusInterval", name) == 0) { + tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; + } else if (strcasecmp("streamCompDelayRatio", name) == 0) { + tsStreamComputDelayRatio = cfgGetItem(pCfg, "streamCompDelayRatio")->fval; + } else if (strcasecmp("slaveQuery", name) == 0) { + tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval; + } else if (strcasecmp("snodeShmSize", name) == 0) { + tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32; + } else if (strcasecmp("serverPort", name) == 0) { + tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN); + tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; + snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort); + + char defaultFirstEp[TSDB_EP_LEN] = {0}; + snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); + + SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); + SEp firstEp = {0}; + taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp); + snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port); + cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype); + } else if (strcasecmp("sDebugFlag", name) == 0) { + sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32; + } else if (strcasecmp("smaDebugFlag", name) == 0) { + smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; + } + break; + } + case 't': { + if (strcasecmp("timezone", name) == 0) { + SConfigItem *pItem = cfgGetItem(pCfg, "timezone"); + osSetTimezone(pItem->str); + uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr); + cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype); + } else if (strcasecmp("tempDir", name) == 0) { + tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX); + taosExpandDir(tsTempDir, tsTempDir, PATH_MAX); + if (taosMulMkDir(tsTempDir) != 0) { + uError("failed to create tempDir:%s since %s", tsTempDir, terrstr()); + return -1; + } + } else if (strcasecmp("telemetryReporting", name) == 0) { + tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; + } else if (strcasecmp("telemetryInterval", name) == 0) { + tsTelemInterval = cfgGetItem(pCfg, "telemetryInterval")->i32; + } else if (strcasecmp("telemetryServer", name) == 0) { + tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN); + } else if (strcasecmp("telemetryPort", name) == 0) { + tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32; + } else if (strcasecmp("transPullupInterval", name) == 0) { + tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; + } else if (strcasecmp("tmrDebugFlag", name) == 0) { + tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32; + } else if (strcasecmp("tsdbDebugFlag", name) == 0) { + tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32; + } else if (strcasecmp("tqDebugFlag", name) == 0) { + tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32; + } + break; + } + case 'u': { + if (strcasecmp("udf", name) == 0) { + tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; + } else if (strcasecmp("uDebugFlag", name) == 0) { + uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32; + } + break; + } + case 'v': { + if (strcasecmp("vnodeShmSize", name) == 0) { + tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32; + } else if (strcasecmp("vDebugFlag", name) == 0) { + vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32; + } + break; + } + case 'w': { + if (strcasecmp("wDebugFlag", name) == 0) { + wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32; + } + break; + } + default: + terrno = TSDB_CODE_CFG_NOT_FOUND; + return -1; + } + + return 0; +} + + int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) { osDefaultInit(); diff --git a/source/common/src/tname.c b/source/common/src/tname.c index ce454d439d..fb3a2d7464 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -214,6 +214,20 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name return 0; } +int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) { + assert(dst != NULL && tbName != NULL && nameLen > 0); + + // too long account id or too long db name + if (nameLen >= tListLen(dst->tname) || nameLen <= 0) { + return -1; + } + + dst->type = TSDB_TABLE_NAME_T; + tstrncpy(dst->tname, tbName, nameLen + 1); + return 0; +} + + int32_t tNameSetAcctId(SName* dst, int32_t acctId) { assert(dst != NULL); dst->acctId = acctId; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 8869e679ae..40eca2c71b 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -555,6 +555,10 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { return terrno; } + if (taosSetCfg(tsCfg, pStmt->config)) { + return terrno; + } + return TSDB_CODE_SUCCESS; } From b7bb08d66516804a621156d78f7ba5e26acef2d6 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 24 Jun 2022 09:12:47 +0800 Subject: [PATCH 29/81] update test case --- tests/system-test/2-query/Now.py | 43 +++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/system-test/2-query/Now.py b/tests/system-test/2-query/Now.py index 9d073eb4f7..a5c2a93aa4 100644 --- a/tests/system-test/2-query/Now.py +++ b/tests/system-test/2-query/Now.py @@ -3,14 +3,55 @@ from util.dnodes import * from util.log import * from util.sql import * from util.cases import * - +from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + # name of normal table + self.ntbname = 'ntb' + # name of stable + self.stbname = 'stb' + # structure of column + self.column_dict = { + 'ts':'timestamp', + 'c1':'int', + 'c2':'float', + 'c3':'double' + } + # structure of tag + self.tag_dict = { + 't0':'int' + } + # number of child tables + self.tbnum = 2 + # values of tag,the number of values should equal to tbnum + self.tag_values = [ + f'10', + f'100' + ] + self.values_list = [ + f'now,10,99.99,11.111111', + f'today(),100,11.111,22.222222' + ] + self.time_unit = ['b','u','a','s','m','h','d','w'] + + def now_check_ntb(self): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + for value in self.values_list: + tdSql.execute( + f'insert into {self.ntbname} values({value})') + + + + pass + def now_check_stb(self): + pass def run(self): # sourcery skip: extract-duplicate-method # for func now() , today(), timezone() tdSql.prepare() From 28d66616e19d7ccf6aad5bc5ed286557393a6734 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 24 Jun 2022 10:48:49 +0800 Subject: [PATCH 30/81] fix: fix invalid write --- include/libs/nodes/nodes.h | 1 + source/libs/nodes/src/nodesUtilFuncs.c | 18 ++++++++++++++++++ source/libs/parser/src/parCalcConst.c | 5 ++++- source/libs/parser/src/parTranslater.c | 4 ++-- source/libs/planner/src/planPhysiCreater.c | 3 +++ source/libs/planner/test/planTestMain.cpp | 9 ++++++++- source/libs/planner/test/planTestUtil.cpp | 11 +++++++++-- 7 files changed, 45 insertions(+), 6 deletions(-) diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 777e67769f..2153f59bf8 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -285,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); SNode* nodesListGetNode(SNodeList* pList, int32_t index); +SListCell* nodesListGetCell(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); // Only clear the linked list structure, without releasing the elements inside void nodesClearList(SNodeList* pList); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 57ead2d2ae..1d8baf5373 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -372,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) { static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); } +static void destroyExprNode(SExprNode* pExpr) { taosArrayDestroy(pExpr->pAssociation); } + void nodesDestroyNode(SNode* pNode) { if (NULL == pNode) { return; @@ -379,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: // pProjectRef is weak reference, no need to release + destroyExprNode((SExprNode*)pNode); break; case QUERY_NODE_VALUE: { SValueNode* pValue = (SValueNode*)pNode; + destroyExprNode((SExprNode*)pNode); taosMemoryFreeClear(pValue->literal); if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { taosMemoryFreeClear(pValue->datum.p); @@ -390,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) { } case QUERY_NODE_OPERATOR: { SOperatorNode* pOp = (SOperatorNode*)pNode; + destroyExprNode((SExprNode*)pNode); nodesDestroyNode(pOp->pLeft); nodesDestroyNode(pOp->pRight); break; } case QUERY_NODE_LOGIC_CONDITION: + destroyExprNode((SExprNode*)pNode); nodesDestroyList(((SLogicConditionNode*)pNode)->pParameterList); break; case QUERY_NODE_FUNCTION: + destroyExprNode((SExprNode*)pNode); nodesDestroyList(((SFunctionNode*)pNode)->pParameterList); break; case QUERY_NODE_REAL_TABLE: { @@ -833,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) { destroyPhysiNode((SPhysiNode*)pPhyNode); nodesDestroyList(pPhyNode->pExprs); nodesDestroyList(pPhyNode->pSortKeys); + nodesDestroyList(pPhyNode->pTargets); break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: @@ -1096,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) { return NULL; } +SListCell* nodesListGetCell(SNodeList* pList, int32_t index) { + SNode* node; + FOREACH(node, pList) { + if (0 == index--) { + return cell; + } + } + return NULL; +} + void nodesDestroyList(SNodeList* pList) { if (NULL == pList) { return; diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 495950f35c..dcdf73630f 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -183,12 +183,15 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) { int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { SNode** pCol = taosArrayGetP(pAssociation, i); + nodesDestroyNode(*pCol); *pCol = nodesCloneNode(*pNew); if (NULL == *pCol) { - return TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + break; } } } + taosArrayDestroy(pAssociation); return code; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index eb767ffa61..424968ac80 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p if (NULL == pCol) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); } - setColumnInfoByExpr(pTable, (SExprNode*)pNode, &pCol); nodesListAppend(pList, (SNode*)pCol); + SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); + setColumnInfoByExpr(pTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); } } return TSDB_CODE_SUCCESS; @@ -4658,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema return TSDB_CODE_SUCCESS; } - int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { if (NULL == pRoot) { return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index fc88d46c7b..efb0f790e1 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1197,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren nodesDestroyNode((SNode*)pSort); } + nodesDestroyList(pPrecalcExprs); + nodesDestroyList(pSortKeys); + return code; } diff --git a/source/libs/planner/test/planTestMain.cpp b/source/libs/planner/test/planTestMain.cpp index acac3d5053..43b6bf5772 100644 --- a/source/libs/planner/test/planTestMain.cpp +++ b/source/libs/planner/test/planTestMain.cpp @@ -16,9 +16,11 @@ #include #include + #include "functionMgt.h" #include "getopt.h" #include "mockCatalog.h" +#include "parser.h" #include "planTestUtil.h" class PlannerEnv : public testing::Environment { @@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment { initLog(TD_TMP_DIR_PATH "td"); } - virtual void TearDown() { destroyMetaDataEnv(); } + virtual void TearDown() { + destroyMetaDataEnv(); + qCleanupKeywordsTable(); + fmFuncMgtDestroy(); + taosCloseLog(); + } PlannerEnv() {} virtual ~PlannerEnv() {} diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index 57d7cb6608..f1ab9c8196 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -102,12 +102,15 @@ class PlannerTestBaseImpl { try { SQuery* pQuery = nullptr; doParseSql(sql, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); SPlanContext cxt = {0}; setPlanContext(pQuery, &cxt); SLogicSubplan* pLogicSubplan = nullptr; doCreateLogicPlan(&cxt, &pLogicSubplan); + unique_ptr logicSubplan(pLogicSubplan, + (void (*)(SLogicSubplan*))nodesDestroyNode); doOptimizeLogicPlan(&cxt, pLogicSubplan); @@ -115,9 +118,12 @@ class PlannerTestBaseImpl { SQueryLogicPlan* pLogicPlan = nullptr; doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan); + unique_ptr logicPlan(pLogicPlan, + (void (*)(SQueryLogicPlan*))nodesDestroyNode); SQueryPlan* pPlan = nullptr; doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan); + unique_ptr plan(pPlan, (void (*)(SQueryPlan*))nodesDestroyNode); dump(g_dumpModule); } catch (...) { @@ -345,8 +351,9 @@ class PlannerTestBaseImpl { } void doCreatePhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan) { - SArray* pExecNodeList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr)); - DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, pExecNodeList); + unique_ptr execNodeList((SArray*)taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr)), + (void (*)(SArray*))taosArrayDestroy); + DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, execNodeList.get()); res_.physiPlan_ = toString((SNode*)(*pPlan)); SNode* pNode; FOREACH(pNode, (*pPlan)->pSubplans) { From 8ebe2c81c7327615925d1b88e4f4a8c445bd7021 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 11:12:05 +0800 Subject: [PATCH 31/81] test: adjust test case --- ...distribute_vgroup_replica3_v1_follower.sim | 33 ++++++++++----- ...redistribute_vgroup_replica3_v1_leader.sim | 42 ++++++++++++++----- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim index 788a23991a..9b11e16616 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim @@ -112,7 +112,7 @@ if $data(5)[4] != ready then goto step2 endi -print =============== step31: move follower +print =============== step3: create database $leaderExist = 0 $leaderVnode = 0 $follower1 = 0 @@ -165,7 +165,7 @@ if $rows != 1 then return -1 endi -print =============== step32: move follower2 +print =============== step31: print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql show d1.vgroups @@ -178,7 +178,7 @@ endi return -print =============== step33: move follower1 +print =============== step32: print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql show d1.vgroups @@ -189,7 +189,7 @@ if $rows != 1 then return -1 endi -print =============== step34: move follower2 +print =============== step33: print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql show d1.vgroups @@ -200,7 +200,7 @@ if $rows != 1 then return -1 endi -print =============== step35: move follower1 +print =============== step34: print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql show d1.vgroups @@ -211,9 +211,9 @@ if $rows != 1 then return -1 endi -print =============== step36: move follower2 -print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 -sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 +print =============== step34: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -222,7 +222,7 @@ if $rows != 1 then return -1 endi -print =============== step37: move follower1 +print =============== step36: print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql show d1.vgroups @@ -233,7 +233,7 @@ if $rows != 1 then return -1 endi -print =============== step38: move follower2 +print =============== step37: print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql show d1.vgroups @@ -244,7 +244,7 @@ if $rows != 1 then return -1 endi -print =============== step39: move follower1 +print =============== step38: print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql show d1.vgroups @@ -255,6 +255,17 @@ if $rows != 1 then return -1 endi +print =============== step39: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim index e9dd82cad9..947482b3d4 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim @@ -91,7 +91,7 @@ if $data(5)[4] != ready then goto step2 endi -print =============== step31: move follower +print =============== step3: create database $leaderExist = 0 $leaderVnode = 0 $follower1 = 0 @@ -144,7 +144,7 @@ if $rows != 1 then return -1 endi -print =============== step32: move leader +print =============== step40: move leader print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 sql show d1.vgroups @@ -155,9 +155,7 @@ if $rows != 1 then return -1 endi -return - -print =============== step33: move follower1 +print =============== step41: print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql show d1.vgroups @@ -168,7 +166,7 @@ if $rows != 1 then return -1 endi -print =============== step34: move follower2 +print =============== step42: print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $leaderVnode sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $leaderVnode sql show d1.vgroups @@ -179,7 +177,18 @@ if $rows != 1 then return -1 endi -print =============== step35: move leader +print =============== step43: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $follower1 sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $follower1 sql show d1.vgroups @@ -190,7 +199,7 @@ if $rows != 1 then return -1 endi -print =============== step36: move follower1 +print =============== step45: print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql show d1.vgroups @@ -201,7 +210,7 @@ if $rows != 1 then return -1 endi -print =============== step37: move follower2 +print =============== step46: print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql show d1.vgroups @@ -212,7 +221,7 @@ if $rows != 1 then return -1 endi -print =============== step38: move leader +print =============== step47: print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2 sql show d1.vgroups @@ -223,7 +232,18 @@ if $rows != 1 then return -1 endi -print =============== step39: move follower1 +print =============== step48: +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step49: print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql show d1.vgroups From a1cc2571ee871605989306712d19f968f2929758 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 24 Jun 2022 11:13:40 +0800 Subject: [PATCH 32/81] fix(wal): set first version to -1 if all log rollbacked --- source/libs/wal/src/walWrite.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 031289f93e..da7aa317d3 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -178,6 +178,10 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer = ver - 1; ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize = entry.offset; + if (((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer < ver - 1) { + ASSERT(((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize == 0); + ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->firstVer = -1; + } taosCloseFile(&pIdxTFile); taosCloseFile(&pLogTFile); @@ -395,8 +399,12 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLog } // set status + if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index; pWal->vers.lastVer = index; pWal->totSize += sizeof(SWalHead) + bodyLen; + if (walGetCurFileInfo(pWal)->firstVer == -1) { + walGetCurFileInfo(pWal)->firstVer = index; + } walGetCurFileInfo(pWal)->lastVer = index; walGetCurFileInfo(pWal)->fileSize += sizeof(SWalHead) + bodyLen; From 411d30f3db8d1ddf4d6d7604b4799bfdd36f56fb Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 24 Jun 2022 11:19:16 +0800 Subject: [PATCH 33/81] handle except --- source/libs/transport/inc/transComm.h | 1 + source/libs/transport/src/transCli.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 327fe50814..bbd9ce3a78 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -125,6 +125,7 @@ typedef struct { STransMsg* pRsp; // for synchronous API tsem_t* pSem; // for synchronous API SCvtAddr cvtAddr; + bool setMaxRetry; int hThrdIdx; } STransConnCtx; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 0dd00e0dc2..beaef2758e 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -980,7 +980,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { tTrace("try to send req to next node"); pMsg->st = taosGetTimestampUs(); pCtx->retryCount += 1; - if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL && pCtx->setMaxRetry == false) { if (pCtx->retryCount < pEpSet->numOfEps * 3) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; if (pThrd->quit == false) { @@ -997,6 +997,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { } } } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { + pCtx->setMaxRetry = true; if (pResp->contLen == 0) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; transPrintEpSet(&pCtx->epSet); @@ -1012,8 +1013,10 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT); } if (pThrd->quit == false) { - if (pConn->status != ConnInPool) { + if (pConn->status != ConnInPool && pResp->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) { addConnToPool(pThrd->pool, pConn); + } else { + transUnrefCliHandle(pConn); } STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); arg->param1 = pMsg; From 4f305c74d10bb317b8e96bdad6dac080c946f927 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 24 Jun 2022 11:24:31 +0800 Subject: [PATCH 34/81] fix: table group error in stream --- source/libs/executor/src/executorimpl.c | 1 + source/libs/executor/src/scanoperator.c | 10 ++++++---- source/libs/planner/src/planOptimizer.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index b90c769c21..1e5d75655c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4055,6 +4055,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; + pTableListInfo->needSortTableByGroupId = true; int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); if(code){ return NULL; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 81e8e19892..ccd7bf04aa 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -510,10 +510,11 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { if(pInfo->currentGroupId == -1){ pInfo->currentGroupId++; if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) { - doSetOperatorCompleted(pOperator); + setTaskStatus(pTaskInfo, TASK_COMPLETED); return NULL; } SArray *tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId); + tsdbCleanupReadHandle(pInfo->dataReader); tsdbReaderT* pReader = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, pInfo->queryId, pInfo->taskId); pInfo->dataReader = pReader; } @@ -525,7 +526,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { pInfo->currentGroupId++; if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) { - doSetOperatorCompleted(pOperator); + setTaskStatus(pTaskInfo, TASK_COMPLETED); return NULL; } @@ -541,7 +542,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { return result; } - doSetOperatorCompleted(pOperator); + setTaskStatus(pTaskInfo, TASK_COMPLETED); return NULL; } @@ -821,8 +822,9 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) { STableScanInfo* pTableScanInfo = pInfo->pSnapshotReadOp->info; pTableScanInfo->cond.twindows[0] = win; pTableScanInfo->curTWinIdx = 0; - tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); +// tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); pTableScanInfo->scanTimes = 0; + pTableScanInfo->currentGroupId = -1; return true; } diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 5b9dbe8388..c2551392b3 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1189,7 +1189,7 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize}, {.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize}, {.pName = "SmaIndex", .optimizeFunc = smaOptimize}, - // {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize}, + {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize}, {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize} }; // clang-format on From b3fa103cb9cc4a3367b6fad734240c62689b3b5a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 11:36:26 +0800 Subject: [PATCH 35/81] refactor(sync): add trace log --- source/libs/sync/src/syncMain.c | 42 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 8bbee65369..42ba2b85b1 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1322,11 +1322,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { snprintf(logBuf, sizeof(logBuf), "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, %s", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing, printStr); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(logBuf, sizeof(logBuf), "%s", str); } @@ -1339,11 +1339,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { snprintf(s, len, "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, %s", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing, printStr); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(s, len, "%s", str); } @@ -1403,14 +1403,34 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) { char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { int len = 256; char* s = (char*)taosMemoryMalloc(len); + + SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; + if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { + pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + } + SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + snprintf(s, len, - "syncNode: vgId:%d, currentTerm:%lu, commitIndex:%ld, state:%d %s, isStandBy:%d, " - "electTimerLogicClock:%lu, " - "electTimerLogicClockUser:%lu, " - "electTimerMS:%d, replicaNum:%d", - pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state, - syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock, - pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum); + "vgId:%d, sync %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "replica-num:%d, " + "lconfig:%ld, changing:%d, restore:%d", + pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, + pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, + pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); + + /* + snprintf(s, len, + "syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, " + "lc:%lu, " + "lc-user:%lu, " + "ems:%d, replica-num:%d, restore:%d, changing:%d", + pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state, + syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock, + pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum, + pSyncNode->restoreFinish, pSyncNode->changing); + */ + return s; } From b2537cb4870cd7861e392c0aff48ff66f41c17c9 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 24 Jun 2022 13:33:34 +0800 Subject: [PATCH 36/81] =?UTF-8?q?refactor=EF=BC=9Arefine=20Now.py=20to=20b?= =?UTF-8?q?e=20parameter=20driven?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/system-test/2-query/Now.py | 469 +++---------------------------- 1 file changed, 43 insertions(+), 426 deletions(-) diff --git a/tests/system-test/2-query/Now.py b/tests/system-test/2-query/Now.py index a5c2a93aa4..6785fddc6f 100644 --- a/tests/system-test/2-query/Now.py +++ b/tests/system-test/2-query/Now.py @@ -9,7 +9,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(),True) self.setsql = TDSetSql() # name of normal table self.ntbname = 'ntb' @@ -38,7 +38,36 @@ class TDTestCase: f'today(),100,11.111,22.222222' ] self.time_unit = ['b','u','a','s','m','h','d','w'] - + self.symbol = ['+','-','*','/'] + self.error_values = [1.5,'abc','"abc"','!@','today()'] + def tbtype_check(self,tb_type): + if tb_type == 'normal table' or tb_type == 'child table': + tdSql.checkRows(len(self.values_list)) + elif tb_type == 'stable': + tdSql.checkRows(len(self.values_list) * self.tbnum) + def data_check(self,tbname,tb_type): + tdSql.query(f'select now() from {tbname}') + self.tbtype_check(tb_type) + for unit in self.time_unit: + for symbol in self.symbol: + if symbol in ['+','-']: + tdSql.query(f'select now() {symbol}1{unit} from {tbname}') + self.tbtype_check(tb_type) + for k,v in self.column_dict.items(): + if v.lower() != 'timestamp': + continue + else: + tdSql.query(f'select * from {tbname} where {k}>=now()') + tdSql.checkRows(0) + tdSql.query(f'select * from {tbname} where {k}=now()") - tdSql.checkRows(0) - tdSql.query("select * from db.ntb where ts>=now()") - tdSql.checkRows(0) - tdSql.query("select * from ntb where ts>now()") - tdSql.checkRows(0) - tdSql.query("select * from db.ntb where ts>now()") - tdSql.checkRows(0) - tdSql.query("select now() from ntb where ts=today()") - tdSql.checkRows(1) - tdSql.query("select now() from db.ntb where ts=today()") - tdSql.checkRows(1) - tdSql.query("select now()+1 from ntb") - tdSql.checkRows(3) - tdSql.query("select now()+1 from db.ntb") - tdSql.checkRows(3) - # tdSql.query("select now()+9223372036854775807 from ntb") - # tdSql.checkRows(3) - - tdSql.error("select now()+1.5 from ntb") - tdSql.error("select now()+1.5 from db.ntb") - tdSql.error("select now()-1.5 from ntb") - tdSql.error("select now()-1.5 from db.ntb") - tdSql.error("select now()*1.5 from ntb") - tdSql.error("select now()*1.5 from db.ntb") - tdSql.error("select now()/1.5 from ntb") - tdSql.error("select now()/1.5 from db.ntb") - tdSql.error("select now()+'abc' from ntb") - tdSql.error("select now()+'abc' from db.ntb") - tdSql.error("select now()+abc from ntb") - tdSql.error("select now()+abc from db.ntb") - tdSql.error("select now()+! from ntb") - tdSql.error("select now()+! from db.ntb") - - tdSql.query("select now()+null from ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()+null from db.ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from db.ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from db.ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from ntb") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from db.ntb") - tdSql.checkData(0,0,None) - - tdSql.error("select now() +today() from ntb") - tdSql.error("select now() +today() from db.ntb") + self.now_check_ntb() + self.now_check_stb() - # stable - tdSql.query("select now() from stb") - tdSql.checkRows(3) - tdSql.query("select now() from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1w from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1w from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1d from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1d from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1h from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1h from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1m from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1m from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1s from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1s from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1a from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1a from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1u from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1u from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() +1b from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1b from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1w from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1w from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1d from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1d from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1h from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1h from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1m from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1m from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1s from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1s from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1a from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1a from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1u from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1u from db.stb") - tdSql.checkRows(3) - tdSql.query("select now() -1b from stb") - tdSql.checkRows(3) - tdSql.query("select now() -1b from db.stb") - tdSql.checkRows(3) - # tdSql.query("select * from stb where ts=now()") - # tdSql.checkRows(0) - # tdSql.query("select * from stb where ts>now()") - # tdSql.checkRows(0) - tdSql.query("select now() from stb where ts=today()") - tdSql.checkRows(1) - tdSql.query("select now() from db.stb where ts=today()") - tdSql.checkRows(1) - tdSql.query("select now() +1 from stb") - tdSql.checkRows(3) - tdSql.query("select now() +1 from db.stb") - tdSql.checkRows(3) - tdSql.error("select now() +1.5 from stb") - tdSql.error("select now() -1.5 from stb") - tdSql.error("select now() *1.5 from stb") - tdSql.error("select now() /1.5 from stb") - tdSql.error("select now() +'abc' from stb") - tdSql.error("select now() +'abc' from db.stb") - tdSql.error("select now() + ! from stb") - tdSql.error("select now() + ! from db.stb") - tdSql.error("select now() + today() from stb") - tdSql.error("select now() + today() from db.stb") - tdSql.error("select now() -today() from stb") - tdSql.error("select now() - today() from db.stb") - - - tdSql.query("select now()+null from stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()+null from db.stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from db.stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from db.stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from stb") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from db.stb") - tdSql.checkData(0,0,None) - - # table - tdSql.query("select now() from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1w from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1w from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1d from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1d from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1h from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1h from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1m from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1m from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1s from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1s from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1a from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1a from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1u from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1u from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1b from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() +1b from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1w from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1w from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1d from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1d from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1h from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1h from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1m from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1m from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1s from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1s from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1a from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1a from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1u from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1u from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1b from stb_1") - tdSql.checkRows(3) - tdSql.query("select now() -1b from db.stb_1") - tdSql.checkRows(3) - tdSql.query("select * from stb_1 where ts=now()") - tdSql.checkRows(0) - tdSql.query("select * from db.stb_1 where ts>=now()") - tdSql.checkRows(0) - tdSql.query("select * from stb_1 where ts>now()") - tdSql.checkRows(0) - tdSql.query("select * from db.stb_1 where ts>now()") - tdSql.checkRows(0) - - # tdSql.query("select * from stb_1 where ts=now") - # tdSql.checkRows(0) - # tdSql.query("select * from stb_1 where ts>now") - # tdSql.checkRows(0) - - tdSql.query("select now() from stb_1 where ts=today()") - tdSql.checkRows(1) - - tdSql.error("select now() +'abc' from stb_1") - tdSql.error("select now() +'abc' from db.stb_1") - tdSql.error("select now() + ! from stb_1") - tdSql.error("select now() + ! from db.stb_1") - tdSql.error("select now() + today() from stb_1") - tdSql.error("select now() + today() from db.stb_1") - tdSql.error("select now() - today() from stb_1") - tdSql.error("select now()-today() from db.stb_1") - - tdSql.query("select now()+null from stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()+null from db.stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()-null from db.stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()*null from db.stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from stb_1") - tdSql.checkData(0,0,None) - tdSql.query("select now()/null from db.stb_1") - tdSql.checkData(0,0,None) def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") From 8060108585cb9cfc015d95899fb5def9036825b9 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 13:50:23 +0800 Subject: [PATCH 37/81] refactor(sync): add trace log --- source/libs/sync/src/syncElection.c | 9 ++++++- source/libs/sync/src/syncReplication.c | 4 ++-- source/libs/sync/src/syncRequestVote.c | 33 +++++++++++++++++++------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index e0f2b0fed2..738b17b9cb 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -105,9 +105,16 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { } int32_t syncNodeRequestVote(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncRequestVote* pMsg) { - sTrace("syncNodeRequestVote pSyncNode:%p ", pSyncNode); int32_t ret = 0; + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-request-vote to %s:%d, {term:%lu, last-index:%ld, last-term:%lu}", pSyncNode->vgId, host, + port, pMsg->term, pMsg->lastLogTerm, pMsg->lastLogIndex); + } while (0); + SRpcMsg rpcMsg; syncRequestVote2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 02cd977e1e..46850758f1 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -224,8 +224,8 @@ int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, c uint16_t port; syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); sDebug( - "vgId:%d, send sync-append-entries to %s:%d, term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, commit:%ld, " - "datalen:%d", + "vgId:%d, send sync-append-entries to %s:%d, {term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, commit:%ld, " + "datalen:%d}", pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm, pMsg->commitIndex, pMsg->dataLen); } while (0); diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index def5c321ad..9b181e21e5 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -99,15 +99,20 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* pSyncNode, SyncRequestVote* pM int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t ret = 0; - // print log - char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "recv SyncRequestVote, currentTerm:%lu", ths->pRaftStore->currentTerm); - syncRequestVoteLog2(logBuf, pMsg); - // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) { - sInfo("recv SyncRequestVote maybe replica already dropped"); - return ret; + do { + char logBuf[128]; + char host[64]; + uint16_t port; + syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); + snprintf(logBuf, sizeof(logBuf), + "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, maybe replica already dropped", + host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm); + syncNodeEventLog(ths, logBuf); + } while (0); + + return -1; } // maybe update term @@ -135,10 +140,22 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { pReply->term = ths->pRaftStore->currentTerm; pReply->voteGranted = grant; + // trace log + do { + char logBuf[128]; + char host[64]; + uint16_t port; + syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); + snprintf(logBuf, sizeof(logBuf), + "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, reply-grant:%d", host, port, + pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, pReply->voteGranted); + syncNodeEventLog(ths, logBuf); + } while (0); + SRpcMsg rpcMsg; syncRequestVoteReply2RpcMsg(pReply, &rpcMsg); syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); syncRequestVoteReplyDestroy(pReply); - return ret; + return 0; } \ No newline at end of file From 778d58c28138b74406e5f08cbe021181e34921f1 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 24 Jun 2022 13:56:35 +0800 Subject: [PATCH 38/81] test: add test time count print --- tests/system-test/simpletest.bat | 8 ++++---- tests/system-test/test.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/system-test/simpletest.bat b/tests/system-test/simpletest.bat index 0b1f16d216..656828aa1e 100644 --- a/tests/system-test/simpletest.bat +++ b/tests/system-test/simpletest.bat @@ -1,12 +1,12 @@ -@REM python3 .\test.py -f 0-others\taosShell.py -@REM python3 .\test.py -f 0-others\taosShellError.py +python3 .\test.py -f 0-others\taosShell.py +python3 .\test.py -f 0-others\taosShellError.py python3 .\test.py -f 0-others\taosShellNetChk.py python3 .\test.py -f 0-others\telemetry.py python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\udfTest.py -@REM python3 .\test.py -f 0-others\udf_create.py -@REM python3 .\test.py -f 0-others\udf_restart_taosd.py +python3 .\test.py -f 0-others\udf_create.py +python3 .\test.py -f 0-others\udf_restart_taosd.py @REM python3 .\test.py -f 0-others\cachelast.py @REM python3 .\test.py -f 0-others\user_control.py diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 7d78f5ab21..8a8356449c 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -38,7 +38,9 @@ def checkRunTimeError(): while 1: time.sleep(1) timeCount = timeCount + 1 + print("checkRunTimeError",timeCount) if (timeCount>900): + print("stop the test.") os.system("TASKKILL /F /IM taosd.exe") os.system("TASKKILL /F /IM taos.exe") os.system("TASKKILL /F /IM tmq_sim.exe") From d5ab6209c7c61122390a8740115b9047241e326a Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 24 Jun 2022 14:04:25 +0800 Subject: [PATCH 39/81] test: add test time count print --- tests/script/sh/cfg.bat | 4 +- tests/script/sh/copy_udf.bat | 2 +- tests/script/sh/deploy.bat | 4 +- tests/script/sh/exec.bat | 4 +- tests/script/tsim/sync/3Replica1VgElect.sim | 8 +-- tests/script/tsim/sync/3Replica5VgElect.sim | 8 +-- tests/script/tsim/sync/oneReplica5VgElect.sim | 8 +-- tests/script/tsim/tmq/consume.bat | 67 +++++++++++++++++++ tests/script/wtest.bat | 4 +- 9 files changed, 88 insertions(+), 21 deletions(-) create mode 100644 tests/script/tsim/tmq/consume.bat diff --git a/tests/script/sh/cfg.bat b/tests/script/sh/cfg.bat index 49ab34383a..c25bebd159 100644 --- a/tests/script/sh/cfg.bat +++ b/tests/script/sh/cfg.bat @@ -16,12 +16,12 @@ rem echo NODE: %NODE% set SCRIPT_DIR=%~dp0..\ rem echo SCRIPT_DIR: %SCRIPT_DIR% -set BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\ +echo %cd% | grep community > nul && set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" || set "BUILD_DIR=%SCRIPT_DIR%..\..\debug\build\bin\" set TSIM=%BUILD_DIR%tsim rem echo BUILD_DIR: %BUILD_DIR% rem echo TSIM: %TSIM% -set SIM_DIR=%SCRIPT_DIR%..\..\..\sim\ +echo %cd% | grep community > nul && set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" || set "SIM_DIR=%SCRIPT_DIR%..\..\sim\" rem echo SIM_DIR: %SIM_DIR% set NODE_DIR=%SIM_DIR%%NODE_NAME%\ diff --git a/tests/script/sh/copy_udf.bat b/tests/script/sh/copy_udf.bat index 5144cf8d25..597b77792e 100644 --- a/tests/script/sh/copy_udf.bat +++ b/tests/script/sh/copy_udf.bat @@ -4,7 +4,7 @@ echo Executing copy_udf.bat set SCRIPT_DIR=%cd% echo SCRIPT_DIR: %SCRIPT_DIR% -cd ..\..\.. +echo %cd% | grep community > nul && cd ..\..\.. || cd ..\.. set TAOS_DIR=%cd% echo find udf library in %TAOS_DIR% set UDF1_DIR=%TAOS_DIR%\debug\build\lib\udf1.dll diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat index f0d8c10b7e..4b221dd479 100644 --- a/tests/script/sh/deploy.bat +++ b/tests/script/sh/deploy.bat @@ -13,12 +13,12 @@ rem echo NODE: %NODE% set SCRIPT_DIR=%~dp0..\ rem echo SCRIPT_DIR: %SCRIPT_DIR% -set BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\ +echo %cd% | grep community > nul && set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" || set "BUILD_DIR=%SCRIPT_DIR%..\..\debug\build\bin\" set TSIM=%BUILD_DIR%tsim rem echo BUILD_DIR: %BUILD_DIR% rem echo TSIM: %TSIM% -set SIM_DIR=%SCRIPT_DIR%..\..\..\sim\ +echo %cd% | grep community > nul && set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" || set "SIM_DIR=%SCRIPT_DIR%..\..\sim\" rem echo SIM_DIR: %SIM_DIR% set NODE_DIR=%SIM_DIR%%NODE_NAME%\ diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat index 7a2c58fc66..0f3d0dcf49 100644 --- a/tests/script/sh/exec.bat +++ b/tests/script/sh/exec.bat @@ -13,12 +13,12 @@ rem echo NODE: %EXEC_OPTON% set SCRIPT_DIR=%~dp0..\ rem echo SCRIPT_DIR: %SCRIPT_DIR% -set BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\ +echo %cd% | grep community > nul && set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" || set "BUILD_DIR=%SCRIPT_DIR%..\..\debug\build\bin\" set TAOSD=%BUILD_DIR%taosd rem echo BUILD_DIR: %BUILD_DIR% rem echo TAOSD: %TAOSD% -set SIM_DIR=%SCRIPT_DIR%..\..\..\sim\ +echo %cd% | grep community > nul && set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" || set "SIM_DIR=%SCRIPT_DIR%..\..\sim\" rem echo SIM_DIR: %SIM_DIR% set NODE_DIR=%SIM_DIR%%NODE_NAME%\ diff --git a/tests/script/tsim/sync/3Replica1VgElect.sim b/tests/script/tsim/sync/3Replica1VgElect.sim index e531fa82ad..6649b9c335 100644 --- a/tests/script/tsim/sync/3Replica1VgElect.sim +++ b/tests/script/tsim/sync/3Replica1VgElect.sim @@ -197,22 +197,22 @@ print $switch_loop_cnt if $switch_loop_cnt == 1 then sql show vgroups - $dnodeId = $data[1][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 2 then sql show vgroups - $dnodeId = $data[2][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 3 then sql show vgroups - $dnodeId = $data[3][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 4 then sql show vgroups - $dnodeId = $data[4][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop else diff --git a/tests/script/tsim/sync/3Replica5VgElect.sim b/tests/script/tsim/sync/3Replica5VgElect.sim index 1243cf8124..d96ad1655d 100644 --- a/tests/script/tsim/sync/3Replica5VgElect.sim +++ b/tests/script/tsim/sync/3Replica5VgElect.sim @@ -290,22 +290,22 @@ print $switch_loop_cnt if $switch_loop_cnt == 1 then sql show vgroups - $dnodeId = $data[1][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 2 then sql show vgroups - $dnodeId = $data[2][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 3 then sql show vgroups - $dnodeId = $data[3][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 4 then sql show vgroups - $dnodeId = $data[4][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop else diff --git a/tests/script/tsim/sync/oneReplica5VgElect.sim b/tests/script/tsim/sync/oneReplica5VgElect.sim index 5af48c7491..71c26e17c7 100644 --- a/tests/script/tsim/sync/oneReplica5VgElect.sim +++ b/tests/script/tsim/sync/oneReplica5VgElect.sim @@ -227,22 +227,22 @@ print $switch_loop_cnt if $switch_loop_cnt == 1 then sql show vgroups - $dnodeId = $data[1][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 2 then sql show vgroups - $dnodeId = $data[2][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 3 then sql show vgroups - $dnodeId = $data[3][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop elif $switch_loop_cnt == 4 then sql show vgroups - $dnodeId = $data[4][3] + $dnodeId = $data[0][3] $dnodeId = dnode . $dnodeId goto switch_leader_to_offine_loop else diff --git a/tests/script/tsim/tmq/consume.bat b/tests/script/tsim/tmq/consume.bat new file mode 100644 index 0000000000..7698ebc865 --- /dev/null +++ b/tests/script/tsim/tmq/consume.bat @@ -0,0 +1,67 @@ + +@echo off + +set EXEC_OPTON=start +set DB_NAME=db +set CDB_NAME=db +set /a POLL_DELAY=5 +set /a VALGRIND=0 +set SIGNAL=SIGINT +set /a SHOW_MSG=0 +set /a SHOW_ROW=0 +set /a EXP_USE_SNAPSHOT=0 + +:param +if "%1"=="" ( + goto :end +) +if %1 == -d ( set "DB_NAME=%2" && shift && shift && goto :param ) +if %1 == -g ( set "SHOW_MSG=%2" && shift && shift && goto :param ) +if %1 == -r ( set "SHOW_ROW=%2" && shift && shift && goto :param ) +if %1 == -s ( set "EXEC_OPTON=%2" && shift && shift && goto :param ) +if %1 == -v ( set "VALGRIND=1" && shift && goto :param ) +if %1 == -y ( set "POLL_DELAY=%2" && shift && shift && goto :param ) +if %1 == -x ( set "SIGNAL=%2" && shift && shift && goto :param ) +if %1 == -w ( set "CDB_NAME=%2" && shift && shift && goto :param ) +if %1 == -e ( set "EXP_USE_SNAPSHOT=%2" && shift && shift && goto :param ) +echo unkown argument %1 +goto :eof +:end + +echo EXEC_OPTON %EXEC_OPTON% +echo DB_NAME %DB_NAME% +echo CDB_NAME %CDB_NAME% +echo POLL_DELAY %POLL_DELAY% +echo VALGRIND %VALGRIND% +echo SIGNAL %SIGNAL% +echo SHOW_MSG %SHOW_MSG% +echo SHOW_ROW %SHOW_ROW% +echo EXP_USE_SNAPSHOT %EXP_USE_SNAPSHOT% + +echo %cd% | grep community > nul && cd ..\..\.. || cd ..\.. +set BUILD_DIR=%cd%\debug\build\bin +set SIM_DIR=%cd%\sim +set PRG_DIR=%SIM_DIR%\tsim +set CFG_DIR=%PRG_DIR%\cfg +set LOG_DIR=%PRG_DIR%\log +set PROGRAM=%BUILD_DIR%\tmq_sim.exe + +echo ------------------------------------------------------------------------ +echo BUILD_DIR : %BUILD_DIR% +echo SIM_DIR : %SIM_DIR% +echo CFG_DIR : %CFG_DIR% +echo PRG_DIR : %PRG_DIR% +echo CFG_DIR : %CFG_DIR% +echo LOG_DIR : %LOG_DIR% +echo PROGRAM : %PROGRAM% +echo POLL_DELAY : %POLL_DELAY% +echo DB_NAME : %DB_NAME% +echo ------------------------------------------------------------------------ + +if "%EXEC_OPTON%" == "start" ( + echo mintty -h never %PROGRAM% -c %CFG_DIR% -y %POLL_DELAY% -d %DB_NAME% -g %SHOW_MSG% -r %SHOW_ROW% -w %CDB_NAME% -e %EXP_USE_SNAPSHOT% + mintty -h never %PROGRAM% -c %CFG_DIR% -y %POLL_DELAY% -d %DB_NAME% -g %SHOW_MSG% -r %SHOW_ROW% -w %CDB_NAME% -e %EXP_USE_SNAPSHOT% +) else ( + if "%SIGNAL%" == "SIGKILL" ( ps | grep tmq_sim | awk '{print $2}' | xargs kill -9 ) else ( ps | grep tmq_sim | awk '{print $2}' | xargs kill -SIGINT ) +) +goto :eof diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index 1f089c9d86..79daf01295 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -6,12 +6,12 @@ rem echo Start TDengine Testing Case ... set "SCRIPT_DIR=%~dp0" rem echo SCRIPT_DIR: %SCRIPT_DIR% -set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" +echo %cd% | grep community > nul && set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" || set "BUILD_DIR=%SCRIPT_DIR%..\..\debug\build\bin\" set "TSIM=%BUILD_DIR%tsim" rem echo BUILD_DIR: %BUILD_DIR% rem echo TSIM: %TSIM% -set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" +echo %cd% | grep community > nul && set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" || set "SIM_DIR=%SCRIPT_DIR%..\..\sim\" rem echo SIM_DIR: %SIM_DIR% set "TSIM_DIR=%SIM_DIR%tsim\" From 8a8e42a9233f1ee2e6c1d9f1a9295adb94f55039 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 14:04:58 +0800 Subject: [PATCH 40/81] refactor(sync): set error code in syncIsReady --- source/dnode/mnode/impl/src/mndSync.c | 3 ++- source/libs/sync/src/syncMain.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index e3358b41df..b481f417d9 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -261,7 +261,8 @@ bool mndIsMaster(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; if (!syncIsReady(pMgmt->sync)) { - terrno = TSDB_CODE_SYN_NOT_LEADER; + // get terrno from syncIsReady + // terrno = TSDB_CODE_SYN_NOT_LEADER; return false; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 42ba2b85b1..041afdb337 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -370,6 +370,15 @@ bool syncIsReady(int64_t rid) { ASSERT(rid == pSyncNode->rid); bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && pSyncNode->restoreFinish; taosReleaseRef(tsNodeRefId, pSyncNode->rid); + + // if false, set error code + if (false == b) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + } else { + terrno = TSDB_CODE_APP_NOT_READY; + } + } return b; } From b884ca9db749a7a0b0f3f3bbbdae6685351aaae6 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 24 Jun 2022 14:07:52 +0800 Subject: [PATCH 41/81] refactor(stream): seperate stream scheduling and persistence --- source/dnode/mnode/impl/inc/mndScheduler.h | 4 +- source/dnode/mnode/impl/src/mndScheduler.c | 98 ++++++------- source/dnode/mnode/impl/src/mndSma.c | 4 +- source/dnode/mnode/impl/src/mndStream.c | 156 +++++++-------------- source/dnode/vnode/src/tq/tqRead.c | 4 +- source/libs/executor/src/executor.c | 11 +- source/libs/executor/src/executorimpl.c | 70 ++++++++- 7 files changed, 160 insertions(+), 187 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndScheduler.h b/source/dnode/mnode/impl/inc/mndScheduler.h index 15d2c6cd5e..db81d8843e 100644 --- a/source/dnode/mnode/impl/inc/mndScheduler.h +++ b/source/dnode/mnode/impl/inc/mndScheduler.h @@ -27,12 +27,10 @@ void mndCleanupScheduler(SMnode* pMnode); int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub); -int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); - int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType, int64_t watermark); -int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); +int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 9d8ed3701e..eb0ccbb5f7 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -97,37 +97,7 @@ END: return terrno; } -int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet* pEpSet, tmsg_t type, int32_t nodeId) { - SEncoder encoder; - tEncoderInit(&encoder, NULL, 0); - tEncodeSStreamTask(&encoder, pTask); - int32_t size = encoder.pos; - int32_t tlen = sizeof(SMsgHead) + size; - tEncoderClear(&encoder); - void* buf = taosMemoryCalloc(1, tlen); - if (buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - ((SMsgHead*)buf)->vgId = htonl(nodeId); - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - tEncoderInit(&encoder, abuf, size); - tEncodeSStreamTask(&encoder, pTask); - tEncoderClear(&encoder); - - STransAction action = {0}; - memcpy(&action.epSet, pEpSet, sizeof(SEpSet)); - action.pCont = buf; - action.contLen = tlen; - action.msgType = type; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(buf); - return -1; - } - return 0; -} - -int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) { +int32_t mndAddSinkToTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask) { pTask->dispatchType = TASK_DISPATCH__NONE; // sink if (pStream->smaId != 0) { @@ -142,7 +112,7 @@ int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SS return 0; } -int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) { +int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask) { pTask->sinkType = TASK_SINK__NONE; if (pStream->fixedSinkVgId == 0) { pTask->dispatchType = TASK_DISPATCH__SHUFFLE; @@ -187,7 +157,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj* return 0; } -int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SSubplan* plan, const SVgObj* pVgroup) { +int32_t mndAssignTaskToVg(SMnode* pMnode, SStreamTask* pTask, SSubplan* plan, const SVgObj* pVgroup) { int32_t msgLen; pTask->nodeId = pVgroup->vgId; pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup); @@ -196,11 +166,11 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS plan->execNode.epSet = pTask->epSet; if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) { + ASSERT(0); terrno = TSDB_CODE_QRY_INVALID_INPUT; return -1; } ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE || pTask->sinkType != TASK_SINK__NONE); - mndPersistTaskDeployReq(pTrans, pTask, &plan->execNode.epSet, TDMT_STREAM_TASK_DEPLOY, pVgroup->vgId); return 0; } @@ -212,8 +182,7 @@ SSnodeObj* mndSchedFetchOneSnode(SMnode* pMnode) { return pObj; } -int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SSubplan* plan, - const SSnodeObj* pSnode) { +int32_t mndAssignTaskToSnode(SMnode* pMnode, SStreamTask* pTask, SSubplan* plan, const SSnodeObj* pSnode) { int32_t msgLen; pTask->nodeId = SNODE_HANDLE; @@ -223,10 +192,10 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, plan->execNode.epSet = pTask->epSet; if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) { + ASSERT(0); terrno = TSDB_CODE_QRY_INVALID_INPUT; return -1; } - mndPersistTaskDeployReq(pTrans, pTask, &plan->execNode.epSet, TDMT_STREAM_TASK_DEPLOY, SNODE_HANDLE); return 0; } @@ -245,7 +214,7 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, int64_t dbUid) { return pVgroup; } -int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { +int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; void* pIter = NULL; SArray* tasks = taosArrayGetP(pStream->tasks, 0); @@ -262,6 +231,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb } SStreamTask* pTask = tNewSStreamTask(pStream->uid); if (pTask == NULL) { + sdbRelease(pSdb, pVgroup); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } @@ -290,13 +260,11 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb // dispatch pTask->dispatchType = TASK_DISPATCH__NONE; - - mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_STREAM_TASK_DEPLOY, pVgroup->vgId); } return 0; } -int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { +int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, SStreamObj* pStream) { ASSERT(pStream->fixedSinkVgId != 0); SArray* tasks = taosArrayGetP(pStream->tasks, 0); SStreamTask* pTask = tNewSStreamTask(pStream->uid); @@ -337,13 +305,10 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* // dispatch pTask->dispatchType = TASK_DISPATCH__NONE; - - mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_STREAM_TASK_DEPLOY, pStream->fixedSinkVg.vgId); - return 0; } -int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { +int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); if (pPlan == NULL) { @@ -368,9 +333,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { // add extra sink hasExtraSink = true; if (pStream->fixedSinkVgId == 0) { - mndAddShuffleSinkTasksToStream(pMnode, pTrans, pStream); + if (mndAddShuffleSinkTasksToStream(pMnode, pStream) < 0) { + // TODO free + return -1; + } } else { - mndAddFixedSinkTaskToStream(pMnode, pTrans, pStream); + if (mndAddFixedSinkTaskToStream(pMnode, pStream) < 0) { + // TODO free + return -1; + } } } @@ -386,6 +357,11 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE); pInnerTask = tNewSStreamTask(pStream->uid); + if (pInnerTask == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + qDestroyQueryPlan(pPlan); + return -1; + } mndAddTaskToTaskSet(taskInnerLevel, pInnerTask); pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*)); @@ -397,7 +373,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { pInnerTask->triggerParam = pStream->triggerParam; // dispatch - if (mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pInnerTask) < 0) { + if (mndAddDispatcherToInnerTask(pMnode, pStream, pInnerTask) < 0) { qDestroyQueryPlan(pPlan); return -1; } @@ -409,14 +385,13 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode); if (pSnode == NULL) { SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid); - if (mndAssignTaskToVg(pMnode, pTrans, pInnerTask, plan, pVgroup) < 0) { + if (mndAssignTaskToVg(pMnode, pInnerTask, plan, pVgroup) < 0) { sdbRelease(pSdb, pVgroup); qDestroyQueryPlan(pPlan); return -1; } } else { - if (mndAssignTaskToSnode(pMnode, pTrans, pInnerTask, plan, pSnode) < 0) { - ASSERT(0); + if (mndAssignTaskToSnode(pMnode, pInnerTask, plan, pSnode) < 0) { sdbRelease(pSdb, pSnode); qDestroyQueryPlan(pPlan); return -1; @@ -424,7 +399,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { } } else { SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid); - if (mndAssignTaskToVg(pMnode, pTrans, pInnerTask, plan, pVgroup) < 0) { + if (mndAssignTaskToVg(pMnode, pInnerTask, plan, pVgroup) < 0) { sdbRelease(pSdb, pVgroup); qDestroyQueryPlan(pPlan); return -1; @@ -450,6 +425,12 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { continue; } SStreamTask* pTask = tNewSStreamTask(pStream->uid); + if (pInnerTask == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + return -1; + } mndAddTaskToTaskSet(taskSourceLevel, pTask); // source @@ -466,7 +447,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { // exec pTask->execType = TASK_EXEC__PIPE; - if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) { + if (mndAssignTaskToVg(pMnode, pTask, plan, pVgroup) < 0) { sdbRelease(pSdb, pVgroup); qDestroyQueryPlan(pPlan); return -1; @@ -507,6 +488,11 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { continue; } SStreamTask* pTask = tNewSStreamTask(pStream->uid); + if (pTask == NULL) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + return -1; + } mndAddTaskToTaskSet(taskOneLevel, pTask); // source @@ -517,14 +503,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { // sink or dispatch if (hasExtraSink) { - mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pTask); + mndAddDispatcherToInnerTask(pMnode, pStream, pTask); } else { - mndAddSinkToTask(pMnode, pTrans, pStream, pTask); + mndAddSinkToTask(pMnode, pStream, pTask); } // exec pTask->execType = TASK_EXEC__PIPE; - if (mndAssignTaskToVg(pMnode, pTrans, pTask, plan, pVgroup) < 0) { + if (mndAssignTaskToVg(pMnode, pTask, plan, pVgroup) < 0) { sdbRelease(pSdb, pVgroup); qDestroyQueryPlan(pPlan); return -1; diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index c44fb03be2..05603f8554 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -533,7 +533,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea #if 0 smaObj.timezone = pCreate->timezone; #endif - smaObj.timezone = tsTimezone; // use timezone of server + smaObj.timezone = tsTimezone; // use timezone of server smaObj.interval = pCreate->interval; smaObj.offset = pCreate->offset; smaObj.sliding = pCreate->sliding; @@ -623,7 +623,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; // if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER; - if (mndScheduleStream(pMnode, pTrans, &streamObj) != 0) goto _OVER; + if (mndScheduleStream(pMnode, &streamObj) != 0) goto _OVER; if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 7e9069d5fc..96a82e2c18 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -320,11 +320,58 @@ FAIL: return 0; } +int32_t mndPersistTaskDeployReq(STrans *pTrans, const SStreamTask *pTask) { + SEncoder encoder; + tEncoderInit(&encoder, NULL, 0); + tEncodeSStreamTask(&encoder, pTask); + int32_t size = encoder.pos; + int32_t tlen = sizeof(SMsgHead) + size; + tEncoderClear(&encoder); + void *buf = taosMemoryCalloc(1, tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + ((SMsgHead *)buf)->vgId = htonl(pTask->nodeId); + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + tEncoderInit(&encoder, abuf, size); + tEncodeSStreamTask(&encoder, pTask); + tEncoderClear(&encoder); + + STransAction action = {0}; + memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet)); + action.pCont = buf; + action.contLen = tlen; + action.msgType = TDMT_STREAM_TASK_DEPLOY; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(buf); + return -1; + } + return 0; +} + +int32_t mndPersistStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) { + int32_t level = taosArrayGetSize(pStream->tasks); + for (int32_t i = 0; i < level; i++) { + SArray *pLevel = taosArrayGetP(pStream->tasks, i); + int32_t sz = taosArrayGetSize(pLevel); + for (int32_t j = 0; j < sz; j++) { + SStreamTask *pTask = taosArrayGetP(pLevel, j); + if (mndPersistTaskDeployReq(pTrans, pTask) < 0) { + return -1; + } + } + } + return 0; +} + int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) { + if (mndPersistStreamTasks(pMnode, pTrans, pStream) < 0) { + return -1; + } SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream); if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); - mndTransDrop(pTrans); return -1; } sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); @@ -342,51 +389,6 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr return 0; } -int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) { - SNode *pAst = NULL; - - if (nodesStringToNode(ast, &pAst) < 0) { - return -1; - } - - if (qExtractResultSchema(pAst, (int32_t *)&pStream->outputSchema.nCols, &pStream->outputSchema.pSchema) != 0) { - nodesDestroyNode(pAst); - return -1; - } - // free - nodesDestroyNode(pAst); - -#if 0 - printf("|"); - for (int i = 0; i < pStream->outputSchema.nCols; i++) { - printf(" %15s |", (char *)pStream->outputSchema.pSchema[i].name); - } - printf("\n=======================================================\n"); - -#endif - - if (TSDB_CODE_SUCCESS != mndStreamGetPlanString(ast, pStream->trigger, pStream->watermark, &pStream->physicalPlan)) { - mError("topic:%s, failed to get plan since %s", pStream->name, terrstr()); - return -1; - } - - if (mndScheduleStream(pMnode, pTrans, pStream) < 0) { - mError("stream:%ld, schedule stream since %s", pStream->uid, terrstr()); - return -1; - } - mDebug("trans:%d, used to create stream:%s", pTrans->id, pStream->name); - - SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream); - if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { - mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); - mndTransDrop(pTrans); - return -1; - } - sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); - - return 0; -} - static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) { SStbObj *pStb = NULL; SDbObj *pDb = NULL; @@ -503,64 +505,6 @@ static int32_t mndDropStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pS return 0; } -static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq *pCreate, SDbObj *pDb) { - mDebug("stream:%s to create", pCreate->name); - SStreamObj streamObj = {0}; - tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN); - tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN); - tstrncpy(streamObj.targetSTbName, pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN); - streamObj.createTime = taosGetTimestampMs(); - streamObj.updateTime = streamObj.createTime; - streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name)); - streamObj.targetStbUid = mndGenerateUid(pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN); - streamObj.sourceDbUid = pDb->uid; - streamObj.version = 1; - streamObj.sql = pCreate->sql; - // TODO - streamObj.fixedSinkVgId = 0; - streamObj.smaId = 0; - streamObj.trigger = pCreate->triggerType; - streamObj.watermark = pCreate->watermark; - streamObj.triggerParam = pCreate->maxDelay; - - if (streamObj.targetSTbName[0]) { - pDb = mndAcquireDbByStb(pMnode, streamObj.targetSTbName); - if (pDb == NULL) { - terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - return -1; - } - tstrncpy(streamObj.targetDb, pDb->name, TSDB_DB_FNAME_LEN); - } - - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); - if (pTrans == NULL) { - mError("stream:%s, failed to create since %s", pCreate->name, terrstr()); - return -1; - } - mDebug("trans:%d, used to create stream:%s", pTrans->id, pCreate->name); - - if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pTrans) != 0) { - mError("trans:%d, failed to add stream since %s", pTrans->id, terrstr()); - mndTransDrop(pTrans); - return -1; - } - - if (streamObj.targetSTbName[0] && mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) { - mError("trans:%d, failed to create stb for stream since %s", pTrans->id, terrstr()); - mndTransDrop(pTrans); - return -1; - } - - if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); - mndTransDrop(pTrans); - return -1; - } - - mndTransDrop(pTrans); - return 0; -} - static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; @@ -631,7 +575,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { } // schedule stream task for stream obj - if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { + if (mndScheduleStream(pMnode, &streamObj) < 0) { mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr()); mndTransDrop(pTrans); goto _OVER; @@ -653,8 +597,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { mndTransDrop(pTrans); - /*code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);*/ - /*if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;*/ code = TSDB_CODE_ACTION_IN_PROGRESS; _OVER: diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 5d2fb81cf0..0243f2a9f0 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -146,8 +146,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_ int32_t* pNumOfRows) { *pUid = 0; - // TODO set to real sversion - /*int32_t sversion = 1;*/ + // TODO: cache multiple schema int32_t sversion = htonl(pHandle->pBlock->sversion); if (pHandle->cachedSchemaSuid == 0 || pHandle->cachedSchemaVer != sversion || pHandle->cachedSchemaSuid != pHandle->msgIter.suid) { @@ -161,7 +160,6 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_ return -1; } - // this interface use suid instead of uid if (pHandle->pSchemaWrapper) tDeleteSSchemaWrapper(pHandle->pSchemaWrapper); pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion, true); if (pHandle->pSchemaWrapper == NULL) { diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 1bd1ce14b1..ad400d720a 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -40,15 +40,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu SStreamBlockScanInfo* pInfo = pOperator->info; pInfo->assignBlockUid = assignUid; - // no need to check -#if 0 - if (pInfo->blockType == 0) { - pInfo->blockType = type; - } else if (pInfo->blockType != type) { - ASSERT(0); - return TSDB_CODE_QRY_APP_ERROR; - } -#endif + // TODO: if a block was set but not consumed, + // prevent setting a different type of block pInfo->blockType = type; if (type == STREAM_DATA_TYPE_SUBMIT_BLOCK) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index afe0a1f8fa..2db10973a5 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1321,7 +1321,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { // todo move to the initialization function int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0); - size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); SFilterColumnParam param1 = {.numOfCols = numOfCols, .pDataBlock = pBlock->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m1); @@ -2048,7 +2048,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLo SArray* pColList) { if (pColList == NULL) { // data from other sources blockDataCleanup(pRes); -// blockDataEnsureCapacity(pRes, numOfRows); + // blockDataEnsureCapacity(pRes, numOfRows); blockCompressDecode(pRes, numOfOutput, numOfRows, pData); } else { // extract data according to pColList ASSERT(numOfOutput == taosArrayGetSize(pColList)); @@ -2402,14 +2402,14 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode tsem_init(&pInfo->ready, 0, 0); - pInfo->seqLoadData = false; + pInfo->seqLoadData = false; pInfo->pTransporter = pTransporter; - pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc); - pOperator->name = "ExchangeOperator"; + pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc); + pOperator->name = "ExchangeOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE; pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pResult->pDataBlock); pOperator->pTaskInfo = pTaskInfo; @@ -4361,6 +4361,62 @@ _error: return NULL; } +int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { + if (pNode->pChildren == NULL || LIST_LENGTH(pNode->pChildren) == 0) { + if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == pNode->type) { + *ppNode = (STableScanPhysiNode*)pNode; + return 0; + } else { + ASSERT(0); + terrno = TSDB_CODE_QRY_APP_ERROR; + return -1; + } + } else { + if (LIST_LENGTH(pNode->pChildren) != 1) { + ASSERT(0); + terrno = TSDB_CODE_QRY_APP_ERROR; + return -1; + } + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pNode->pChildren, 0); + return extractTableScanNode(pChildNode, ppNode); + } + return -1; +} + +int32_t doRebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle) { + if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + if (pOperator->numOfDownstream == 0) { + qError("failed to find stream scan operator"); + return TSDB_CODE_QRY_APP_ERROR; + } + + if (pOperator->numOfDownstream > 1) { + qError("join not supported for stream block scan"); + return TSDB_CODE_QRY_APP_ERROR; + } + return doRebuildReader(pOperator->pDownstream[0], plan, pHandle); + } else { + SStreamBlockScanInfo* pInfo = pOperator->info; + ASSERT(pInfo->pSnapshotReadOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); + STableScanInfo* pTableScanInfo = pInfo->pSnapshotReadOp->info; + + tsdbCleanupReadHandle(pTableScanInfo->dataReader); + STableScanPhysiNode* pNode = NULL; + if (extractTableScanNode(plan->pNode, &pNode) < 0) { + ASSERT(0); + } + + STableListInfo info = {0}; + pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, 0, 0); + if (pTableScanInfo->dataReader == NULL) { + ASSERT(0); + qError("failed to create data reader"); + return TSDB_CODE_QRY_APP_ERROR; + } + } + return 0; +} + int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { int32_t code = TDB_CODE_SUCCESS; char* pCurrent = NULL; From 8cbb7bc7164a13d53537eb036270eccc27fcca01 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 24 Jun 2022 14:20:43 +0800 Subject: [PATCH 42/81] feat: refactor rpc quit --- source/libs/transport/src/transCli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index beaef2758e..e563bf0ddd 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1013,8 +1013,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT); } if (pThrd->quit == false) { - if (pConn->status != ConnInPool && pResp->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) { - addConnToPool(pThrd->pool, pConn); + if (pResp->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (pConn->status != ConnInPool) addConnToPool(pThrd->pool, pConn); } else { transUnrefCliHandle(pConn); } From 87defc2790ec69b3e10917c67302a12225b17e22 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 14:26:31 +0800 Subject: [PATCH 43/81] refactor(sync): add interface: get retry epset --- include/libs/sync/sync.h | 1 + source/dnode/vnode/src/vnd/vnodeSync.c | 4 ++++ source/libs/sync/src/syncMain.c | 24 +++++++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 2bf49fa006..52d9b6f810 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -200,6 +200,7 @@ const char* syncGetMyRoleStr(int64_t rid); SyncTerm syncGetMyTerm(int64_t rid); SyncGroupId syncGetVgId(int64_t rid); void syncGetEpSet(int64_t rid, SEpSet* pEpSet); +void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); bool syncEnvIsStart(); const char* syncStr(ESyncState state); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 32090b774e..4c56180979 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -144,11 +144,15 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { vnodeAccumBlockMsg(pVnode, pMsg->msgType); } else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) { SEpSet newEpSet = {0}; + syncGetRetryEpSet(pVnode->sync, &newEpSet); + + /* syncGetEpSet(pVnode->sync, &newEpSet); SEp *pEp = &newEpSet.eps[newEpSet.inUse]; if (pEp->port == tsServerPort && strcmp(pEp->fqdn, tsLocalFqdn) == 0) { newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps; } + */ vGTrace("vgId:%d, msg:%p is redirect since not leader, numOfEps:%d inUse:%d", vgId, pMsg, newEpSet.numOfEps, newEpSet.inUse); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 041afdb337..c5af72c971 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -489,12 +489,30 @@ void syncGetEpSet(int64_t rid, SEpSet* pEpSet) { snprintf(pEpSet->eps[i].fqdn, sizeof(pEpSet->eps[i].fqdn), "%s", (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodeFqdn); pEpSet->eps[i].port = (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodePort; (pEpSet->numOfEps)++; - - sInfo("syncGetEpSet index:%d %s:%d", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); + sInfo("vgId:%d sync get epset: index:%d %s:%d", pSyncNode->vgId, i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); } pEpSet->inUse = pSyncNode->pRaftCfg->cfg.myIndex; + sInfo("vgId:%d sync get epset in-use:%d", pSyncNode->vgId, pEpSet->inUse); - sInfo("syncGetEpSet pEpSet->inUse:%d ", pEpSet->inUse); + taosReleaseRef(tsNodeRefId, pSyncNode->rid); +} + +void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + memset(pEpSet, 0, sizeof(*pEpSet)); + return; + } + ASSERT(rid == pSyncNode->rid); + pEpSet->numOfEps = 0; + for (int i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { + snprintf(pEpSet->eps[i].fqdn, sizeof(pEpSet->eps[i].fqdn), "%s", (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodeFqdn); + pEpSet->eps[i].port = (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodePort; + (pEpSet->numOfEps)++; + sInfo("vgId:%d sync get retry epset: index:%d %s:%d", pSyncNode->vgId, i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); + } + pEpSet->inUse = (pSyncNode->pRaftCfg->cfg.myIndex + 1) % pEpSet->numOfEps; + sInfo("vgId:%d sync get retry epset in-use:%d", pSyncNode->vgId, pEpSet->inUse); taosReleaseRef(tsNodeRefId, pSyncNode->rid); } From 4c846895ff60bd37b5ed4a10d17b0588b831ba81 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 24 Jun 2022 14:36:41 +0800 Subject: [PATCH 44/81] test: add test time count print --- source/dnode/mnode/impl/test/db/CMakeLists.txt | 10 ++++------ source/dnode/mnode/impl/test/func/CMakeLists.txt | 10 ++++------ .../dnode/mnode/impl/test/profile/CMakeLists.txt | 10 ++++------ source/dnode/mnode/impl/test/show/CMakeLists.txt | 10 ++++------ source/dnode/mnode/impl/test/sma/CMakeLists.txt | 10 ++++------ source/dnode/mnode/impl/test/stb/CMakeLists.txt | 10 ++++------ source/dnode/mnode/impl/test/user/CMakeLists.txt | 10 ++++------ source/libs/parser/src/parInsertData.c | 15 +++++++++++++-- source/libs/planner/test/CMakeLists.txt | 10 ++++------ 9 files changed, 45 insertions(+), 50 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index e28cdd4f61..3f6a80835f 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -if(NOT TD_WINDOWS) - add_test( - NAME dbTest - COMMAND dbTest - ) -endif(NOT TD_WINDOWS) +add_test( + NAME dbTest + COMMAND dbTest +) diff --git a/source/dnode/mnode/impl/test/func/CMakeLists.txt b/source/dnode/mnode/impl/test/func/CMakeLists.txt index 17adfde801..3b6f2b5782 100644 --- a/source/dnode/mnode/impl/test/func/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/func/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -# if(NOT TD_WINDOWS) - add_test( - NAME funcTest - COMMAND funcTest - ) -# endif(NOT TD_WINDOWS) +add_test( + NAME funcTest + COMMAND funcTest +) \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/profile/CMakeLists.txt b/source/dnode/mnode/impl/test/profile/CMakeLists.txt index 049a4f3a9f..8b811ebfed 100644 --- a/source/dnode/mnode/impl/test/profile/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/profile/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -# if(NOT TD_WINDOWS) - add_test( - NAME profileTest - COMMAND profileTest - ) -# endif(NOT TD_WINDOWS) +add_test( + NAME profileTest + COMMAND profileTest +) diff --git a/source/dnode/mnode/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt index 33ba0c5697..69e93e7086 100644 --- a/source/dnode/mnode/impl/test/show/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/show/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -# if(NOT TD_WINDOWS) - add_test( - NAME showTest - COMMAND showTest - ) -# endif(NOT TD_WINDOWS) +add_test( + NAME showTest + COMMAND showTest +) diff --git a/source/dnode/mnode/impl/test/sma/CMakeLists.txt b/source/dnode/mnode/impl/test/sma/CMakeLists.txt index fd596c5021..3f9ec123a8 100644 --- a/source/dnode/mnode/impl/test/sma/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/sma/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -if(NOT TD_WINDOWS) - add_test( - NAME smaTest - COMMAND smaTest - ) -endif(NOT TD_WINDOWS) +add_test( + NAME smaTest + COMMAND smaTest +) diff --git a/source/dnode/mnode/impl/test/stb/CMakeLists.txt b/source/dnode/mnode/impl/test/stb/CMakeLists.txt index 857c404c1c..dcfbe658fc 100644 --- a/source/dnode/mnode/impl/test/stb/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/stb/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -if(NOT TD_WINDOWS) - add_test( - NAME stbTest - COMMAND stbTest - ) -endif(NOT TD_WINDOWS) \ No newline at end of file +add_test( + NAME stbTest + COMMAND stbTest +) \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/user/CMakeLists.txt b/source/dnode/mnode/impl/test/user/CMakeLists.txt index ed4d964617..b39ea0e73f 100644 --- a/source/dnode/mnode/impl/test/user/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/user/CMakeLists.txt @@ -5,9 +5,7 @@ target_link_libraries( PUBLIC sut ) -if(NOT TD_WINDOWS) - add_test( - NAME userTest - COMMAND userTest - ) -endif(NOT TD_WINDOWS) +add_test( + NAME userTest + COMMAND userTest +) diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index 2b505d4bf7..56301c072c 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -26,6 +26,7 @@ typedef struct SBlockKeyTuple { TSKEY skey; void* payloadAddr; + int16_t index; } SBlockKeyTuple; typedef struct SBlockKeyInfo { @@ -36,7 +37,6 @@ typedef struct SBlockKeyInfo { static int32_t rowDataCompar(const void* lhs, const void* rhs) { TSKEY left = *(TSKEY*)lhs; TSKEY right = *(TSKEY*)rhs; - if (left == right) { return 0; } else { @@ -44,6 +44,16 @@ static int32_t rowDataCompar(const void* lhs, const void* rhs) { } } +static int32_t rowDataComparStable(const void* lhs, const void* rhs) { + TSKEY left = *(TSKEY*)lhs; + TSKEY right = *(TSKEY*)rhs; + if (left == right) { + return ((SBlockKeyTuple*)lhs)->index - ((SBlockKeyTuple*)rhs)->index; + } else { + return left > right ? 1 : -1; + } +} + void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) { pColList->numOfCols = numOfCols; pColList->numOfBound = numOfCols; @@ -343,6 +353,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey while (n < nRows) { pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData); pBlkKeyTuple->payloadAddr = pBlockData; + pBlkKeyTuple->index = n; // next loop pBlockData += extendedRowSize; @@ -354,7 +365,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; // todo. qsort is unstable, if timestamp is same, should get the last one - qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataCompar); + qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable); pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; int32_t i = 0; diff --git a/source/libs/planner/test/CMakeLists.txt b/source/libs/planner/test/CMakeLists.txt index b34ffa7bb1..a21b36fef6 100644 --- a/source/libs/planner/test/CMakeLists.txt +++ b/source/libs/planner/test/CMakeLists.txt @@ -32,9 +32,7 @@ if(${BUILD_WINGETOPT}) target_link_libraries(plannerTest PUBLIC wingetopt) endif() -# if(NOT TD_WINDOWS) - add_test( - NAME plannerTest - COMMAND plannerTest - ) -# endif(NOT TD_WINDOWS) +add_test( + NAME plannerTest + COMMAND plannerTest +) From fee5e134f4ed661c041e18bdda9fad9c420661a4 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 24 Jun 2022 14:41:09 +0800 Subject: [PATCH 45/81] test: add test time count print --- tests/system-test/0-others/taosShell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system-test/0-others/taosShell.py b/tests/system-test/0-others/taosShell.py index 046db93c49..e03b34adca 100644 --- a/tests/system-test/0-others/taosShell.py +++ b/tests/system-test/0-others/taosShell.py @@ -44,13 +44,13 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key tdLog.info ("taos cmd: %s" % taosCmd) - child = taosExpect.spawn(taosCmd, timeout=3) + child = taosExpect.spawn(taosCmd, timeout=10) #output = child.readline() #print (output.decode()) if len(expectString) != 0: - i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) + i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) else: - i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) + i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) if platform.system().lower() == 'windows': retResult = child.before From 33c85e06c8c2a5c3e618ef44a2a25dfc4869bc11 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Fri, 24 Jun 2022 15:17:17 +0800 Subject: [PATCH 46/81] ci: optimize Jenkins log --- Jenkinsfile2 | 103 +++++++++++++++++++++++------------ tests/parallel_test/run.sh | 109 ++++++++++++++++++++++++++++--------- 2 files changed, 149 insertions(+), 63 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 94af11868a..38af8fd286 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -43,10 +43,8 @@ def pre_test(){ sh ''' cd ${WK} git reset --hard - git fetch || git fetch cd ${WKC} git reset --hard - git fetch || git fetch ''' script { if (env.CHANGE_TARGET == 'master') { @@ -82,6 +80,7 @@ def pre_test(){ if (env.CHANGE_URL =~ /\/TDengine\//) { sh ''' cd ${WKC} + git remote prune origin git pull >/dev/null git log -5 echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log @@ -107,6 +106,7 @@ def pre_test(){ git log -5 echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log cd ${WKC} + git remote prune origin git pull >/dev/null git log -5 echo "community log: `git log -5`" >>${WKDIR}/jenkins.log @@ -137,53 +137,51 @@ def pre_test_win(){ set date /t time /t - rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug || exit 0 + rd /s /Q %WIN_INTERNAL_ROOT%\\debug || exit 0 ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git reset --hard - git fetch || git fetch ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git reset --hard - git fetch || git fetch ''' script { if (env.CHANGE_TARGET == 'master') { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git checkout master ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git checkout master ''' } else if(env.CHANGE_TARGET == '2.0') { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git checkout 2.0 ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git checkout 2.0 ''' } else if(env.CHANGE_TARGET == '3.0') { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git checkout 3.0 ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git checkout 3.0 ''' } else { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git checkout develop ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git checkout develop ''' } @@ -191,36 +189,38 @@ def pre_test_win(){ script { if (env.CHANGE_URL =~ /\/TDengine\//) { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git pull ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% + git remote prune origin git pull ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git fetch origin +refs/pull/%CHANGE_ID%/merge ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git checkout -qf FETCH_HEAD ''' } else if (env.CHANGE_URL =~ /\/TDinternal\//) { bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git pull ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git fetch origin +refs/pull/%CHANGE_ID%/merge ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git checkout -qf FETCH_HEAD ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% + git remote prune origin git pull ''' } else { @@ -230,27 +230,27 @@ def pre_test_win(){ } } bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% git branch git log -5 ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git branch git log -5 ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community + cd %WIN_COMMUNITY_ROOT% git submodule update --init --recursive ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python + cd %WIN_CONNECTOR_ROOT% git branch git reset --hard git pull ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python + cd %WIN_CONNECTOR_ROOT% git log -5 ''' } @@ -258,7 +258,7 @@ def pre_test_build_win() { bat ''' echo "building ..." time /t - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal + cd %WIN_INTERNAL_ROOT% mkdir debug cd debug time /t @@ -273,9 +273,9 @@ def pre_test_build_win() { time /t ''' bat ''' - cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python + cd %WIN_CONNECTOR_ROOT% python -m pip install . - xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 + xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ''' return 1 } @@ -283,7 +283,7 @@ def run_win_ctest() { bat ''' echo "windows ctest ..." time /t - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug + cd %WIN_INTERNAL_ROOT%\\debug ctest -j 1 || exit 7 time /t ''' @@ -292,12 +292,12 @@ def run_win_test() { echo "LINUX NODE: ${linux_node_ip} - ${linux_node_pass}" bat ''' echo "windows test ..." - cd C:\\workspace\\%EXECUTOR_NUMBER%\\taos-connector-python + cd %WIN_CONNECTOR_ROOT% python -m pip install . - xcopy /e/y/i/f C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 + xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ls -l C:\\Windows\\System32\\taos.dll time /t - cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community\\tests\\system-test + cd %WIN_SYSTEM_TEST_ROOT% echo "node: ''' + linux_node_ip + ''':''' + linux_node_pass + '''" echo "testing ..." test-all.bat "{\\\"host\\\":\\\"''' + linux_node_ip + '''\\\",\\\"port\\\":22,\\\"user\\\":\\\"root\\\",\\\"password\\\":\\\"''' + linux_node_pass + '''\\\",\\\"path\\\":\\\"/var/lib/jenkins/workspace/TDinternal\\\"}" @@ -319,6 +319,12 @@ pipeline { parallel { stage('windows test') { agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "} + environment{ + WIN_INTERNAL_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal" + WIN_COMMUNITY_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community" + WIN_SYSTEM_TEST_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community\\tests\\system-test" + WIN_CONNECTOR_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\taos-connector-python" + } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { timeout(time: 55, unit: 'MINUTES'){ @@ -368,11 +374,36 @@ pipeline { rm -f /tmp/cases.task ./collect_cases.sh -e ''' + def extra_param = "" + def log_server_file = "/home/log_server.json" + def timeout_cmd = "" + if (fileExists(log_server_file)) { + def log_server_enabled = sh ( + script: 'jq .enabled ' + log_server_file, + returnStdout: true + ).trim() + def timeout_param = sh ( + script: 'jq .timeout ' + log_server_file, + returnStdout: true + ).trim() + if (timeout_param != "null" && timeout_param != "0") { + timeout_cmd = "timeout " + timeout_param + } + if (log_server_enabled == "1") { + def log_server = sh ( + script: 'jq .server ' + log_server_file + ' | sed "s/\\\"//g"', + returnStdout: true + ).trim() + if (log_server != "null" && log_server != "") { + extra_param = "-w " + log_server + } + } + } sh ''' cd ${WKC}/tests/parallel_test export DEFAULT_RETRY_TIME=2 date - timeout 2100 time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 + ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + ''' ''' } } diff --git a/tests/parallel_test/run.sh b/tests/parallel_test/run.sh index e9871637bd..700d6853d2 100755 --- a/tests/parallel_test/run.sh +++ b/tests/parallel_test/run.sh @@ -8,11 +8,12 @@ function usage() { echo -e "\t -l log dir" echo -e "\t -e enterprise edition" echo -e "\t -o default timeout value" + echo -e "\t -w log web server" echo -e "\t -h help" } ent=0 -while getopts "m:t:b:l:o:eh" opt; do +while getopts "m:t:b:l:o:w:eh" opt; do case $opt in m) config_file=$OPTARG @@ -32,6 +33,9 @@ while getopts "m:t:b:l:o:eh" opt; do o) timeout_param="-o $OPTARG" ;; + w) + web_server=$OPTARG + ;; h) usage exit 0 @@ -64,10 +68,11 @@ if [ ! -f $t_file ]; then exit 1 fi date_tag=`date +%Y%m%d-%H%M%S` +test_log_dir=${branch}_${date_tag} if [ -z $log_dir ]; then - log_dir="log/${branch}_${date_tag}" + log_dir="log/${test_log_dir}" else - log_dir="$log_dir/${branch}_${date_tag}" + log_dir="$log_dir/${test_log_dir}" fi hosts=() @@ -190,44 +195,54 @@ function run_thread() { # echo "$thread_no $count $cmd" local ret=0 local redo_count=1 + local case_log_file=$log_dir/${case_file}.txt start_time=`date +%s` + local case_index=`flock -x $lock_file -c "sh -c \"echo \\\$(( \\\$( cat $index_file ) + 1 )) | tee $index_file\""` + case_index=`printf "%5d" $case_index` + local case_info=`echo "$line"|cut -d, -f 3,4` while [ ${redo_count} -lt 6 ]; do - if [ -f $log_dir/$case_file.log ]; then - cp $log_dir/$case_file.log $log_dir/$case_file.${redo_count}.redolog + if [ -f $case_log_file ]; then + cp $case_log_file $log_dir/$case_file.${redo_count}.redotxt fi - echo "${hosts[index]}-${thread_no} order:${count}, redo:${redo_count} task:${line}" >$log_dir/$case_file.log - echo -e "\e[33m >>>>> \e[0m ${case_cmd}" - date >>$log_dir/$case_file.log - # $cmd 2>&1 | tee -a $log_dir/$case_file.log + echo "${hosts[index]}-${thread_no} order:${count}, redo:${redo_count} task:${line}" >$case_log_file + local current_time=`date "+%Y-%m-%d %H:%M:%S"` + echo -e "$case_index \e[33m START >>>>> \e[0m ${case_info} \e[33m[$current_time]\e[0m" + echo "$current_time" >>$case_log_file + local real_start_time=`date +%s` + # $cmd 2>&1 | tee -a $case_log_file # ret=${PIPESTATUS[0]} - $cmd >>$log_dir/$case_file.log 2>&1 + $cmd >>$case_log_file 2>&1 ret=$? - echo "${hosts[index]} `date` ret:${ret}" >>$log_dir/$case_file.log + local real_end_time=`date +%s` + local time_elapsed=$(( real_end_time - real_start_time )) + echo "execute time: ${time_elapsed}s" >>$case_log_file + current_time=`date "+%Y-%m-%d %H:%M:%S"` + echo "${hosts[index]} $current_time exit code:${ret}" >>$case_log_file if [ $ret -eq 0 ]; then break fi redo=0 - grep -q "wait too long for taosd start" $log_dir/$case_file.log + grep -q "wait too long for taosd start" $case_log_file if [ $? -eq 0 ]; then redo=1 fi - grep -q "kex_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log + grep -q "kex_exchange_identification: Connection closed by remote host" $case_log_file if [ $? -eq 0 ]; then redo=1 fi - grep -q "ssh_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log + grep -q "ssh_exchange_identification: Connection closed by remote host" $case_log_file if [ $? -eq 0 ]; then redo=1 fi - grep -q "kex_exchange_identification: read: Connection reset by peer" $log_dir/$case_file.log + grep -q "kex_exchange_identification: read: Connection reset by peer" $case_log_file if [ $? -eq 0 ]; then redo=1 fi - grep -q "Database not ready" $log_dir/$case_file.log + grep -q "Database not ready" $case_log_file if [ $? -eq 0 ]; then redo=1 fi - grep -q "Unable to establish connection" $log_dir/$case_file.log + grep -q "Unable to establish connection" $case_log_file if [ $? -eq 0 ]; then redo=1 fi @@ -240,11 +255,18 @@ function run_thread() { redo_count=$(( redo_count + 1 )) done end_time=`date +%s` - echo >>$log_dir/$case_file.log - echo "${hosts[index]} execute time: $(( end_time - start_time ))s" >>$log_dir/$case_file.log + echo >>$case_log_file + total_time=$(( end_time - start_time )) + echo "${hosts[index]} total time: ${total_time}s" >>$case_log_file # echo "$thread_no ${line} DONE" - if [ $ret -ne 0 ]; then - flock -x $lock_file -c "echo \"${hosts[index]} ret:${ret} ${line}\" >>$log_dir/failed.log" + if [ $ret -eq 0 ]; then + echo -e "$case_index \e[34m DONE <<<<< \e[0m ${case_info} \e[34m[${total_time}s]\e[0m \e[32m success\e[0m" + else + if [ ! -z ${web_server} ]; then + flock -x $lock_file -c "echo -e \"${hosts[index]} ret:${ret} ${line}\n ${web_server}/$test_log_dir/${case_file}.txt\" >>${failed_case_file}" + else + flock -x $lock_file -c "echo -e \"${hosts[index]} ret:${ret} ${line}\n log file: ${case_log_file}\" >>${failed_case_file}" + fi mkdir -p $log_dir/${case_file}.coredump local remote_coredump_dir="${workdirs[index]}/tmp/thread_volume/$thread_no/coredump" local scpcmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}" @@ -253,13 +275,12 @@ function run_thread() { fi cmd="$scpcmd:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/" $cmd # 2>/dev/null - local case_info=`echo "$line"|cut -d, -f 3,4` local corefile=`ls $log_dir/${case_file}.coredump/` - echo -e "$case_info \e[31m failed\e[0m" + echo -e "$case_index \e[34m DONE <<<<< \e[0m ${case_info} \e[34m[${total_time}s]\e[0m \e[31m failed\e[0m" echo "=========================log============================" - cat $log_dir/$case_file.log + cat $case_log_file echo "=====================================================" - echo -e "\e[34m log file: $log_dir/$case_file.log \e[0m" + echo -e "\e[34m log file: $case_log_file \e[0m" if [ ! -z "$corefile" ]; then echo -e "\e[34m corefiles: $corefile \e[0m" local build_dir=$log_dir/build_${hosts[index]} @@ -325,6 +346,10 @@ mkdir -p $log_dir rm -rf $log_dir/* task_file=$log_dir/$$.task lock_file=$log_dir/$$.lock +index_file=$log_dir/case_index.txt +stat_file=$log_dir/stat.txt +failed_case_file=$log_dir/failed.txt +echo "0" >$index_file i=0 j=0 @@ -350,15 +375,45 @@ rm -f $lock_file rm -f $task_file # docker ps -a|grep -v CONTAINER|awk '{print $1}'|xargs docker rm -f +echo "=====================================================================" +echo "log dir: $log_dir" +total_cases=`cat $index_file` +failed_cases=0 +if [ -f $failed_case_file ]; then + if [ ! -z "$web_server" ]; then + failed_cases=`grep -v "$web_server" $failed_case_file|wc -l` + else + failed_cases=`grep -v "log file:" $failed_case_file|wc -l` + fi +fi +success_cases=$(( total_cases - failed_cases )) +echo "Total Cases: $total_cases" >$stat_file +echo "Successful: $success_cases" >>$stat_file +echo "Failed: $failed_cases" >>$stat_file +cat $stat_file + RET=0 i=1 -if [ -f "$log_dir/failed.log" ]; then +if [ -f "${failed_case_file}" ]; then echo "=====================================================" while read line; do + if [ ! -z "${web_server}" ]; then + echo "$line"|grep -q "${web_server}" + if [ $? -eq 0 ]; then + echo " $line" + continue + fi + else + echo "$line"|grep -q "log file:" + if [ $? -eq 0 ]; then + echo " $line" + continue + fi + fi line=`echo "$line"|cut -d, -f 3,4` echo -e "$i. $line \e[31m failed\e[0m" >&2 i=$(( i + 1 )) - done <$log_dir/failed.log + done <${failed_case_file} RET=1 fi From 94a2b6d945f89a53c41da81c4cc569250ec8c2c8 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 24 Jun 2022 15:18:40 +0800 Subject: [PATCH 47/81] enh: refactor show variables --- include/common/tmsg.h | 32 +++++- include/common/tmsgdef.h | 1 + include/libs/catalog/catalog.h | 30 ++--- include/libs/nodes/cmdnodes.h | 1 - include/libs/parser/parser.h | 2 + source/client/inc/clientInt.h | 10 +- source/client/src/clientHb.c | 3 + source/client/src/clientImpl.c | 4 +- source/client/src/clientMain.c | 6 +- source/client/src/clientMsgHandler.c | 102 ++++++++++++++++- source/common/src/tmsg.c | 117 +++++++++++++++++++- source/dnode/mgmt/mgmt_mnode/src/mmHandle.c | 2 + source/dnode/mnode/impl/src/mndDnode.c | 56 ++++++++++ source/dnode/mnode/impl/src/mndProfile.c | 52 ++++++++- source/libs/catalog/inc/catalogInt.h | 5 +- source/libs/catalog/src/catalog.c | 20 +++- source/libs/catalog/src/ctgAsync.c | 71 +++++++++++- source/libs/catalog/src/ctgDbg.c | 2 +- source/libs/catalog/src/ctgRemote.c | 49 ++++++++ source/libs/catalog/src/ctgUtil.c | 109 +++++------------- source/libs/parser/src/parTranslater.c | 14 ++- source/libs/qcom/src/querymsg.c | 39 +++++++ 22 files changed, 608 insertions(+), 119 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d289ff13ae..a4bc1aebae 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -510,7 +510,8 @@ typedef struct { int8_t superUser; int8_t connType; SEpSet epSet; - char sVersion[128]; + char sVer[TSDB_VERSION_LEN]; + char sDetailVer[128]; } SConnectRsp; int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp); @@ -836,6 +837,20 @@ typedef struct { int32_t tSerializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq); int32_t tDeserializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq); +typedef struct { + int32_t useless; // useless +} SServerVerReq; + +int32_t tSerializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq); +int32_t tDeserializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq); + +typedef struct { + char ver[TSDB_VERSION_LEN]; +} SServerVerRsp; + +int32_t tSerializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp); +int32_t tDeserializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp); + typedef struct SQueryNodeAddr { int32_t nodeId; // vgId or qnodeId @@ -1229,6 +1244,21 @@ typedef struct { int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq); int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq); +typedef struct { + char name[TSDB_CONFIG_OPTION_LEN + 1]; + char value[TSDB_CONFIG_VALUE_LEN + 1]; +} SVariablesInfo; + +typedef struct { + SArray *variables; //SArray +} SShowVariablesRsp; + +int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq); +int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq); + +void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp); + + /* * sql: show tables like '%a_%' * payload is the query condition, e.g., '%a_%' diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 1babb45003..acf08bd47e 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -163,6 +163,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_REDISTRIBUTE_VGROUP, "redistribute-vgroup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_SPLIT_VGROUP, "split-vgroup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_SERVER_VERSION, "server-version", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_MSG) TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp) diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 20f4765190..8482ae3f3d 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -71,6 +71,7 @@ typedef struct SCatalogReq { SArray* pTableCfg; // element is SNAME bool qNodeRequired; // valid qnode bool dNodeRequired; // valid dnode + bool svrVerRequired; bool forceUpdate; } SCatalogReq; @@ -80,18 +81,19 @@ typedef struct SMetaRes { } SMetaRes; typedef struct SMetaData { - SArray* pDbVgroup; // pRes = SArray* - SArray* pDbCfg; // pRes = SDbCfgInfo* - SArray* pDbInfo; // pRes = SDbInfo* - SArray* pTableMeta; // pRes = STableMeta* - SArray* pTableHash; // pRes = SVgroupInfo* - SArray* pTableIndex; // pRes = SArray* - SArray* pUdfList; // pRes = SFuncInfo* - SArray* pIndex; // pRes = SIndexInfo* - SArray* pUser; // pRes = bool* - SArray* pQnodeList; // pRes = SArray* - SArray* pTableCfg; // pRes = STableCfg* - SArray* pDnodeList; // pRes = SArray* + SArray* pDbVgroup; // pRes = SArray* + SArray* pDbCfg; // pRes = SDbCfgInfo* + SArray* pDbInfo; // pRes = SDbInfo* + SArray* pTableMeta; // pRes = STableMeta* + SArray* pTableHash; // pRes = SVgroupInfo* + SArray* pTableIndex; // pRes = SArray* + SArray* pUdfList; // pRes = SFuncInfo* + SArray* pIndex; // pRes = SIndexInfo* + SArray* pUser; // pRes = bool* + SArray* pQnodeList; // pRes = SArray* + SArray* pTableCfg; // pRes = STableCfg* + SArray* pDnodeList; // pRes = SArray* + SMetaRes* pSvrVer; // pRes = char* } SMetaData; typedef struct SCatalogCfg { @@ -268,7 +270,7 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, c */ int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp); -int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId); +int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId); int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList); @@ -298,6 +300,8 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth); int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet); +int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion); + int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate); int32_t catalogClearCache(void); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 4f18cb19c2..585675c5fd 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -40,7 +40,6 @@ extern "C" { #define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) - #define PRIVILEGE_TYPE_MASK(n) (1 << n) #define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index e45e5bd160..6c2a9bb374 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -51,6 +51,8 @@ typedef struct SParseContext { bool isSuperUser; bool async; int8_t schemalessType; + const char* svrVer; + bool nodeOffline; } SParseContext; int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 2b918412fe..cca79186d0 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -54,6 +54,11 @@ enum { RES_TYPE__TMQ_META, }; +#define SHOW_VARIABLES_RESULT_COLS 2 +#define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) +#define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) + + #define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) #define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) #define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) @@ -104,6 +109,8 @@ typedef struct SHeartBeatInfo { struct SAppInstInfo { int64_t numOfConns; SCorEpSet mgmtEp; + int32_t totalDnodes; + int32_t onlineDnodes; TdThreadMutex qnodeMutex; SArray* pQnodeList; SAppClusterSummary summary; @@ -127,7 +134,8 @@ typedef struct STscObj { char user[TSDB_USER_LEN]; char pass[TSDB_PASSWORD_LEN]; char db[TSDB_DB_FNAME_LEN]; - char ver[128]; + char sVer[TSDB_VERSION_LEN]; + char sDetailVer[128]; int8_t connType; int32_t acctId; uint32_t connId; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index c6d0d6a860..86562fea97 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -161,6 +161,9 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); } + + pTscObj->pAppInfo->totalDnodes = pRsp->query->totalDnodes; + pTscObj->pAppInfo->onlineDnodes = pRsp->query->onlineDnodes; pTscObj->connId = pRsp->query->connId; if (pRsp->query->killRid) { diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 51e709ac58..b3aaeaea78 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -178,7 +178,9 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC .pStmtCb = pStmtCb, .pUser = pTscObj->user, .schemalessType = pTscObj->schemalessType, - .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER))}; + .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)), + .svrVer = pTscObj->sVer, + .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes)}; cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 515136bb27..f5dfe2de36 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -623,7 +623,7 @@ const char *taos_get_server_info(TAOS *taos) { releaseTscObj(*(int64_t *)taos); - return pTscObj->ver; + return pTscObj->sDetailVer; } typedef struct SqlParseWrapper { @@ -766,7 +766,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { .requestObjRefId = pCxt->requestRid, .mgmtEps = pCxt->mgmtEpSet}; - code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, &catalogReq, retrieveMetaCallback, pWrapper, + code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, &catalogReq, retrieveMetaCallback, pWrapper, &pRequest->body.queryJob); if (code == TSDB_CODE_SUCCESS) { return; @@ -934,7 +934,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); - code = catalogAsyncGetAllMeta(pCtg, &conn, pRequest->requestId, &catalogReq, syncCatalogFn, ¶m, NULL); + code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, ¶m, NULL); if (code) { goto _return; } diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index db8aebb322..45a525d124 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -82,7 +82,8 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { pTscObj->connId = connectRsp.connId; pTscObj->acctId = connectRsp.acctId; - tstrncpy(pTscObj->ver, connectRsp.sVersion, tListLen(pTscObj->ver)); + tstrncpy(pTscObj->sVer, connectRsp.sVer, tListLen(pTscObj->sVer)); + tstrncpy(pTscObj->sDetailVer, connectRsp.sDetailVer, tListLen(pTscObj->sDetailVer)); // update the appInstInfo pTscObj->pAppInfo->clusterId = connectRsp.clusterId; @@ -287,6 +288,103 @@ int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) { return code; } +static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + pBlock->info.hasVarCol = true; + + pBlock->pDataBlock = taosArrayInit(SHOW_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData)); + + SColumnInfoData infoData = {0}; + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD1_LEN; + + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD2_LEN; + taosArrayPush(pBlock->pDataBlock, &infoData); + + int32_t numOfCfg = taosArrayGetSize(pVars); + blockDataEnsureCapacity(pBlock, numOfCfg); + + for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) { + SVariablesInfo *pInfo = taosArrayGet(pVars, i); + + char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++); + colDataAppend(pColInfo, i, name, false); + + char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE); + pColInfo = taosArrayGet(pBlock->pDataBlock, c++); + colDataAppend(pColInfo, i, value, false); + } + + pBlock->info.rows = numOfCfg; + + *block = pBlock; + + return TSDB_CODE_SUCCESS; +} + + +static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = NULL; + int32_t code = buildShowVariablesBlock(pVars, &pBlock); + if (code) { + return code; + } + + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + *pRsp = taosMemoryCalloc(1, rspSize); + if (NULL == *pRsp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htonl(pBlock->info.rows); + (*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS); + + int32_t len = 0; + blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_VARIABLES_RESULT_COLS, false); + ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); + + blockDataDestroy(pBlock); + return TSDB_CODE_SUCCESS; +} + +int32_t processShowVariablesRsp(void* param, const SDataBuf* pMsg, int32_t code) { + SRequestObj* pRequest = param; + if (code != TSDB_CODE_SUCCESS) { + setErrno(pRequest, code); + } else { + SShowVariablesRsp rsp = {0}; + SRetrieveTableRsp* pRes = NULL; + code = tDeserializeSShowVariablesRsp(pMsg->pData, pMsg->len, &rsp); + if (TSDB_CODE_SUCCESS == code) { + code = buildShowVariablesRsp(rsp.variables, &pRes); + } + if (TSDB_CODE_SUCCESS == code) { + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, false); + } + + tFreeSShowVariablesRsp(&rsp); + } + + if (pRequest->body.queryFp != NULL) { + pRequest->body.queryFp(pRequest->body.param, pRequest, code); + } else { + tsem_post(&pRequest->body.rspSem); + } + return code; +} + + __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) { switch (msgType) { case TDMT_MND_CONNECT: @@ -301,6 +399,8 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) { return processDropDbRsp; case TDMT_MND_ALTER_STB: return processAlterStbRsp; + case TDMT_MND_SHOW_VARIABLES: + return processShowVariablesRsp; default: return genericRspCallback; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 4ad11f2998..2c6b94f17c 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2246,6 +2246,56 @@ int32_t tDeserializeSDnodeListReq(void *buf, int32_t bufLen, SDnodeListReq *pReq return 0; } +int32_t tSerializeSServerVerReq(void *buf, int32_t bufLen, SServerVerReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->useless) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSServerVerReq(void *buf, int32_t bufLen, SServerVerReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->useless) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +int32_t tSerializeSServerVerRsp(void *buf, int32_t bufLen, SServerVerRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->ver) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSServerVerRsp(void *buf, int32_t bufLen, SServerVerRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->ver) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) { SEncoder encoder = {0}; @@ -2855,6 +2905,67 @@ int32_t tDeserializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesR return 0; } +int32_t tEncodeSVariablesInfo(SEncoder* pEncoder, SVariablesInfo* pInfo) { + if (tEncodeCStr(pEncoder, pInfo->name) < 0) return -1; + if (tEncodeCStr(pEncoder, pInfo->value) < 0) return -1; + return 0; +} + +int32_t tDecodeSVariablesInfo(SDecoder* pDecoder, SVariablesInfo* pInfo) { + if (tDecodeCStrTo(pDecoder, pInfo->name) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pInfo->value) < 0) return -1; + return 0; +} + + +int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + int32_t varNum = taosArrayGetSize(pRsp->variables); + if (tEncodeI32(&encoder, varNum) < 0) return -1; + for (int32_t i = 0; i < varNum; ++i) { + SVariablesInfo* pInfo = taosArrayGet(pRsp->variables, i); + if (tEncodeSVariablesInfo(&encoder, pInfo) < 0) return -1; + } + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + int32_t varNum = 0; + if (tDecodeI32(&decoder, &varNum) < 0) return -1; + if (varNum > 0) { + pRsp->variables = taosArrayInit(varNum, sizeof(SVariablesInfo)); + if (NULL == pRsp->variables) return -1; + for (int32_t i = 0; i < varNum; ++i) { + SVariablesInfo info = {0}; + if (tDecodeSVariablesInfo(&decoder, &info) < 0) return -1; + if (NULL == taosArrayPush(pRsp->variables, &info)) return -1; + } + } + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp) { + if (NULL == pRsp) { + return; + } + + taosArrayDestroy(pRsp->variables); +} + int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -3396,7 +3507,8 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1; if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1; if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1; - if (tEncodeCStr(&encoder, pRsp->sVersion) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->sVer) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->sDetailVer) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -3416,7 +3528,8 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1; if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1; - if (tDecodeCStrTo(&decoder, pRsp->sVersion) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->sVer) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->sDetailVer) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index d44a7d79bf..cb741994b8 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -206,6 +206,8 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index d3723326b9..0eab364e90 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -48,6 +48,7 @@ static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode); static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode); static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew); static int32_t mndProcessDnodeListReq(SRpcMsg *pReq); +static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq); static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq); static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq); @@ -78,6 +79,7 @@ int32_t mndInitDnode(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp); mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq); mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq); + mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig); @@ -554,6 +556,60 @@ _OVER: return code; } +static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) { + SShowVariablesRsp rsp = {0}; + int32_t code = -1; + + rsp.variables = taosArrayInit(4, sizeof(SVariablesInfo)); + if (NULL == rsp.variables) { + mError("failed to alloc SVariablesInfo array while process show variables req"); + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + SVariablesInfo info = {0}; + + strcpy(info.name, "statusInterval"); + snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval); + taosArrayPush(rsp.variables, &info); + + strcpy(info.name, "timezone"); + snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr); + taosArrayPush(rsp.variables, &info); + + strcpy(info.name, "locale"); + snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale); + taosArrayPush(rsp.variables, &info); + + strcpy(info.name, "charset"); + snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset); + taosArrayPush(rsp.variables, &info); + + int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp); + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp); + + pReq->info.rspLen = rspLen; + pReq->info.rsp = pRsp; + code = 0; + +_OVER: + + if (code != 0) { + mError("failed to get show variables info since %s", terrstr()); + } + + tFreeSShowVariablesRsp(&rsp); + + return code; +} + + static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 832e328d96..acbbf993fd 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -70,6 +70,7 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter); static void mndFreeApp(SAppObj *pApp); static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextApp(SMnode *pMnode, void *pIter); +static int32_t mndProcessSvrVerReq(SRpcMsg *pReq); int32_t mndInitProfile(SMnode *pMnode) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; @@ -94,6 +95,7 @@ int32_t mndInitProfile(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_CONNECT, mndProcessConnectReq); mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq); mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq); + mndSetMsgHandle(pMnode, TDMT_MND_SERVER_VERSION, mndProcessSvrVerReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn); @@ -262,8 +264,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { connectRsp.connId = pConn->id; connectRsp.connType = connReq.connType; connectRsp.dnodeNum = mndGetDnodeSize(pMnode); - - snprintf(connectRsp.sVersion, sizeof(connectRsp.sVersion), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo, + + strcpy(connectRsp.sVer, version); + snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo, gitinfo); mndGetMnodeEpSet(pMnode, &connectRsp.epSet); @@ -460,6 +463,27 @@ static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnIn return TSDB_CODE_SUCCESS; } +static int32_t mndGetOnlineDnodeNum(SMnode *pMnode, int32_t *num) { + SSdb *pSdb = pMnode->pSdb; + SDnodeObj *pDnode = NULL; + int64_t curMs = taosGetTimestampMs(); + void *pIter = NULL; + + while (true) { + pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode); + if (pIter == NULL) break; + + bool online = mndIsDnodeOnline(pDnode, curMs); + if (online) { + (*num)++; + } + + sdbRelease(pSdb, pDnode); + } + + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; @@ -503,7 +527,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb rspBasic->connId = pConn->id; rspBasic->totalDnodes = mndGetDnodeSize(pMnode); - rspBasic->onlineDnodes = 1; // TODO + mndGetOnlineDnodeNum(pMnode, &rspBasic->onlineDnodes); mndGetMnodeEpSet(pMnode, &rspBasic->epSet); mndCreateQnodeList(pMnode, &rspBasic->pQnodeList, -1); @@ -694,6 +718,28 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) { } } +static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) { + int32_t code = -1; + SServerVerRsp rsp = {0}; + strcpy(rsp.ver, version); + + int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp); + if (contLen < 0) goto _over; + void *pRsp = rpcMallocCont(contLen); + if (pRsp == NULL) goto _over; + tSerializeSServerVerRsp(pRsp, contLen, &rsp); + + pReq->info.rspLen = contLen; + pReq->info.rsp = pRsp; + + code = 0; + +_over: + + return code; +} + + static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 384c3f19e5..74caa717b8 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -76,6 +76,7 @@ typedef enum { CTG_TASK_GET_INDEX, CTG_TASK_GET_UDF, CTG_TASK_GET_USER, + CTG_TASK_GET_SVR_VER, } CTG_TASK_TYPE; typedef enum { @@ -224,6 +225,7 @@ typedef struct SCtgJob { int32_t dbInfoNum; int32_t tbIndexNum; int32_t tbCfgNum; + int32_t svrVerNum; } SCtgJob; typedef struct SCtgMsgCtx { @@ -578,8 +580,9 @@ int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask); int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask); int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask); +int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask); -int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum); +int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum); int32_t ctgLaunchJob(SCtgJob *pJob); int32_t ctgMakeAsyncRes(SCtgJob *pJob); int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param); diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 931a944adf..abead99cb0 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -1051,7 +1051,7 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId) { +int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pReq || NULL == fp || NULL == param) { @@ -1060,7 +1060,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, uint64_t int32_t code = 0, taskNum = 0; SCtgJob *pJob = NULL; - CTG_ERR_JRET(ctgInitJob(pCtg, pConn, &pJob, reqId, pReq, fp, param, &taskNum)); + CTG_ERR_JRET(ctgInitJob(pCtg, pConn, &pJob, pReq, fp, param, &taskNum)); if (taskNum <= 0) { SMetaData* pMetaData = taosMemoryCalloc(1, sizeof(SMetaData)); fp(pMetaData, param, TSDB_CODE_SUCCESS); @@ -1247,6 +1247,22 @@ _return: CTG_API_LEAVE(code); } +int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pConn || NULL == pVersion) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(ctgGetSvrVerFromMnode(pCtg, pConn, pVersion, NULL)); + +_return: + + CTG_API_LEAVE(code); +} + + int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) { CTG_API_ENTER(); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 8928a7e028..18c95397dd 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -255,6 +255,20 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, void* param) { return TSDB_CODE_SUCCESS; } +int32_t ctgInitGetSvrVerTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SCtgTask task = {0}; + + task.type = CTG_TASK_GET_SVR_VER; + task.taskId = taskIdx; + task.pJob = pJob; + + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:0x%" PRIx64 " [%dth] task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type)); + + return TSDB_CODE_SUCCESS; +} + int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { SName *name = (SName*)param; SCtgTask task = {0}; @@ -413,7 +427,7 @@ int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *tas return TSDB_CODE_SUCCESS; } -int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum) { +int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum) { int32_t code = 0; int32_t tbMetaNum = (int32_t)taosArrayGetSize(pReq->pTableMeta); int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup); @@ -421,6 +435,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 int32_t udfNum = (int32_t)taosArrayGetSize(pReq->pUdf); int32_t qnodeNum = pReq->qNodeRequired ? 1 : 0; int32_t dnodeNum = pReq->dNodeRequired ? 1 : 0; + int32_t svrVerNum = pReq->svrVerRequired ? 1 : 0; int32_t dbCfgNum = (int32_t)taosArrayGetSize(pReq->pDbCfg); int32_t indexNum = (int32_t)taosArrayGetSize(pReq->pIndex); int32_t userNum = (int32_t)taosArrayGetSize(pReq->pUser); @@ -428,21 +443,21 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex); int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg); - *taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum; + *taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum; if (*taskNum <= 0) { - ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, reqId); + ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, pConn->requestId); return TSDB_CODE_SUCCESS; } *job = taosMemoryCalloc(1, sizeof(SCtgJob)); if (NULL == *job) { - ctgError("failed to calloc, size:%d, reqId:0x%" PRIx64, (int32_t)sizeof(SCtgJob), reqId); + ctgError("failed to calloc, size:%d, reqId:0x%" PRIx64, (int32_t)sizeof(SCtgJob), pConn->requestId); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCtgJob *pJob = *job; - pJob->queryId = reqId; + pJob->queryId = pConn->requestId; pJob->userFp = fp; pJob->pCtg = pCtg; pJob->conn = *pConn; @@ -460,6 +475,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 pJob->dbInfoNum = dbInfoNum; pJob->tbIndexNum = tbIndexNum; pJob->tbCfgNum = tbCfgNum; + pJob->svrVerNum = svrVerNum; pJob->pTasks = taosArrayInit(*taskNum, sizeof(SCtgTask)); @@ -530,6 +546,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DNODE, NULL, NULL)); } + if (svrVerNum) { + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_SVR_VER, NULL, NULL)); + } + pJob->refId = taosAddRef(gCtgMgmt.jobPool, pJob); if (pJob->refId < 0) { ctgError("add job to ref failed, error: %s", tstrerror(terrno)); @@ -728,6 +748,21 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgDumpSvrVer(SCtgTask* pTask) { + SCtgJob* pJob = pTask->pJob; + if (NULL == pJob->jobRes.pSvrVer) { + pJob->jobRes.pSvrVer = taosMemoryCalloc(1, sizeof(SMetaRes)); + if (NULL == pJob->jobRes.pSvrVer) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + } + + pJob->jobRes.pSvrVer->code = pTask->code; + pJob->jobRes.pSvrVer->pRes = pTask->res; + + return TSDB_CODE_SUCCESS; +} + int32_t ctgInvokeSubCb(SCtgTask *pTask) { int32_t code = 0; @@ -1156,6 +1191,20 @@ _return: CTG_RET(code); } +int32_t ctgHandleGetSvrVerRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + + CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); + + TSWAP(pTask->res, pTask->msgCtx.out); + +_return: + + ctgHandleTaskEnd(pTask, code); + + CTG_RET(code); +} + int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; @@ -1459,6 +1508,15 @@ int32_t ctgLaunchGetUserTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgLaunchGetSvrVerTask(SCtgTask *pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; + SRequestConnInfo* pConn = &pTask->pJob->conn; + + CTG_ERR_RET(ctgGetSvrVerFromMnode(pCtg, pConn, NULL, pTask)); + + return TSDB_CODE_SUCCESS; +} + int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) { ctgResetTbMetaTask(pTask); @@ -1532,6 +1590,7 @@ SCtgAsyncFps gCtgAsyncFps[] = { {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL}, {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL}, {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL}, + {ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL}, }; int32_t ctgMakeAsyncRes(SCtgJob *pJob) { @@ -1633,7 +1692,7 @@ int32_t ctgLaunchJob(SCtgJob *pJob) { for (int32_t i = 0; i < taskNum; ++i) { SCtgTask *pTask = taosArrayGet(pJob->pTasks, i); - qDebug("QID:0x%" PRIx64 " ctg start to launch task %d", pJob->queryId, pTask->taskId); + qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId); CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask)); pTask->status = CTG_TASK_LAUNCHED; } diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index 7f2b919f17..5f54362d8e 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -210,7 +210,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re int64_t jobId = 0; - CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pConn, reqId, &req, ctgdUserCallback, param, &jobId)); + CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pConn, &req, ctgdUserCallback, param, &jobId)); _return: diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 97edb1b837..304da88888 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -217,6 +217,21 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, qDebug("Got stb cfg from mnode, tbFName:%s", target); break; } + case TDMT_MND_SERVER_VERSION: { + if (TSDB_CODE_SUCCESS != rspCode) { + qError("error rsp for svr ver from mnode, error:%s", tstrerror(rspCode)); + CTG_ERR_RET(rspCode); + } + + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process svr ver rsp failed, error:%s", tstrerror(code)); + CTG_ERR_RET(code); + } + + qDebug("Got svr ver from mnode"); + break; + } default: qError("invalid req type %s", TMSG_INFO(reqType)); return TSDB_CODE_APP_ERROR; @@ -811,4 +826,38 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S return TSDB_CODE_SUCCESS; } +int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask) { + char *msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_MND_SERVER_VERSION; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + + qDebug("try to get svr ver from mnode"); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](NULL, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build get svr ver msg failed, code:%s", tstrerror(code)); + CTG_ERR_RET(code); + } + + if (pTask) { + CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL)); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &pConn->mgmtEps, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, NULL)); + + return TSDB_CODE_SUCCESS; +} + diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index cc823adad0..0c10b69a2d 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -45,6 +45,8 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) { return "[get udf]"; case CTG_TASK_GET_USER: return "[get user]"; + case CTG_TASK_GET_SVR_VER: + return "[get svr ver]"; default: return "unknown"; } @@ -103,8 +105,13 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pQnodeList); pData->pQnodeList = NULL; + taosArrayDestroy(pData->pDnodeList); + pData->pDnodeList = NULL; + taosArrayDestroy(pData->pTableCfg); pData->pTableCfg = NULL; + + taosMemoryFreeClear(pData->pSvrVer); } void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) { @@ -346,20 +353,8 @@ void ctgResetTbMetaTask(SCtgTask* pTask) { void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { switch (type) { - case CTG_TASK_GET_QNODE: { - taosArrayDestroy((SArray*)*pRes); - *pRes = NULL; - break; - } - case CTG_TASK_GET_DNODE: { - taosArrayDestroy((SArray*)*pRes); - *pRes = NULL; - break; - } - case CTG_TASK_GET_TB_META: { - taosMemoryFreeClear(*pRes); - break; - } + case CTG_TASK_GET_QNODE: + case CTG_TASK_GET_DNODE: case CTG_TASK_GET_DB_VGROUP: { taosArrayDestroy((SArray*)*pRes); *pRes = NULL; @@ -373,14 +368,6 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { } break; } - case CTG_TASK_GET_DB_INFO: { - taosMemoryFreeClear(*pRes); - break; - } - case CTG_TASK_GET_TB_HASH: { - taosMemoryFreeClear(*pRes); - break; - } case CTG_TASK_GET_TB_INDEX: { taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo); *pRes = NULL; @@ -394,15 +381,13 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { } break; } - case CTG_TASK_GET_INDEX: { - taosMemoryFreeClear(*pRes); - break; - } - case CTG_TASK_GET_UDF: { - taosMemoryFreeClear(*pRes); - break; - } - case CTG_TASK_GET_USER: { + case CTG_TASK_GET_TB_HASH: + case CTG_TASK_GET_DB_INFO: + case CTG_TASK_GET_INDEX: + case CTG_TASK_GET_UDF: + case CTG_TASK_GET_USER: + case CTG_TASK_GET_SVR_VER: + case CTG_TASK_GET_TB_META: { taosMemoryFreeClear(*pRes); break; } @@ -415,20 +400,12 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { switch (type) { - case CTG_TASK_GET_QNODE: { - taosArrayDestroy((SArray*)*pRes); - *pRes = NULL; - break; - } + case CTG_TASK_GET_QNODE: case CTG_TASK_GET_DNODE: { taosArrayDestroy((SArray*)*pRes); *pRes = NULL; break; } - case CTG_TASK_GET_TB_META: { - taosMemoryFreeClear(*pRes); - break; - } case CTG_TASK_GET_DB_VGROUP: { if (*pRes) { SDBVgInfo* pInfo = (SDBVgInfo*)*pRes; @@ -445,14 +422,6 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { } break; } - case CTG_TASK_GET_DB_INFO: { - taosMemoryFreeClear(*pRes); - break; - } - case CTG_TASK_GET_TB_HASH: { - taosMemoryFreeClear(*pRes); - break; - } case CTG_TASK_GET_TB_INDEX: { taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo); *pRes = NULL; @@ -466,14 +435,12 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { } break; } - case CTG_TASK_GET_INDEX: { - taosMemoryFreeClear(*pRes); - break; - } - case CTG_TASK_GET_UDF: { - taosMemoryFreeClear(*pRes); - break; - } + case CTG_TASK_GET_TB_META: + case CTG_TASK_GET_DB_INFO: + case CTG_TASK_GET_TB_HASH: + case CTG_TASK_GET_INDEX: + case CTG_TASK_GET_UDF: + case CTG_TASK_GET_SVR_VER: case CTG_TASK_GET_USER: { taosMemoryFreeClear(*pRes); break; @@ -497,10 +464,6 @@ void ctgClearSubTaskRes(SCtgSubRes *pRes) { void ctgFreeTaskCtx(SCtgTask* pTask) { switch (pTask->type) { - case CTG_TASK_GET_QNODE: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } case CTG_TASK_GET_TB_META: { SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); @@ -511,18 +474,6 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { taosMemoryFreeClear(pTask->taskCtx); break; } - case CTG_TASK_GET_DB_VGROUP: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } - case CTG_TASK_GET_DB_CFG: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } - case CTG_TASK_GET_DB_INFO: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } case CTG_TASK_GET_TB_HASH: { SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); @@ -542,14 +493,12 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { taosMemoryFreeClear(pTask->taskCtx); break; } - case CTG_TASK_GET_INDEX: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } - case CTG_TASK_GET_UDF: { - taosMemoryFreeClear(pTask->taskCtx); - break; - } + case CTG_TASK_GET_DB_VGROUP: + case CTG_TASK_GET_DB_CFG: + case CTG_TASK_GET_DB_INFO: + case CTG_TASK_GET_INDEX: + case CTG_TASK_GET_UDF: + case CTG_TASK_GET_QNODE: case CTG_TASK_GET_USER: { taosMemoryFreeClear(pTask->taskCtx); break; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 7b5c30d3cb..58b50b776f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4611,7 +4611,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** return TSDB_CODE_SUCCESS; } -static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) { +static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { @@ -4649,7 +4649,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return extractShowCreateTableResultSchema(numOfCols, pSchema); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: - return extractShowLocalVariablesResultSchema(numOfCols, pSchema); + case QUERY_NODE_SHOW_VARIABLES_STMT: + return extractShowVariablesResultSchema(numOfCols, pSchema); default: break; } @@ -5874,7 +5875,6 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_CLUSTER_STMT: case QUERY_NODE_SHOW_TOPICS_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: - case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_APPS_STMT: code = rewriteShow(pCxt, pQuery); break; @@ -5974,6 +5974,14 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_ALTER_LOCAL_STMT: pQuery->execMode = QUERY_EXEC_MODE_LOCAL; break; + case QUERY_NODE_SHOW_VARIABLES_STMT: + pQuery->haveResultSet = true; + pQuery->execMode = QUERY_EXEC_MODE_RPC; + if (NULL != pCxt->pCmdMsg) { + TSWAP(pQuery->pCmdMsg, pCxt->pCmdMsg); + pQuery->msgType = pQuery->pCmdMsg->msgType; + } + break; default: pQuery->execMode = QUERY_EXEC_MODE_RPC; if (NULL != pCxt->pCmdMsg) { diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index df608412b0..b433a88001 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -144,6 +144,23 @@ int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } +int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { + if (NULL == msg || NULL == msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + SServerVerReq req = {0}; + + int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req); + void *pBuf = (*mallcFp)(bufLen); + tSerializeSServerVerReq(pBuf, bufLen, &req); + + *msg = pBuf; + *msgLen = bufLen; + + return TSDB_CODE_SUCCESS; +} + int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { if (NULL == msg || NULL == msgLen) { @@ -467,6 +484,26 @@ int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) { return code; } +int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) { + SServerVerRsp out = {0}; + int32_t code = 0; + + if (NULL == output || NULL == msg || msgSize <= 0) { + code = TSDB_CODE_TSC_INVALID_INPUT; + return code; + } + + if (tDeserializeSServerVerRsp(msg, msgSize, &out) != 0) { + qError("invalid svr ver rsp msg, msgSize:%d", msgSize); + code = TSDB_CODE_INVALID_MSG; + return code; + } + + *(char**)output = strdup(out.ver); + + return code; +} + int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) { SDbCfgRsp out = {0}; @@ -583,6 +620,7 @@ void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg; queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; @@ -596,6 +634,7 @@ void initQueryModuleMsgHandle() { queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp; } #pragma GCC diagnostic pop From 544a2534c5c2fb9a77c7135691b9ff35c9d47bc5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 15:22:57 +0800 Subject: [PATCH 48/81] test: case for sysinfo and enable user --- source/dnode/mnode/impl/src/mndAuth.c | 6 + tests/script/jenkins/basic.txt | 11 +- tests/script/tsim/user/basic.sim | 157 ++++++++++++++++++ tests/script/tsim/user/basic1.sim | 74 --------- tests/script/tsim/user/pass_alter.sim | 66 -------- tests/script/tsim/user/pass_len.sim | 79 --------- tests/script/tsim/user/password.sim | 87 ++++++++++ .../user/{privilege1.sim => privilege_db.sim} | 24 ++- .../{privilege2.sim => privilege_enable.sim} | 13 +- tests/script/tsim/user/privilege_sysinfo.sim | 6 + tests/script/tsim/user/user_len.sim | 85 ---------- 11 files changed, 290 insertions(+), 318 deletions(-) create mode 100644 tests/script/tsim/user/basic.sim delete mode 100644 tests/script/tsim/user/basic1.sim delete mode 100644 tests/script/tsim/user/pass_alter.sim delete mode 100644 tests/script/tsim/user/pass_len.sim create mode 100644 tests/script/tsim/user/password.sim rename tests/script/tsim/user/{privilege1.sim => privilege_db.sim} (78%) rename tests/script/tsim/user/{privilege2.sim => privilege_enable.sim} (81%) create mode 100644 tests/script/tsim/user/privilege_sysinfo.sim delete mode 100644 tests/script/tsim/user/user_len.sim diff --git a/source/dnode/mnode/impl/src/mndAuth.c b/source/dnode/mnode/impl/src/mndAuth.c index d47fb9dfb4..f1f1bbae46 100644 --- a/source/dnode/mnode/impl/src/mndAuth.c +++ b/source/dnode/mnode/impl/src/mndAuth.c @@ -102,7 +102,13 @@ _OVER: } int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) { + if (pUser->superUser && pAlter->alterType != TSDB_ALTER_USER_PASSWD) { + terrno = TSDB_CODE_MND_NO_RIGHTS; + return -1; + } + if (pOperUser->superUser) return 0; + if (!pOperUser->enable) { terrno = TSDB_CODE_MND_USER_DISABLED; return -1; diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index cc28b19de9..340d701a99 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -2,12 +2,11 @@ #======================b1-start=============== # ---- user -./test.sh -f tsim/user/basic1.sim -./test.sh -f tsim/user/pass_alter.sim -./test.sh -f tsim/user/pass_len.sim -./test.sh -f tsim/user/user_len.sim -./test.sh -f tsim/user/privilege1.sim -./test.sh -f tsim/user/privilege2.sim +./test.sh -f tsim/user/basic.sim +./test.sh -f tsim/user/password.sim +./test.sh -f tsim/user/privilege_db.sim +#./test.sh -f tsim/user/privilege_enable.sim +#./test.sh -f tsim/user/privilege_sysinfo.sim ## ---- db ./test.sh -f tsim/db/create_all_options.sim diff --git a/tests/script/tsim/user/basic.sim b/tests/script/tsim/user/basic.sim new file mode 100644 index 0000000000..85d5f8375e --- /dev/null +++ b/tests/script/tsim/user/basic.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== step0 +sql show users +if $data(root)[1] != 1 then + return -1 +endi +if $data(root)[2] != 1 then + return -1 +endi +if $data(root)[3] != 1 then + return -1 +endi + +sql alter user root pass 'taosdata' + +sql_error ALTER USER root SYSINFO 0 +sql_error ALTER USER root SYSINFO 1 +sql_error ALTER USER root enable 0 +sql_error ALTER USER root enable 1 + +sql_error create database db vgroups 1; +sql_error GRANT read ON db.* to root; +sql_error GRANT read ON *.* to root; +sql_error REVOKE read ON db.* from root; +sql_error REVOKE read ON *.* from root; +sql_error GRANT write ON db.* to root; +sql_error GRANT write ON *.* to root; +sql_error REVOKE write ON db.* from root; +sql_error REVOKE write ON *.* from root; +sql_error REVOKE write ON *.* from root; + +sql_error GRANT all ON *.* to root; +sql_error REVOKE all ON *.* from root; +sql_error GRANT read,write ON *.* to root; +sql_error REVOKE read,write ON *.* from root; + +print =============== step1: sysinfo create +sql CREATE USER u1 PASS 'taosdata' SYSINFO 0; +sql show users +if $rows != 2 then + return -1 +endi +if $data(u1)[1] != 0 then + return -1 +endi +if $data(u1)[2] != 1 then + return -1 +endi +if $data(u1)[3] != 0 then + return -1 +endi + +sql CREATE USER u2 PASS 'taosdata' SYSINFO 1; +sql show users +if $rows != 3 then + return -1 +endi +if $data(u2)[1] != 0 then + return -1 +endi +if $data(u2)[2] != 1 then + return -1 +endi +if $data(u2)[3] != 1 then + return -1 +endi + +print =============== step2: sysinfo alter +sql ALTER USER u1 SYSINFO 1 +sql show users +if $data(u1)[1] != 0 then + return -1 +endi +if $data(u1)[2] != 1 then + return -1 +endi +if $data(u1)[3] != 1 then + return -1 +endi + +sql ALTER USER u1 SYSINFO 0 +sql show users +if $data(u1)[1] != 0 then + return -1 +endi +if $data(u1)[2] != 1 then + return -1 +endi +if $data(u1)[3] != 0 then + return -1 +endi + +sql ALTER USER u1 SYSINFO 0 +sql ALTER USER u1 SYSINFO 0 + +sql drop user u1 +sql show users +if $rows != 2 then + return -1 +endi + +print =============== step3: enable alter +sql ALTER USER u2 enable 0 +sql show users +if $rows != 2 then + return -1 +endi +if $data(u2)[1] != 0 then + return -1 +endi +if $data(u2)[2] != 0 then + return -1 +endi +if $data(u2)[3] != 1 then + return -1 +endi + +sql ALTER USER u2 enable 1 +sql show users +if $data(u2)[1] != 0 then + return -1 +endi +if $data(u2)[2] != 1 then + return -1 +endi +if $data(u2)[3] != 1 then + return -1 +endi + +sql ALTER USER u2 enable 1 +sql ALTER USER u2 enable 1 + +print =============== restart taosd +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s start + +print =============== step4: enable privilege +sql show users +if $rows != 2 then + return -1 +endi +if $data(u2)[1] != 0 then + return -1 +endi +if $data(u2)[2] != 1 then + return -1 +endi +if $data(u2)[3] != 1 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/user/basic1.sim b/tests/script/tsim/user/basic1.sim deleted file mode 100644 index 06a52c6604..0000000000 --- a/tests/script/tsim/user/basic1.sim +++ /dev/null @@ -1,74 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print =============== show users -sql show users -if $rows != 1 then - return -1 -endi - -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" -sql_error drop account a -sql_error drop account root - -print =============== create user1 -sql create user user1 PASS 'user1' -sql show users -if $rows != 2 then - return -1 -endi - -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' -sql show users -if $rows != 3 then - return -1 -endi - -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 -sql drop user user1 -sql show users -if $rows != 2 then - return -1 -endi - -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 -sleep 1000 -system sh/exec.sh -n dnode1 -s start - -print =============== show users -sql show users -if $rows != 2 then - return -1 -endi - -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/script/tsim/user/pass_alter.sim b/tests/script/tsim/user/pass_alter.sim deleted file mode 100644 index 33fc9e51bd..0000000000 --- a/tests/script/tsim/user/pass_alter.sim +++ /dev/null @@ -1,66 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print ============= step1 -sql create user u_read pass 'taosdata1' -sql create user u_write pass 'taosdata1' - -sql alter user u_read pass 'taosdata' -sql alter user u_write pass 'taosdata' - -sql show users -if $rows != 3 then - return -1 -endi - -print ============= step2 -sql close -sleep 2500 -print user u_read login -sql connect u_read -sql alter user u_read pass 'taosdata' -sql alter user u_write pass 'taosdata1' -x step2 - return -1 -step2: - -sql_error create user read1 pass 'taosdata1' -sql_error create user write1 pass 'taosdata1' - -sql show users -if $rows != 3 then - return -1 -endi - -print ============= step3 -sql close -sleep 2500 -print user u_write login -sql connect u_write - -sql_error create user read2 pass 'taosdata1' -sql_error create user write2 pass 'taosdata1' -sql alter user u_write pass 'taosdata' -sql alter user u_read pass 'taosdata' -x step3 - return -1 -step3: - -sql show users -if $rows != 3 then - return -1 -endi - -print ============= step4 -sql close -sleep 2500 -print user root login -sql connect -sql create user oroot pass 'taosdata' - -sql show users -if $rows != 4 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/user/pass_len.sim b/tests/script/tsim/user/pass_len.sim deleted file mode 100644 index 66c378c6cb..0000000000 --- a/tests/script/tsim/user/pass_len.sim +++ /dev/null @@ -1,79 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -$i = 0 -$dbPrefix = apdb -$tbPrefix = aptb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i -$userPrefix = apusr - -print =============== step1 -$i = 0 -$user = $userPrefix . $i - -sql drop user $user -x step11 - return -1 -step11: - -sql create user $user PASS -x step12 - return -1 -step12: - -sql create user $user PASS 'taosdata' - -sql show users -if $rows != 2 then - return -1 -endi - -print =============== step2 -$i = 1 -$user = $userPrefix . $i -sql drop user $user -x step2 -step2: -sql create user $user PASS '1' -sql show users -if $rows != 3 then - return -1 -endi - -print =============== step3 -$i = 2 -$user = $userPrefix . $i -sql drop user $user -x step3 -step3: - -sql create user $user PASS 'abc0123456789' -sql show users -if $rows != 4 then - return -1 -endi - -print =============== step4 -$i = 3 -$user = $userPrefix . $i -sql create user $user PASS 'abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890123' -x step4 - return -1 - -step4: -sql show users -if $rows != 4 then - return -1 -endi - -$i = 0 -while $i < 3 - $user = $userPrefix . $i - sql drop user $user - $i = $i + 1 -endw - -sql show users -if $rows != 1 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/user/password.sim b/tests/script/tsim/user/password.sim new file mode 100644 index 0000000000..d26b9dbc2e --- /dev/null +++ b/tests/script/tsim/user/password.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============= step1 +sql create user u_read pass 'taosdata1' +sql create user u_write pass 'taosdata1' + +sql alter user u_read pass 'taosdata' +sql alter user u_write pass 'taosdata' + +sql show users +if $rows != 3 then + return -1 +endi + +print ============= step2 +print user u_read login +sql close +sql connect u_read + +sql alter user u_read pass 'taosdata' +sql_error alter user u_write pass 'taosdata1' + +sql_error create user read1 pass 'taosdata1' +sql_error create user write1 pass 'taosdata1' + +sql show users +if $rows != 3 then + return -1 +endi + +print ============= step3 +print user u_write login +sql close +sql connect u_write + +sql_error create user read2 pass 'taosdata1' +sql_error create user write2 pass 'taosdata1' +sql alter user u_write pass 'taosdata' +sql_error alter user u_read pass 'taosdata' + +sql show users +if $rows != 3 then + return -1 +endi + +print ============= step4 +print user root login +sql close +sql connect +sql create user oroot pass 'taosdata' +sql_error create user $user PASS 'abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890123' +sql_error create userabcd012345678901234567891234567890abcd01234567890123456789123456789 PASS 'taosdata' +sql_error create user abcd0123456789012345678901234567890111 PASS '123' +sql create user abc01234567890123456789 PASS '123' + +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step5 +sql create database db vgroups 1 +sql_error ALTER USER o_root SYSINFO 0 +sql_error ALTER USER o_root SYSINFO 1 +sql_error ALTER USER o_root enable 0 +sql_error ALTER USER o_root enable 1 + +sql_error create database db vgroups 1; +sql_error GRANT read ON db.* to o_root; +sql_error GRANT read ON *.* to o_root; +sql_error REVOKE read ON db.* from o_root; +sql_error REVOKE read ON *.* from o_root; +sql_error GRANT write ON db.* to o_root; +sql_error GRANT write ON *.* to o_root; +sql_error REVOKE write ON db.* from o_root; +sql_error REVOKE write ON *.* from o_root; +sql_error REVOKE write ON *.* from o_root; + +sql_error GRANT all ON *.* to o_root; +sql_error REVOKE all ON *.* from o_root; +sql_error GRANT read,write ON *.* to o_root; +sql_error REVOKE read,write ON *.* from o_root; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/user/privilege1.sim b/tests/script/tsim/user/privilege_db.sim similarity index 78% rename from tests/script/tsim/user/privilege1.sim rename to tests/script/tsim/user/privilege_db.sim index a7c5d9d13d..a694d21f2f 100644 --- a/tests/script/tsim/user/privilege1.sim +++ b/tests/script/tsim/user/privilege_db.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print =============== show users +print =============== create db sql create database d1 vgroups 1; sql create database d2 vgroups 1; sql create database d3 vgroups 1; @@ -68,4 +68,26 @@ sql REVOKE read,write ON d1.* from user1; sql REVOKE read,write ON d2.* from user1; sql REVOKE read,write ON *.* from user1; + +print =============== create users +sql create user u1 PASS 'taosdata' +sql show users +if $rows != 4 then + return -1 +endi + +sql GRANT read ON d1.* to u1; +sql GRANT write ON d2.* to u1; + +print =============== re connect +print user u1 login +sql close +sql connect u1 + +sql_error drop database d1; +sql_error drop database d2; + +sql_error create stable d1.st (ts timestamp, i int) tags (j int) +sql create stable d2.st (ts timestamp, i int) tags (j int) + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/user/privilege2.sim b/tests/script/tsim/user/privilege_enable.sim similarity index 81% rename from tests/script/tsim/user/privilege2.sim rename to tests/script/tsim/user/privilege_enable.sim index 470f167c50..5635e7c95e 100644 --- a/tests/script/tsim/user/privilege2.sim +++ b/tests/script/tsim/user/privilege_enable.sim @@ -3,14 +3,13 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print =============== show users +print =============== create db sql create database d1 vgroups 1; -sql create database d2 vgroups 1; -sql create database d3 vgroups 1; -sql show databases -if $rows != 5 then - return -1 -endi + +print =============== create users +sql create user u1 pass 'taosdata' +sql alter user u1 enable 0 + print =============== create users sql create user user1 PASS 'taosdata' diff --git a/tests/script/tsim/user/privilege_sysinfo.sim b/tests/script/tsim/user/privilege_sysinfo.sim new file mode 100644 index 0000000000..b7d4195ae1 --- /dev/null +++ b/tests/script/tsim/user/privilege_sysinfo.sim @@ -0,0 +1,6 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/user/user_len.sim b/tests/script/tsim/user/user_len.sim deleted file mode 100644 index 0e44f94294..0000000000 --- a/tests/script/tsim/user/user_len.sim +++ /dev/null @@ -1,85 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -$i = 0 -$dbPrefix = lm_us_db -$tbPrefix = lm_us_tb -$db = $dbPrefix . $i -$tb = $tbPrefix . $i - -print =============== step1 -sql drop user ac -x step0 - return -1 -step0: - -sql create user PASS '123' -x step1 - return -1 -step1: - -sql show users -if $rows != 1 then - return -1 -endi - -print =============== step2 -sql drop user a -x step2 -step2: -sql create user a PASS '123' -sql show users -if $rows != 2 then - return -1 -endi - -sql drop user a -sql show users -if $rows != 1 then - return -1 -endi - -print =============== step3 -sql drop user abc01234567890123456789 -x step3 -step3: - -sql create user abc01234567890123456789 PASS '123' -sql show users -if $rows != 2 then - return -1 -endi - -sql drop user abc01234567890123456789 -sql show users -if $rows != 1 then - return -1 -endi - -print =============== step4 -sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 - return -1 -step4: -sql show users -if $rows != 1 then - return -1 -endi - -print =============== step5 -sql drop user 123 -x step5 -step5: -sql create user 123 PASS '123' -x step61 - return -1 -step61: - -sql create user a123 PASS '123' -sql show users -if $rows != 2 then - return -1 -endi - -sql drop user a123 -sql show users -if $rows != 1 then - return -1 -endi - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From e8db435e2ecfd08011604ccca7b992270b9e2908 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 15:24:13 +0800 Subject: [PATCH 49/81] enh: adjust password len --- source/dnode/mnode/impl/inc/mndDef.h | 2 +- source/dnode/mnode/impl/src/mndProfile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 0605e3a69e..693cb77b6d 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -222,7 +222,7 @@ typedef struct { typedef struct { char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_PASSWORD_LEN + 1]; char acct[TSDB_USER_LEN]; int64_t createdTime; int64_t updateTime; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 832e328d96..08da1d54d9 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -230,7 +230,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { mGError("user:%s, failed to login while acquire user since %s", pReq->info.conn.user, terrstr()); goto CONN_OVER; } - if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) { + if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN)) { mGError("user:%s, failed to auth while acquire user, input:%s", pReq->info.conn.user, connReq.passwd); code = TSDB_CODE_RPC_AUTH_FAILURE; goto CONN_OVER; From 7695dbcce776f0429906059244c9b11135dd302c Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 15:28:01 +0800 Subject: [PATCH 50/81] refactor(sync): adjust election timer --- source/dnode/mnode/impl/src/mndSync.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index b481f417d9..c58ce97588 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -198,6 +198,10 @@ int32_t mndInitSync(SMnode *pMnode) { return -1; } + // decrease election timer + setElectTimerMS(pMgmt->sync, 600); + setHeartbeatTimerMS(pMgmt->sync, 300); + mDebug("mnode-sync is opened, id:%" PRId64, pMgmt->sync); return 0; } From 01f64b4d17db39954f939ea4c8b6afbaba67a438 Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 24 Jun 2022 15:28:37 +0800 Subject: [PATCH 51/81] fix: fix bugs of less output when interval overlaps --- source/libs/executor/src/timewindowoperator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 554fce3968..f0358b6d7b 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -3924,7 +3924,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t return 0; } - if (newWin == NULL || (ascScan && newWin->skey > prevWin->ekey || (!ascScan) && newWin->skey < prevWin->ekey)) { + if (newWin == NULL || (ascScan && newWin->skey > prevWin->skey || (!ascScan) && newWin->skey < prevWin->skey)) { SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &prevWin->skey, TSDB_KEYSIZE, tableGroupId); SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); From 181874339bc32c34cf5c7c30d0854f6a7f9aa8e0 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Fri, 24 Jun 2022 15:46:45 +0800 Subject: [PATCH 52/81] fix: change Jenkins run case timeout --- Jenkinsfile2 | 2 +- tests/parallel_test/run.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 38af8fd286..b65576deaf 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -363,7 +363,7 @@ pipeline { echo "${linux_node_ip}:${linux_node_pass}" } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 40, unit: 'MINUTES'){ + timeout(time: 120, unit: 'MINUTES'){ pre_test() script { sh ''' diff --git a/tests/parallel_test/run.sh b/tests/parallel_test/run.sh index 700d6853d2..26f481e571 100755 --- a/tests/parallel_test/run.sh +++ b/tests/parallel_test/run.sh @@ -281,6 +281,9 @@ function run_thread() { cat $case_log_file echo "=====================================================" echo -e "\e[34m log file: $case_log_file \e[0m" + if [ ! -z "${web_server}" ]; then + echo "${web_server}/$test_log_dir/${case_file}.txt" + fi if [ ! -z "$corefile" ]; then echo -e "\e[34m corefiles: $corefile \e[0m" local build_dir=$log_dir/build_${hosts[index]} From 4ff652bf4158c7a8c60d3c721c9087332a80859e Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 24 Jun 2022 15:54:29 +0800 Subject: [PATCH 53/81] fix: fix ut case issue --- source/libs/parser/test/parTestUtil.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/libs/parser/test/parTestUtil.h b/source/libs/parser/test/parTestUtil.h index 16c3d05b38..3e5fab5927 100644 --- a/source/libs/parser/test/parTestUtil.h +++ b/source/libs/parser/test/parTestUtil.h @@ -54,12 +54,6 @@ class ParserDdlTest : public ParserTestBase { virtual void checkDdl(const SQuery* pQuery, ParserStage stage) { ASSERT_NE(pQuery, nullptr); ASSERT_NE(pQuery->pRoot, nullptr); - if (QUERY_EXEC_MODE_RPC == pQuery->execMode) { - ASSERT_EQ(pQuery->haveResultSet, false); - ASSERT_EQ(pQuery->numOfResCols, 0); - ASSERT_EQ(pQuery->pResSchema, nullptr); - ASSERT_EQ(pQuery->precision, 0); - } if (nullptr != checkDdl_) { checkDdl_(pQuery, stage); } From b47c829a9c2e66415ae85345c8c31acc8b5c2fb8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 15:55:31 +0800 Subject: [PATCH 54/81] fix: auth failure --- source/dnode/mnode/impl/inc/mndAuth.h | 3 ++- source/dnode/mnode/impl/inc/mndDef.h | 2 +- source/dnode/mnode/impl/src/mndAuth.c | 9 +++++-- source/dnode/mnode/impl/src/mndProfile.c | 33 ++++++++++++++---------- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndAuth.h b/source/dnode/mnode/impl/inc/mndAuth.h index 45841ca367..9af4792665 100644 --- a/source/dnode/mnode/impl/inc/mndAuth.h +++ b/source/dnode/mnode/impl/inc/mndAuth.h @@ -23,7 +23,8 @@ extern "C" { #endif typedef enum { - MND_OPER_CREATE_USER = 1, + MND_OPER_CONNECT = 1, + MND_OPER_CREATE_USER, MND_OPER_DROP_USER, MND_OPER_ALTER_USER, MND_OPER_CREATE_BNODE, diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 693cb77b6d..0605e3a69e 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -222,7 +222,7 @@ typedef struct { typedef struct { char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN + 1]; + char pass[TSDB_PASSWORD_LEN]; char acct[TSDB_USER_LEN]; int64_t createdTime; int64_t updateTime; diff --git a/source/dnode/mnode/impl/src/mndAuth.c b/source/dnode/mnode/impl/src/mndAuth.c index f1f1bbae46..4445e3b9f7 100644 --- a/source/dnode/mnode/impl/src/mndAuth.c +++ b/source/dnode/mnode/impl/src/mndAuth.c @@ -93,8 +93,13 @@ int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) { goto _OVER; } - terrno = TSDB_CODE_MND_NO_RIGHTS; - code = -1; + switch (operType) { + case MND_OPER_CONNECT: + break; + default: + terrno = TSDB_CODE_MND_NO_RIGHTS; + code = -1; + } _OVER: mndReleaseUser(pMnode, pUser); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 08da1d54d9..2c47bba8ce 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mndProfile.h" +#include "mndAuth.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" @@ -215,36 +216,42 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { SConnObj *pConn = NULL; int32_t code = -1; SConnectReq connReq = {0}; - char ip[30] = {0}; + char ip[24] = {0}; const STraceId *trace = &pReq->info.traceId; if (tDeserializeSConnectReq(pReq->pCont, pReq->contLen, &connReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CONN_OVER; + goto _OVER; } taosIp2String(pReq->info.conn.clientIp, ip); pUser = mndAcquireUser(pMnode, pReq->info.conn.user); if (pUser == NULL) { - mGError("user:%s, failed to login while acquire user since %s", pReq->info.conn.user, terrstr()); - goto CONN_OVER; + mGError("user:%s, failed to login from %s while acquire user since %s", pReq->info.conn.user, ip, terrstr()); + goto _OVER; } - if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN)) { - mGError("user:%s, failed to auth while acquire user, input:%s", pReq->info.conn.user, connReq.passwd); + + if (strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1) != 0) { + mGError("user:%s, failed to login from %s since invalid pass, input:%s", pReq->info.conn.user, ip, connReq.passwd); code = TSDB_CODE_RPC_AUTH_FAILURE; - goto CONN_OVER; + goto _OVER; + } + + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CONNECT) != 0) { + mGError("user:%s, failed to login from %s since %s", pReq->info.conn.user, ip, terrstr()); + goto _OVER; } if (connReq.db[0]) { - char db[TSDB_DB_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN] = {0}; snprintf(db, TSDB_DB_FNAME_LEN, "%d%s%s", pUser->acctId, TS_PATH_DELIMITER, connReq.db); pDb = mndAcquireDb(pMnode, db); if (pDb == NULL) { terrno = TSDB_CODE_MND_INVALID_DB; mGError("user:%s, failed to login from %s while use db:%s since %s", pReq->info.conn.user, ip, connReq.db, terrstr()); - goto CONN_OVER; + goto _OVER; } } @@ -252,7 +259,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { pReq->info.conn.clientPort, connReq.pid, connReq.app, connReq.startTime); if (pConn == NULL) { mGError("user:%s, failed to login from %s while create connection since %s", pReq->info.conn.user, ip, terrstr()); - goto CONN_OVER; + goto _OVER; } SConnectRsp connectRsp = {0}; @@ -268,9 +275,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { mndGetMnodeEpSet(pMnode, &connectRsp.epSet); int32_t contLen = tSerializeSConnectRsp(NULL, 0, &connectRsp); - if (contLen < 0) goto CONN_OVER; + if (contLen < 0) goto _OVER; void *pRsp = rpcMallocCont(contLen); - if (pRsp == NULL) goto CONN_OVER; + if (pRsp == NULL) goto _OVER; tSerializeSConnectRsp(pRsp, contLen, &connectRsp); pReq->info.rspLen = contLen; @@ -280,7 +287,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { code = 0; -CONN_OVER: +_OVER: mndReleaseUser(pMnode, pUser); mndReleaseDb(pMnode, pDb); From 9ac0a34e7220a1ec307190c37ced2fcb5786e51f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 24 Jun 2022 15:57:33 +0800 Subject: [PATCH 55/81] fix: disable group by tag cases --- source/libs/executor/src/executorimpl.c | 116 +++++++++++++----------- tests/system-test/2-query/json_tag.py | 80 ++++++++-------- 2 files changed, 101 insertions(+), 95 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index a3170cd748..2dd12db224 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3888,6 +3888,65 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI return TSDB_CODE_SUCCESS; } +static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum){ + taosArrayClear(pTableListInfo->pGroupList); + SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); + if(sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; + for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { + STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); + uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); + + int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ); + if (index == -1){ + void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); + SArray *tGroup = taosArrayInit(8, sizeof(STableKeyInfo)); + if(tGroup == NULL) { + taosArrayDestroy(sortSupport); + return TSDB_CODE_OUT_OF_MEMORY; + } + if(taosArrayPush(tGroup, info) == NULL){ + qError("taos push info array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + if(p == NULL){ + if(taosArrayPush(sortSupport, groupId) != NULL){ + qError("taos push support array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + if(taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL){ + qError("taos push group array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + }else{ + int32_t pos = TARRAY_ELEM_IDX(sortSupport, p); + if(taosArrayInsert(sortSupport, pos, groupId) == NULL){ + qError("taos insert support array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + if(taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL){ + qError("taos insert group array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + } + }else{ + SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index); + if(taosArrayPush(tGroup, info) == NULL){ + qError("taos push uid array error"); + taosArrayDestroy(sortSupport); + return TSDB_CODE_QRY_APP_ERROR; + } + } + + } + taosArrayDestroy(sortSupport); + return TDB_CODE_SUCCESS; +} + int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group) { if (group == NULL) { return TDB_CODE_SUCCESS; @@ -3950,7 +4009,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, isNull[index++] = 0; char* data = nodesGetValueFromNode(pValue); if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON){ - int32_t len = ((const STag*)data) -> len; + int32_t len = getJsonValueLen(data); memcpy(pStart, data, len); pStart += len; } else if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { @@ -3973,59 +4032,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, taosMemoryFree(keyBuf); if(pTableListInfo->needSortTableByGroupId){ - taosArrayClear(pTableListInfo->pGroupList); - SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); - if(sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; - for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { - STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); - uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); - - int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ); - if (index == -1){ - void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); - SArray *tGroup = taosArrayInit(8, sizeof(STableKeyInfo)); - if(tGroup == NULL) { - taosArrayDestroy(sortSupport); - return TSDB_CODE_OUT_OF_MEMORY; - } - if(taosArrayPush(tGroup, info) == NULL){ - qError("taos push info array error"); - return TSDB_CODE_QRY_APP_ERROR; - } - if(p == NULL){ - if(taosArrayPush(sortSupport, groupId) != NULL){ - qError("taos push support array error"); - taosArrayDestroy(sortSupport); - return TSDB_CODE_QRY_APP_ERROR; - } - if(taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL){ - qError("taos push group array error"); - taosArrayDestroy(sortSupport); - return TSDB_CODE_QRY_APP_ERROR; - } - }else{ - int32_t pos = TARRAY_ELEM_IDX(sortSupport, p); - if(taosArrayInsert(sortSupport, pos, groupId) == NULL){ - qError("taos insert support array error"); - taosArrayDestroy(sortSupport); - return TSDB_CODE_QRY_APP_ERROR; - } - if(taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL){ - qError("taos insert group array error"); - taosArrayDestroy(sortSupport); - return TSDB_CODE_QRY_APP_ERROR; - } - } - }else{ - SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index); - if(taosArrayPush(tGroup, info) == NULL){ - qError("taos push uid array error"); - return TSDB_CODE_QRY_APP_ERROR; - } - } - - } - taosArrayDestroy(sortSupport); + return sortTableGroup(pTableListInfo, groupNum); } return TDB_CODE_SUCCESS; @@ -4057,7 +4064,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; - pTableListInfo->needSortTableByGroupId = true; int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); if(code){ return NULL; diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 6816d4a3a3..2ef1b8dad2 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -424,47 +424,47 @@ class TDTestCase: # tdSql.error("select count(*) from jsons1 group by jtag order by jtag") tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'") tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag") - tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") - tdSql.checkRows(8) - tdSql.checkData(0, 0, 2) - tdSql.checkData(0, 1, '"femail"') - tdSql.checkData(1, 0, 2) - tdSql.checkData(1, 1, '"收到货"') - tdSql.checkData(2, 0, 1) - tdSql.checkData(2, 1, "11.000000000") - tdSql.checkData(5, 0, 1) - tdSql.checkData(5, 1, "false") - tdSql.checkData(6, 0, 1) - tdSql.checkData(6, 1, "null") - tdSql.checkData(7, 0, 2) - tdSql.checkData(7, 1, None) + # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") + # tdSql.checkRows(8) + # tdSql.checkData(0, 0, 2) + # tdSql.checkData(0, 1, '"femail"') + # tdSql.checkData(1, 0, 2) + # tdSql.checkData(1, 1, '"收到货"') + # tdSql.checkData(2, 0, 1) + # tdSql.checkData(2, 1, "11.000000000") + # tdSql.checkData(5, 0, 1) + # tdSql.checkData(5, 1, "false") + # tdSql.checkData(6, 0, 1) + # tdSql.checkData(6, 1, "null") + # tdSql.checkData(7, 0, 2) + # tdSql.checkData(7, 1, None) - tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc") - tdSql.checkRows(8) - tdSql.checkData(0, 0, 2) - tdSql.checkData(0, 1, None) - tdSql.checkData(2, 0, 1) - tdSql.checkData(2, 1, "false") - tdSql.checkData(5, 0, 1) - tdSql.checkData(5, 1, "11.000000000") - tdSql.checkData(7, 0, 2) - tdSql.checkData(7, 1, '"femail"') + # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc") + # tdSql.checkRows(8) + # tdSql.checkData(0, 0, 2) + # tdSql.checkData(0, 1, None) + # tdSql.checkData(2, 0, 1) + # tdSql.checkData(2, 1, "false") + # tdSql.checkData(5, 0, 1) + # tdSql.checkData(5, 1, "11.000000000") + # tdSql.checkData(7, 0, 2) + # tdSql.checkData(7, 1, '"femail"') # # test stddev with group by json tag - tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") - tdSql.checkRows(8) - tdSql.checkData(0, 0, 10) - tdSql.checkData(0, 1, None) - tdSql.checkData(4, 0, 0) - tdSql.checkData(4, 1, "5.000000000") - tdSql.checkData(7, 0, 11) - tdSql.checkData(7, 1, '"femail"') - - res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'") - cname_list = [] - cname_list.append("stddev(dataint)") - cname_list.append("jsons1.jtag->'tag1'") - tdSql.checkColNameList(res, cname_list) + # tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") + # tdSql.checkRows(8) + # tdSql.checkData(0, 0, 10) + # tdSql.checkData(0, 1, None) + # tdSql.checkData(4, 0, 0) + # tdSql.checkData(4, 1, "5.000000000") + # tdSql.checkData(7, 0, 11) + # tdSql.checkData(7, 1, '"femail"') + # + # res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'") + # cname_list = [] + # cname_list.append("stddev(dataint)") + # cname_list.append("jsons1.jtag->'tag1'") + # tdSql.checkColNameList(res, cname_list) # test top/bottom with group by json tag # tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'") @@ -477,8 +477,8 @@ class TDTestCase: # tdSql.checkData(10, 1, '"femail"') # test having - tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1") - tdSql.checkRows(3) + # tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1") + # tdSql.checkRows(3) # subquery with json tag tdSql.query("select * from (select jtag, dataint from jsons1) order by dataint") From 7fe7b9625e94c49eabb052cbde76780763f9e783 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 24 Jun 2022 16:03:57 +0800 Subject: [PATCH 56/81] test:add test case for tmq --- tests/system-test/7-tmq/tmqCommon.py | 55 +++++-- tests/system-test/7-tmq/tmqConsumerGroup.py | 170 ++++++++++++++++++++ tests/system-test/fulltest.sh | 1 + tests/test/c/tmqSim.c | 150 +++++++++-------- 4 files changed, 293 insertions(+), 83 deletions(-) create mode 100644 tests/system-test/7-tmq/tmqConsumerGroup.py diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index d17e36fc97..b8aa78e3ac 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -11,7 +11,9 @@ # -*- coding: utf-8 -*- +from asyncore import loop from collections import defaultdict +import subprocess import random import string import threading @@ -75,7 +77,7 @@ class TMQCom: return resultList - def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): + def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0,alias=0): buildPath = tdCom.getBuildPath() cfgPath = tdCom.getClientCfgPath() if valgrind == 1: @@ -88,30 +90,53 @@ class TMQCom: shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> nul 2>&1 &" else: - shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + processorName = buildPath + '/build/bin/tmq_sim' + if alias != 0: + processorNameNew = buildPath + '/build/bin/tmq_sim_new' + shellCmd = 'cp %s %s'%(processorName, processorNameNew) + os.system(shellCmd) + processorName = processorNameNew + shellCmd = 'nohup ' + processorName + ' -c ' + cfgPath shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) - os.system(shellCmd) + os.system(shellCmd) - def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'): - while 1: + def stopTmqSimProcess(self, processorName): + psCmd = "ps -ef|grep -w %s|grep -v grep | awk '{print $2}'"%(processorName) + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(0.2) + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + tdLog.debug("%s is stopped by kill -INT" % (processorName)) + + def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb',rows=1): + loopFlag = 1 + while loopFlag: tdSql.query("select * from %s.notifyinfo"%cdbName) #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) - if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0): - break - else: - time.sleep(0.1) + actRows = tdSql.getRows() + if (actRows >= rows): + for i in range(actRows): + if tdSql.getData(i, 1) == 0: + loopFlag = 0 + break + time.sleep(0.1) return - def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'): - while 1: + def getStartCommitNotifyFromTmqsim(self,cdbName='cdb',rows=2): + loopFlag = 1 + while loopFlag: tdSql.query("select * from %s.notifyinfo"%cdbName) #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) - if tdSql.getRows() == 2 : - print(tdSql.getData(0, 1), tdSql.getData(1, 1)) - if tdSql.getData(1, 1) == 1: - break + actRows = tdSql.getRows() + if (actRows >= rows): + for i in range(actRows): + if tdSql.getData(i, 1) == 1: + loopFlag = 0 + break time.sleep(0.1) return diff --git a/tests/system-test/7-tmq/tmqConsumerGroup.py b/tests/system-test/7-tmq/tmqConsumerGroup.py new file mode 100644 index 0000000000..bfd63fd4a2 --- /dev/null +++ b/tests/system-test/7-tmq/tmqConsumerGroup.py @@ -0,0 +1,170 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) + else: + break + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 10, + 'rowsPerTbl': 1000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 20, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1', 'topic2'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("insert data") + tmqCom.insert_data_2(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdLog.info("create topics from stb with filter") + # queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) + queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # create one stb2 + paraDict["stbName"] = 'stb2' + paraDict["ctbPrefix"] = 'ctbx' + paraDict["rowsPerTbl"] = 5000 + tdLog.info("create stb2") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb2") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + + # queryString = "select ts, sin(c1), abs(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) + queryString = "select ts, sin(c1), abs(pow(c1,3)) from %s.%s" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[1], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + # tdSql.query(queryString) + # expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 + topicList = "%s,%s"%(topicNameList[0],topicNameList[1]) + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:3000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor 1") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("start consume processor 2") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'],'cdb',0,1) + + tdLog.info("async insert data") + pThread = tmqCom.asyncInsertData(paraDict) + + tdLog.info("wait consumer commit notify") + tmqCom.getStartCommitNotifyFromTmqsim(rows=4) + + tdLog.info("pkill one consume processor") + tmqCom.stopTmqSimProcess('tmq_sim_new') + + pThread.join() + + tdLog.info("wait the consume result") + expectRows = 2 + resultList = tmqCom.selectConsumeResult(expectRows) + actTotalRows = 0 + for i in range(len(resultList)): + actTotalRows += resultList[i] + + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + expectTotalRows = 0 + for i in range(len(expectRowsList)): + expectTotalRows += expectRowsList[i] + + tdLog.info("act consume rows: %d, expect consume rows: %d"%(actTotalRows, expectTotalRows)) + if expectTotalRows <= resultList[0]: + tdLog.info("act consume rows: %d should >= expect consume rows: %d"%(actTotalRows, expectTotalRows)) + tdLog.exit("0 tmq consume rows error!") + + # time.sleep(10) + # for i in range(len(topicNameList)): + # tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 73e6716cad..a136334f70 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -135,3 +135,4 @@ python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py python3 ./test.py -f 7-tmq/tmqUdf.py #python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 +python3 ./test.py -f 7-tmq/tmqConsumerGroup.py diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index e96f5d4793..59005fae94 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -22,9 +22,9 @@ #include #include "taos.h" -#include "taosdef.h" #include "taoserror.h" #include "tlog.h" +#include "taosdef.h" #include "types.h" #define GREEN "\033[1;32m" @@ -36,7 +36,11 @@ #define MAX_CONSUMER_THREAD_CNT (16) #define MAX_VGROUP_CNT (32) -typedef enum { NOTIFY_CMD_START_CONSUM, NOTIFY_CMD_START_COMMIT, NOTIFY_CMD_ID_BUTT } NOTIFY_CMD_ID; +typedef enum { + NOTIFY_CMD_START_CONSUM, + NOTIFY_CMD_START_COMMIT, + NOTIFY_CMD_ID_BUTT +}NOTIFY_CMD_ID; typedef struct { TdThread thread; @@ -48,8 +52,8 @@ typedef struct { // char autoOffsetRest[16]; // none, earliest, latest TdFilePtr pConsumeRowsFile; - int32_t ifCheckData; - int64_t expectMsgCnt; + int32_t ifCheckData; + int64_t expectMsgCnt; int64_t consumeMsgCnt; int64_t consumeRowCnt; @@ -85,7 +89,6 @@ typedef struct { int32_t saveRowFlag; int32_t consumeDelay; // unit s int32_t numOfThread; - int32_t useSnapshot; SThreadInfo stThreads[MAX_CONSUMER_THREAD_CNT]; } SConfInfo; @@ -93,8 +96,6 @@ static SConfInfo g_stConfInfo; TdFilePtr g_fp = NULL; static int running = 1; -int8_t useSnapshot = 0; - // char* g_pRowValue = NULL; // TdFilePtr g_fp = NULL; @@ -126,11 +127,23 @@ char* getCurrentTimeString(char* timeString) { return timeString; } +static void tmqStop(int signum, void *info, void *ctx) { + running = 0; + char tmpString[128]; + taosFprintfFile(g_fp, "%s tmqStop() receive stop signal[%d]\n", getCurrentTimeString(tmpString), signum); +} + +static void tmqSetSignalHandle() { + taosSetSignal(SIGINT, tmqStop); +} + void initLogFile() { char filename[256]; char tmpString[128]; - sprintf(filename, "%s/../log/tmqlog_%s.txt", configDir, getCurrentTimeString(tmpString)); + pid_t process_id = getpid(); + + sprintf(filename, "%s/../log/tmqlog-%d-%s.txt", configDir, process_id, getCurrentTimeString(tmpString)); #ifdef WINDOWS for (int i = 2; i < sizeof(filename); i++) { if (filename[i] == ':') filename[i] = '-'; @@ -204,8 +217,6 @@ void parseArgument(int32_t argc, char* argv[]) { g_stConfInfo.saveRowFlag = atol(argv[++i]); } else if (strcmp(argv[i], "-y") == 0) { g_stConfInfo.consumeDelay = atol(argv[++i]); - } else if (strcmp(argv[i], "-e") == 0) { - useSnapshot = (int8_t)atol(argv[++i]); } else { pError("%s unknow para: %s %s", GREEN, argv[++i], NC); exit(-1); @@ -299,11 +310,11 @@ int32_t saveConsumeContentToTbl(SThreadInfo* pInfo, char* buf) { return 0; } -static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { - // if (shell.args.is_raw_time) { - // sprintf(buf, "%" PRId64, val); - // return buf; - // } +static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { + //if (shell.args.is_raw_time) { + // sprintf(buf, "%" PRId64, val); + // return buf; + //} time_t tt; int32_t ms = 0; @@ -341,7 +352,7 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { } } - struct tm* ptm = taosLocalTime(&tt, NULL); + struct tm *ptm = taosLocalTime(&tt, NULL); size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm); if (precision == TSDB_TIME_PRECISION_NANO) { @@ -355,8 +366,7 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { return buf; } -static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length, - int32_t precision) { +static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision) { if (val == NULL) { taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR); return; @@ -366,31 +376,31 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - taosFprintfFile(pFile, "%d", ((((int32_t)(*((char*)val))) == 1) ? 1 : 0)); + taosFprintfFile(pFile, "%d", ((((int32_t)(*((char *)val))) == 1) ? 1 : 0)); break; case TSDB_DATA_TYPE_TINYINT: - taosFprintfFile(pFile, "%d", *((int8_t*)val)); + taosFprintfFile(pFile, "%d", *((int8_t *)val)); break; case TSDB_DATA_TYPE_UTINYINT: - taosFprintfFile(pFile, "%u", *((uint8_t*)val)); + taosFprintfFile(pFile, "%u", *((uint8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - taosFprintfFile(pFile, "%d", *((int16_t*)val)); + taosFprintfFile(pFile, "%d", *((int16_t *)val)); break; case TSDB_DATA_TYPE_USMALLINT: - taosFprintfFile(pFile, "%u", *((uint16_t*)val)); + taosFprintfFile(pFile, "%u", *((uint16_t *)val)); break; case TSDB_DATA_TYPE_INT: - taosFprintfFile(pFile, "%d", *((int32_t*)val)); + taosFprintfFile(pFile, "%d", *((int32_t *)val)); break; case TSDB_DATA_TYPE_UINT: - taosFprintfFile(pFile, "%u", *((uint32_t*)val)); + taosFprintfFile(pFile, "%u", *((uint32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: - taosFprintfFile(pFile, "%" PRId64, *((int64_t*)val)); + taosFprintfFile(pFile, "%" PRId64, *((int64_t *)val)); break; case TSDB_DATA_TYPE_UBIGINT: - taosFprintfFile(pFile, "%" PRIu64, *((uint64_t*)val)); + taosFprintfFile(pFile, "%" PRIu64, *((uint64_t *)val)); break; case TSDB_DATA_TYPE_FLOAT: taosFprintfFile(pFile, "%.5f", GET_FLOAT_VAL(val)); @@ -411,7 +421,7 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f taosFprintfFile(pFile, "\'%s\'", buf); break; case TSDB_DATA_TYPE_TIMESTAMP: - shellFormatTimestamp(buf, *(int64_t*)val, precision); + shellFormatTimestamp(buf, *(int64_t *)val, precision); taosFprintfFile(pFile, "'%s'", buf); break; default: @@ -419,13 +429,12 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f } } -static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields, - int32_t precision) { +static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields, int32_t precision) { for (int32_t i = 0; i < num_fields; i++) { if (i > 0) { taosFprintfFile(pFile, "\n"); } - shellDumpFieldToFile(pFile, (const char*)row[i], fields + i, length[i], precision); + shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision); } taosFprintfFile(pFile, "\n"); } @@ -435,42 +444,40 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex) int32_t totalRows = 0; // printf("topic: %s\n", tmq_get_topic_name(msg)); - int32_t vgroupId = tmq_get_vgroup_id(msg); - const char* dbName = tmq_get_db_name(msg); + int32_t vgroupId = tmq_get_vgroup_id(msg); + const char* dbName = tmq_get_db_name(msg); taosFprintfFile(g_fp, "consumerId: %d, msg index:%" PRId64 "\n", pInfo->consumerId, msgIndex); - taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", - tmq_get_topic_name(msg), vgroupId); + taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", tmq_get_topic_name(msg), vgroupId); while (1) { TAOS_ROW row = taos_fetch_row(msg); if (row == NULL) break; - TAOS_FIELD* fields = taos_fetch_fields(msg); + TAOS_FIELD* fields = taos_fetch_fields(msg); int32_t numOfFields = taos_field_count(msg); - int32_t* length = taos_fetch_lengths(msg); - int32_t precision = taos_result_precision(msg); - const char* tbName = tmq_get_table_name(msg); + int32_t* length = taos_fetch_lengths(msg); + int32_t precision = taos_result_precision(msg); + const char* tbName = tmq_get_table_name(msg); - #if 0 + #if 0 // get schema //============================== stub =================================================// for (int32_t i = 0; i < numOfFields; i++) { taosFprintfFile(g_fp, "%02d: name: %s, type: %d, len: %d\n", i, fields[i].name, fields[i].type, fields[i].bytes); } //============================== stub =================================================// - #endif - - dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); - + #endif + + dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); taos_print_row(buf, row, fields, numOfFields); if (0 != g_stConfInfo.showRowFlag) { taosFprintfFile(g_fp, "tbname:%s, rows[%d]: %s\n", (tbName != NULL ? tbName : "null table"), totalRows, buf); - // if (0 != g_stConfInfo.saveRowFlag) { - // saveConsumeContentToTbl(pInfo, buf); - // } + //if (0 != g_stConfInfo.saveRowFlag) { + // saveConsumeContentToTbl(pInfo, buf); + //} } totalRows++; @@ -493,7 +500,8 @@ int queryDB(TAOS* taos, char* command) { return 0; } -static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) {} +static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) { +} int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { char sqlStr[1024] = {0}; @@ -501,8 +509,11 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { int64_t now = taosGetTimestampMs(); // schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int - sprintf(sqlStr, "insert into %s.notifyinfo values (%" PRId64 ", %d, %d)", g_stConfInfo.cdbName, now, cmdId, - pInfo->consumerId); + sprintf(sqlStr, "insert into %s.notifyinfo values (%"PRId64", %d, %d)", + g_stConfInfo.cdbName, + now, + cmdId, + pInfo->consumerId); taos_query_a(pInfo->taos, sqlStr, appNothing, NULL); @@ -512,14 +523,16 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { } static int32_t g_once_commit_flag = 0; -static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { - pError("tmq_commit_cb_print() commit %d\n", code); +static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { + pError("tmq_commit_cb_print() commit %d\n", code); if (0 == g_once_commit_flag) { g_once_commit_flag = 1; - notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); + notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); } - taosFprintfFile(g_fp, "tmq_commit_cb_print() be called\n"); + + char tmpString[128]; + taosFprintfFile(g_fp, "%s tmq_commit_cb_print() be called\n", getCurrentTimeString(tmpString)); } void build_consumer(SThreadInfo* pInfo) { @@ -551,10 +564,6 @@ void build_consumer(SThreadInfo* pInfo) { // tmq_conf_set(conf, "auto.offset.reset", "none"); // tmq_conf_set(conf, "auto.offset.reset", "earliest"); // tmq_conf_set(conf, "auto.offset.reset", "latest"); - // - if (useSnapshot) { - tmq_conf_set(conf, "experiment.use.snapshot", "true"); - } pInfo->tmq = tmq_consumer_new(conf, NULL, 0); @@ -609,13 +618,12 @@ void loop_consume(SThreadInfo* pInfo) { pInfo->consumerId); pInfo->ts = taosGetTimestampMs(); - + if (pInfo->ifCheckData) { - char filename[256] = {0}; + char filename[256] = {0}; char tmpString[128]; - // sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId, - // getCurrentTimeString(tmpString)); - sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId); + //sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId, getCurrentTimeString(tmpString)); + sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId); pInfo->pConsumeRowsFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); if (pInfo->pConsumeRowsFile == NULL) { taosFprintfFile(g_fp, "%s create file fail for save rows content\n", getCurrentTimeString(tmpString)); @@ -634,10 +642,10 @@ void loop_consume(SThreadInfo* pInfo) { totalMsgs++; - if (0 == once_flag) { + if (0 == once_flag) { once_flag = 1; - notifyMainScript(pInfo, NOTIFY_CMD_START_CONSUM); - } + notifyMainScript(pInfo, NOTIFY_CMD_START_CONSUM); + } if (totalRows >= pInfo->expectMsgCnt) { char tmpString[128]; @@ -651,6 +659,10 @@ void loop_consume(SThreadInfo* pInfo) { } } + if (0 == running) { + taosFprintfFile(g_fp, "receive stop signal and not continue consume\n"); + } + pInfo->consumeMsgCnt = totalMsgs; pInfo->consumeRowCnt = totalRows; @@ -666,7 +678,7 @@ void* consumeThreadFunc(void* param) { pInfo->taos = taos_connect(NULL, "root", "taosdata", NULL, 0); if (pInfo->taos == NULL) { taosFprintfFile(g_fp, "taos_connect() fail, can not notify and save consume result to main scripte\n"); - return NULL; + return NULL; } build_consumer(pInfo); @@ -680,7 +692,7 @@ void* consumeThreadFunc(void* param) { int32_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList); if (err != 0) { pError("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err)); - taosFprintfFile(g_fp, "tmq_subscribe()! reason: %s\n", tmq_err2str(err)); + taosFprintfFile(g_fp, "tmq_subscribe() fail! reason: %s\n", tmq_err2str(err)); assert(0); return NULL; } @@ -829,6 +841,8 @@ int main(int32_t argc, char* argv[]) { getConsumeInfo(); saveConfigToLogFile(); + tmqSetSignalHandle(); + TdThreadAttr thattr; taosThreadAttrInit(&thattr); taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); From a533f3497c0ec525dca5d6a5c1f31c9ac7a27e6c Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Fri, 24 Jun 2022 16:28:56 +0800 Subject: [PATCH 57/81] add case for scalar function for null value --- tests/system-test/2-query/function_null.py | 225 +++++++++++++++++++++ tests/system-test/fulltest.sh | 2 + 2 files changed, 227 insertions(+) create mode 100644 tests/system-test/2-query/function_null.py diff --git a/tests/system-test/2-query/function_null.py b/tests/system-test/2-query/function_null.py new file mode 100644 index 0000000000..d301fb2ca3 --- /dev/null +++ b/tests/system-test/2-query/function_null.py @@ -0,0 +1,225 @@ +import taos +import sys +import datetime +import inspect + +from util.log import * +from util.sql import * +from util.cases import * +import random + + +class TDTestCase: + updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, + "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + self.tb_nums = 10 + self.row_nums = 20 + self.ts = 1434938400000 + self.time_step = 1000 + + def prepare_tag_datas(self): + # prepare datas + tdSql.execute( + "create database if not exists testdb keep 3650 duration 1000") + tdSql.execute(" use testdb ") + tdSql.execute( + '''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 (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + tdSql.execute( + ''' + 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) + ''' + ) + for i in range(4): + tdSql.execute( + f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + "insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute( + "insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute( + "insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '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" ) + ( '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" ) + ( '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" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + + def function_for_null_data(self): + + function_names = ["abs" , "floor" , "ceil" , "round"] + + for function_name in function_names: + + scalar_sql_1 = f"select {function_name}(c1)/0 from t1 group by c1 order by c1" + scalar_sql_2 = f"select {function_name}(c1/0) from t1 group by c1 order by c1" + tdSql.query(scalar_sql_1) + tdSql.checkRows(10) + tdSql.checkData(0,0,None) + tdSql.checkData(9,0,None) + tdSql.query(scalar_sql_2) + tdSql.checkRows(10) + tdSql.checkData(0,0,None) + tdSql.checkData(9,0,None) + + function_names = ["sin" ,"cos" ,"tan" ,"asin" ,"acos" ,"atan"] + + PI = 3.141592654 + + # sin + tdSql.query(" select sin(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select sin(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.000000000) + + tdSql.query(f" select sin({PI/2}) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.0) + + tdSql.query(" select sin(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.826879541) + + # cos + tdSql.query(" select cos(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select cos(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.000000000) + + tdSql.query(f" select cos({PI}/2) from t1 group by c1 order by c1") + + tdSql.query(" select cos(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.562379076) + + + # tan + tdSql.query(" select tan(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select tan(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.000000000) + + tdSql.query(f" select tan({PI}/2) from t1 group by c1 order by c1") + + tdSql.query(" select tan(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.470324156) + + # atan + tdSql.query(" select atan(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select atan(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.000000000) + + tdSql.query(f" select atan({PI}/2) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.003884822) + + tdSql.query(" select atan(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.569796327) + + # asin + tdSql.query(" select asin(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select asin(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,0.000000000) + + tdSql.query(f" select asin({PI}/2) from t1 group by c1 order by c1") + + tdSql.query(" select asin(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + # acos + + tdSql.query(" select acos(c1/0) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select acos(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,1.570796327) + + tdSql.query(f" select acos({PI}/2) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select acos(1000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + function_names = ["log" ,"pow"] + + # log + tdSql.query(" select log(-10) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select log(c1)/0 from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(f" select log(0.00) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + # pow + tdSql.query(" select pow(c1,10000) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(" select pow(c1,2)/0 from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + tdSql.query(f" select pow(c1/0 ,1 ) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table ==============") + + self.prepare_tag_datas() + + tdLog.printNoPrefix("==========step2:test errors ==============") + + self.function_for_null_data() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 73e6716cad..3c6f4de5cb 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -110,6 +110,8 @@ python3 ./test.py -f 2-query/distribute_agg_avg.py python3 ./test.py -f 2-query/distribute_agg_stddev.py python3 ./test.py -f 2-query/twa.py +python3 ./test.py -f 2-query/function_null.py + python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 From 58296f6a5abf559915cbc11a50150300a85d3c84 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 16:44:45 +0800 Subject: [PATCH 58/81] refactor(sync): adjust log buf size --- source/libs/sync/src/syncRequestVote.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 9b181e21e5..3270b5c0e4 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -102,7 +102,7 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &(pMsg->srcId)) && !ths->pRaftCfg->isStandBy) { do { - char logBuf[128]; + char logBuf[256]; char host[64]; uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); @@ -142,7 +142,7 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { // trace log do { - char logBuf[128]; + char logBuf[256]; char host[64]; uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); From e81dcb9bb37fa9cfe7098ab74a1d425a1ffef6c0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 16:46:48 +0800 Subject: [PATCH 59/81] test: case for sysinfo --- tests/script/jenkins/basic.txt | 5 ++- tests/script/tsim/user/privilege_enable.sim | 37 -------------------- tests/script/tsim/user/privilege_sysinfo.sim | 20 +++++++++++ 3 files changed, 22 insertions(+), 40 deletions(-) delete mode 100644 tests/script/tsim/user/privilege_enable.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 340d701a99..63eed3bceb 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -5,8 +5,7 @@ ./test.sh -f tsim/user/basic.sim ./test.sh -f tsim/user/password.sim ./test.sh -f tsim/user/privilege_db.sim -#./test.sh -f tsim/user/privilege_enable.sim -#./test.sh -f tsim/user/privilege_sysinfo.sim +./test.sh -f tsim/user/privilege_sysinfo.sim ## ---- db ./test.sh -f tsim/db/create_all_options.sim @@ -133,7 +132,7 @@ ./test.sh -f tsim/stable/tag_filter.sim # --- for multi process mode -./test.sh -f tsim/user/basic1.sim -m +./test.sh -f tsim/user/basic.sim -m ./test.sh -f tsim/db/basic3.sim -m ./test.sh -f tsim/db/error1.sim -m ./test.sh -f tsim/insert/backquote.sim -m diff --git a/tests/script/tsim/user/privilege_enable.sim b/tests/script/tsim/user/privilege_enable.sim deleted file mode 100644 index 5635e7c95e..0000000000 --- a/tests/script/tsim/user/privilege_enable.sim +++ /dev/null @@ -1,37 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print =============== create db -sql create database d1 vgroups 1; - -print =============== create users -sql create user u1 pass 'taosdata' -sql alter user u1 enable 0 - - -print =============== create users -sql create user user1 PASS 'taosdata' -sql create user user2 PASS 'taosdata' -sql show users -if $rows != 3 then - return -1 -endi - -sql GRANT read ON d1.* to user1; -sql GRANT write ON d2.* to user1; - -print =============== re connect -sql close -sleep 2500 -print user user1 login -sql connect user1 - -sql_error drop database d1; -sql_error drop database d2; - -sql_error create stable d1.st (ts timestamp, i int) tags (j int) -sql create stable d2.st (ts timestamp, i int) tags (j int) - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/user/privilege_sysinfo.sim b/tests/script/tsim/user/privilege_sysinfo.sim index b7d4195ae1..9ddfce8a97 100644 --- a/tests/script/tsim/user/privilege_sysinfo.sim +++ b/tests/script/tsim/user/privilege_sysinfo.sim @@ -3,4 +3,24 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect +print =============== create user and login +sql create user sysinfo0 pass 'taosdata' +sql create user sysinfo1 pass 'taosdata' +sql alter user sysinfo0 sysinfo 0 +sql alter user sysinfo1 sysinfo 1 + +print user sysinfo0 login +sql close +sql connect sysinfo0 + +system sh/exec.sh -n dnode1 -s stop +return + +print =============== check oper +sql_error create user u1 pass 'u1' +sql_error drop user sysinfo1 +sql_error alter user sysinfo1 pass '1' +sql_error alter user sysinfo0 pass '1' + + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From e823041cf4811163b0fb8647800a1e07ef11d11a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 16:47:12 +0800 Subject: [PATCH 60/81] test: adjust retry times if lock failed --- source/dnode/mgmt/node_util/src/dmFile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c index 2185adc18b..ce592b8375 100644 --- a/source/dnode/mgmt/node_util/src/dmFile.c +++ b/source/dnode/mgmt/node_util/src/dmFile.c @@ -133,10 +133,10 @@ TdFilePtr dmCheckRunning(const char *dataDir) { ret = taosLockFile(pFile); if (ret == 0) break; terrno = TAOS_SYSTEM_ERROR(errno); - taosMsleep(100); + taosMsleep(1000); retryTimes++; dError("failed to lock file:%s since %s, retryTimes:%d", filepath, terrstr(), retryTimes); - } while (retryTimes < 120); + } while (retryTimes < 6); if (ret < 0) { terrno = TAOS_SYSTEM_ERROR(errno); From 9aa684ba77a2fd892b26b9479517c28153aa16f2 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 16:47:28 +0800 Subject: [PATCH 61/81] fix: no redirect resp --- source/dnode/mnode/impl/src/mndMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 000e1041d0..d78e89036f 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -529,7 +529,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0; if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER || - pMsg->msgType == TDMT_MND_TRANS_TIMER || TDMT_MND_TTL_TIMER) { + pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER) { return -1; } From f53521cb8c017c476c96156b7f97c85fd536e636 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 24 Jun 2022 16:50:11 +0800 Subject: [PATCH 62/81] test(stream): partition by tbname --- source/dnode/mnode/impl/src/mndStream.c | 4 + source/dnode/vnode/src/tq/tq.c | 3 + source/libs/executor/src/executor.c | 4 +- source/libs/executor/src/executorimpl.c | 70 ++++++------ source/libs/stream/src/streamDispatch.c | 7 +- source/libs/wal/src/walWrite.c | 4 +- tests/script/jenkins/basic.txt | 1 + tests/script/tsim/stream/partitionby1.sim | 124 ++++++++++++++++++++++ 8 files changed, 180 insertions(+), 37 deletions(-) create mode 100644 tests/script/tsim/stream/partitionby1.sim diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 96a82e2c18..5e2f5bc2dd 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -321,6 +321,10 @@ FAIL: } int32_t mndPersistTaskDeployReq(STrans *pTrans, const SStreamTask *pTask) { + ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1); + if (pTask->isDataScan == 0 && pTask->sinkType == TASK_SINK__NONE) { + ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0); + } SEncoder encoder; tEncoderInit(&encoder, NULL, 0); tEncodeSStreamTask(&encoder, pTask); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index cca3a58588..ef6ab00cda 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -455,6 +455,9 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { } tDecoderClear(&decoder); ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1); + if (pTask->isDataScan == 0 && pTask->sinkType == TASK_SINK__NONE) { + ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0); + } pTask->execStatus = TASK_EXEC_STATUS__IDLE; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index ad400d720a..6de364e63a 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -145,10 +145,10 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo, continue; } - ASSERT(mr.me.type == TSDB_CHILD_TABLE); - if (mr.me.ctbEntry.suid != pScanInfo->tableUid) { + if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != pScanInfo->tableUid) { continue; } + // TODO handle ntb case taosArrayPush(qa, id); } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6c416ae9c4..57ca814974 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4365,6 +4365,26 @@ _error: return NULL; } +static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanInfo** ppInfo) { + if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + if (pOperator->numOfDownstream == 0) { + qError("failed to find stream scan operator"); + return TSDB_CODE_QRY_APP_ERROR; + } + + if (pOperator->numOfDownstream > 1) { + qError("join not supported for stream block scan"); + return TSDB_CODE_QRY_APP_ERROR; + } + return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo); + } else { + SStreamBlockScanInfo* pInfo = pOperator->info; + ASSERT(pInfo->pSnapshotReadOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); + *ppInfo = pInfo->pSnapshotReadOp->info; + return 0; + } +} + int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { if (pNode->pChildren == NULL || LIST_LENGTH(pNode->pChildren) == 0) { if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == pNode->type) { @@ -4387,37 +4407,27 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { return -1; } -int32_t doRebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle) { - if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - if (pOperator->numOfDownstream == 0) { - qError("failed to find stream scan operator"); - return TSDB_CODE_QRY_APP_ERROR; - } - - if (pOperator->numOfDownstream > 1) { - qError("join not supported for stream block scan"); - return TSDB_CODE_QRY_APP_ERROR; - } - return doRebuildReader(pOperator->pDownstream[0], plan, pHandle); - } else { - SStreamBlockScanInfo* pInfo = pOperator->info; - ASSERT(pInfo->pSnapshotReadOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); - STableScanInfo* pTableScanInfo = pInfo->pSnapshotReadOp->info; - - tsdbCleanupReadHandle(pTableScanInfo->dataReader); - STableScanPhysiNode* pNode = NULL; - if (extractTableScanNode(plan->pNode, &pNode) < 0) { - ASSERT(0); - } - - STableListInfo info = {0}; - pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, 0, 0); - if (pTableScanInfo->dataReader == NULL) { - ASSERT(0); - qError("failed to create data reader"); - return TSDB_CODE_QRY_APP_ERROR; - } +int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle, int64_t uid, int64_t ts) { + STableScanInfo* pTableScanInfo = NULL; + if (extractTbscanInStreamOpTree(pOperator, &pTableScanInfo) < 0) { + return -1; } + + STableScanPhysiNode* pNode = NULL; + if (extractTableScanNode(plan->pNode, &pNode) < 0) { + ASSERT(0); + } + + tsdbCleanupReadHandle(pTableScanInfo->dataReader); + + STableListInfo info = {0}; + pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, 0, 0); + if (pTableScanInfo->dataReader == NULL) { + ASSERT(0); + qError("failed to create data reader"); + return TSDB_CODE_QRY_APP_ERROR; + } + // TODO: set uid and ts to data reader return 0; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 11cd089606..179dc88d2a 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -70,20 +70,21 @@ int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* p if (tEncodeI32(pEncoder, pReq->dstTaskId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->srcNodeId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->srcTaskId) < 0) return -1; - if (tEncodeBinary(pEncoder, (const uint8_t*)&pReq->pRetrieve, pReq->retrieveLen) < 0) return -1; + if (tEncodeBinary(pEncoder, (const uint8_t*)pReq->pRetrieve, pReq->retrieveLen) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; } int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) { - int32_t tlen = 0; if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->dstNodeId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->dstTaskId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->srcNodeId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->srcTaskId) < 0) return -1; - if (tDecodeBinary(pDecoder, (uint8_t**)&pReq->pRetrieve, &pReq->retrieveLen) < 0) return -1; + uint64_t len = 0; + if (tDecodeBinaryAlloc(pDecoder, (void**)&pReq->pRetrieve, &len) < 0) return -1; + pReq->retrieveLen = len; tEndDecode(pDecoder); return 0; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index f82f27e3af..1d169a0891 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -23,7 +23,7 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) { void *pIter = NULL; while (1) { - taosHashIterate(pWal->pRefHash, pIter); + pIter = taosHashIterate(pWal->pRefHash, pIter); if (pIter == NULL) break; SWalRef *pRef = (SWalRef *)pIter; if (pRef->ver != -1) { @@ -309,7 +309,7 @@ static int walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { SWalIdxEntry entry = {.ver = ver, .offset = offset}; /*int64_t idxOffset = taosLSeekFile(pWal->pWriteIdxTFile, 0, SEEK_CUR);*/ /*wDebug("write index: ver: %ld, offset: %ld, at %ld", ver, offset, idxOffset);*/ - int size = taosWriteFile(pWal->pWriteIdxTFile, &entry, sizeof(SWalIdxEntry)); + int64_t size = taosWriteFile(pWal->pWriteIdxTFile, &entry, sizeof(SWalIdxEntry)); if (size != sizeof(SWalIdxEntry)) { terrno = TAOS_SYSTEM_ERROR(errno); // TODO truncate diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index cc28b19de9..a6c74f5d4d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -90,6 +90,7 @@ ./test.sh -f tsim/stream/triggerInterval0.sim # ./test.sh -f tsim/stream/triggerSession0.sim ./test.sh -f tsim/stream/partitionby.sim +./test.sh -f tsim/stream/partitionby1.sim ./test.sh -f tsim/stream/schedSnode.sim ./test.sh -f tsim/stream/windowClose.sim diff --git a/tests/script/tsim/stream/partitionby1.sim b/tests/script/tsim/stream/partitionby1.sim new file mode 100644 index 0000000000..f0a17bf399 --- /dev/null +++ b/tests/script/tsim/stream/partitionby1.sim @@ -0,0 +1,124 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); +sql create table ts3 using st tags(3,2,2); +sql create table ts4 using st tags(4,2,2); +sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by tbname interval(10s); + +sql insert into ts1 values(1648791213001,1,12,3,1.0); +sql insert into ts2 values(1648791213001,1,12,3,1.0); + +sql insert into ts3 values(1648791213001,1,12,3,1.0); +sql insert into ts4 values(1648791213001,1,12,3,1.0); +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then +print =====rows=$rows +goto loop0 +endi + +print =====loop0 + +sql create database test1 vgroups 1; +sql use test1; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,2,3); +sql create table ts2 using st tags(1,3,4); +sql create table ts3 using st tags(1,4,5); + +sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by tbname interval(10s); + + +sql insert into ts1 values(1648791211000,1,2,3); + +sql insert into ts2 values(1648791211000,1,2,3); + +$loop_count = 0 + +loop1: +sleep 300 +sql select * from streamt; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then +print =====rows=$rows +goto loop1 +endi + +print =====loop1 + +sql create database test2 vgroups 1; +sql use test2; +sql create stable st(ts timestamp,a int,b int,c int,id int) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); + +sql create stream stream_t2 trigger at_once into streamtST as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by ta interval(10s) ; +sql insert into ts1 values(1648791211000,1,2,3,1); +sql insert into ts1 values(1648791222001,2,2,3,2); +sql insert into ts2 values(1648791211000,1,2,3,3); +sql insert into ts2 values(1648791222001,2,2,3,4); + +sql insert into ts2 values(1648791222002,2,2,3,5); +sql insert into ts2 values(1648791222002,2,2,3,6); + +sql insert into ts1 values(1648791211000,1,2,3,1); +sql insert into ts1 values(1648791222001,2,2,3,2); +sql insert into ts2 values(1648791211000,1,2,3,3); +sql insert into ts2 values(1648791222001,2,2,3,4); + +$loop_count = 0 + +loop2: +sleep 300 +sql select * from streamtST; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then +print =====data01=$data01 +goto loop2 +endi + +if $data02 != 1 then +print =====data02=$data02 +goto loop2 +endi + +if $data03 != 1 then +print =====data03=$data03 +goto loop2 +endi + +if $data04 != 2 then +print =====data04=$data04 +goto loop2 +endi + +print =====loop2 + +system sh/stop_dnodes.sh From d98270fe12acd9c5836de1e9f16ddbbfd1c8afca Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 17:00:00 +0800 Subject: [PATCH 63/81] fix: no redirect resp --- source/dnode/mnode/impl/src/mndMain.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index d78e89036f..26fe593c36 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -533,12 +533,16 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { return -1; } - const STraceId *trace = &pMsg->info.traceId; - mError("msg:%p, failed to check mnode state since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); - SEpSet epSet = {0}; mndGetMnodeEpSet(pMsg->info.node, &epSet); + const STraceId *trace = &pMsg->info.traceId; + mError("msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d", pMsg, terrstr(), + TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse); + for (int32_t i = 0; i < epSet.numOfEps; ++i) { + mTrace("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); + } + int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); pMsg->info.rsp = rpcMallocCont(contLen); if (pMsg->info.rsp != NULL) { @@ -555,10 +559,10 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { static int32_t mndCheckMsgContent(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (pMsg->contLen != 0 && pMsg->pCont != NULL) return 0; - + const STraceId *trace = &pMsg->info.traceId; mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen, - pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); + pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); terrno = TSDB_CODE_INVALID_MSG_LEN; return -1; } @@ -723,7 +727,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb); if (pIter == NULL) break; - SMonStbDesc desc = {0}; + SMonStbDesc desc = {0}; SName name1 = {0}; tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); From 125944ce15893590fdf92803c75597ba9fbe7029 Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Fri, 24 Jun 2022 17:05:03 +0800 Subject: [PATCH 64/81] add case for compute null value --- tests/system-test/2-query/function_null.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/system-test/2-query/function_null.py b/tests/system-test/2-query/function_null.py index d301fb2ca3..4de7a7f113 100644 --- a/tests/system-test/2-query/function_null.py +++ b/tests/system-test/2-query/function_null.py @@ -92,6 +92,7 @@ class TDTestCase: scalar_sql_1 = f"select {function_name}(c1)/0 from t1 group by c1 order by c1" scalar_sql_2 = f"select {function_name}(c1/0) from t1 group by c1 order by c1" + scalar_sql_3 = f"select {function_name}(NULL) from t1 group by c1 order by c1" tdSql.query(scalar_sql_1) tdSql.checkRows(10) tdSql.checkData(0,0,None) @@ -100,6 +101,10 @@ class TDTestCase: tdSql.checkRows(10) tdSql.checkData(0,0,None) tdSql.checkData(9,0,None) + tdSql.query(scalar_sql_3) + tdSql.checkRows(10) + tdSql.checkData(0,0,None) + tdSql.checkData(9,0,None) function_names = ["sin" ,"cos" ,"tan" ,"asin" ,"acos" ,"atan"] @@ -109,6 +114,9 @@ class TDTestCase: tdSql.query(" select sin(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select sin(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select sin(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,0.000000000) @@ -122,6 +130,9 @@ class TDTestCase: tdSql.query(" select cos(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select cos(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select cos(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,1.000000000) @@ -135,6 +146,9 @@ class TDTestCase: tdSql.query(" select tan(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select tan(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select tan(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,0.000000000) @@ -147,6 +161,9 @@ class TDTestCase: tdSql.query(" select atan(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select atan(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select atan(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,0.000000000) @@ -160,6 +177,9 @@ class TDTestCase: tdSql.query(" select asin(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select asin(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select asin(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,0.000000000) @@ -173,6 +193,9 @@ class TDTestCase: tdSql.query(" select acos(c1/0) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select acos(NULL) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select acos(0.00) from t1 group by c1 order by c1") tdSql.checkData(9,0,1.570796327) @@ -188,6 +211,9 @@ class TDTestCase: tdSql.query(" select log(-10) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select log(NULL ,2) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(" select log(c1)/0 from t1 group by c1 order by c1") tdSql.checkData(9,0,None) @@ -201,6 +227,9 @@ class TDTestCase: tdSql.query(" select pow(c1,2)/0 from t1 group by c1 order by c1") tdSql.checkData(9,0,None) + tdSql.query(" select pow(NULL,2) from t1 group by c1 order by c1") + tdSql.checkData(9,0,None) + tdSql.query(f" select pow(c1/0 ,1 ) from t1 group by c1 order by c1") tdSql.checkData(9,0,None) From 1d7bf59fe8a3dc3d965bbe5ec79a30e270833dc7 Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 24 Jun 2022 17:23:13 +0800 Subject: [PATCH 65/81] fix: fix iteration bugs of last window result --- source/libs/executor/src/timewindowoperator.c | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 21c265e03d..48b0b1c071 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -3902,6 +3902,7 @@ typedef struct SMergeIntervalAggOperatorInfo { SIntervalAggOperatorInfo intervalAggOperatorInfo; SHashObj* groupIntervalHash; + void* groupIntervalIter; bool hasGroupId; uint64_t groupId; SSDataBlock* prefetchedBlock; @@ -3914,6 +3915,23 @@ void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) { destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); } +static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, STimeWindow* win, SSDataBlock* pResultBlock) { + SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; + bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + SExprSupp* pExprSup = &pOperatorInfo->exprSupp; + + SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId); + SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, + GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + ASSERT(p1 != NULL); + finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo, + pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); + taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + return TSDB_CODE_SUCCESS; +} + static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock, STimeWindow* newWin) { SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; @@ -3928,20 +3946,9 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t return 0; } - if (newWin == NULL || (ascScan && newWin->skey > prevWin->skey || (!ascScan) && newWin->skey < prevWin->skey)) { - SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &prevWin->skey, TSDB_KEYSIZE, tableGroupId); - SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, - GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); - ASSERT(p1 != NULL); - - finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo, - pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); - taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); - if (newWin == NULL) { - taosHashRemove(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId)); - } else { - taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow)); - } + if ((ascScan && newWin->skey > prevWin->skey || (!ascScan) && newWin->skey < prevWin->skey)) { + finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock); + taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow)); } return 0; @@ -4090,12 +4097,17 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { } pRes->info.groupId = miaInfo->groupId; - } else { - void* p = taosHashIterate(miaInfo->groupIntervalHash, NULL); - if (p != NULL) { + } + + if (miaInfo->inputBlocksFinished) { + void* win = taosHashIterate(miaInfo->groupIntervalHash, miaInfo->groupIntervalIter); + if (win != NULL) { + miaInfo->groupIntervalIter = win; + size_t len = 0; - uint64_t* pKey = taosHashGetKey(p, &len); - outputPrevIntervalResult(pOperator, *pKey, pRes, NULL); + uint64_t* pTableGroupId = taosHashGetKey(win, &len); + finalizeWindowResult(pOperator, *pTableGroupId, win, pRes); + pRes->info.groupId = *pTableGroupId; } } @@ -4118,6 +4130,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI } miaInfo->groupIntervalHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_NO_LOCK); + miaInfo->groupIntervalIter = NULL; SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; From c41a4bd7db2ffaeb26a810794c21b9df1c35cf5b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 24 Jun 2022 17:27:43 +0800 Subject: [PATCH 66/81] feat: subplan adds 'user' field --- include/libs/nodes/plannodes.h | 1 + include/libs/planner/planner.h | 25 ++-- source/client/src/clientImpl.c | 148 ++++++++++----------- source/libs/nodes/src/nodesCodeFuncs.c | 7 + source/libs/planner/src/planPhysiCreater.c | 1 + source/libs/planner/test/planTestUtil.cpp | 16 ++- source/libs/planner/test/planTestUtil.h | 2 +- 7 files changed, 103 insertions(+), 97 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index f8cf58d8cb..b7583b41b9 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -458,6 +458,7 @@ typedef struct SSubplan { int32_t msgType; // message type for subplan, used to denote the send message type to vnode. int32_t level; // the execution level of current subplan, starting from 0 in a top-down manner. char dbFName[TSDB_DB_FNAME_LEN]; + char user[TSDB_USER_LEN]; SQueryNodeAddr execNode; // for the scan/modify subplan, the optional execution node SQueryNodeStat execNodeStat; // only for scan subplan SNodeList* pChildren; // the datasource subplan,from which to fetch the result diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index c4f71e57a8..b350837551 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -24,18 +24,19 @@ extern "C" { #include "taos.h" typedef struct SPlanContext { - uint64_t queryId; - int32_t acctId; - SEpSet mgmtEpSet; - SNode* pAstRoot; - bool topicQuery; - bool streamQuery; - bool rSmaQuery; - bool showRewrite; - int8_t triggerType; - int64_t watermark; - char* pMsg; - int32_t msgLen; + uint64_t queryId; + int32_t acctId; + SEpSet mgmtEpSet; + SNode* pAstRoot; + bool topicQuery; + bool streamQuery; + bool rSmaQuery; + bool showRewrite; + int8_t triggerType; + int64_t watermark; + char* pMsg; + int32_t msgLen; + const char* pUser; } SPlanContext; // Create the physical plan for the query, according to the AST. diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b3aaeaea78..73d449412f 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -59,7 +59,7 @@ static STscObj* taosConnectImpl(const char* user, const char* auth, const char* SAppInstInfo* pAppInfo, int connType); STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, - uint16_t port, int connType) { + uint16_t port, int connType) { if (taos_init() != TSDB_CODE_SUCCESS) { return NULL; } @@ -327,8 +327,8 @@ bool qnodeRequired(SRequestObj* pRequest) { } SAppInstInfo* pInfo = pRequest->pTscObj->pAppInfo; - bool required = false; - + bool required = false; + taosThreadMutexLock(&pInfo->qnodeMutex); required = (NULL == pInfo->pQnodeList); taosThreadMutexUnlock(&pInfo->qnodeMutex); @@ -376,7 +376,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra .pAstRoot = pQuery->pRoot, .showRewrite = pQuery->showRewrite, .pMsg = pRequest->msgBuf, - .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE}; + .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, + .pUser = pRequest->pTscObj->user}; return qCreateQueryPlan(&cxt, pPlan, pNodeList); } @@ -433,11 +434,11 @@ int32_t buildVnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr } for (int32_t j = 0; j < vgNum; ++j) { - SVgroupInfo* pInfo = taosArrayGet(pVg, j); + SVgroupInfo* pInfo = taosArrayGet(pVg, j); SQueryNodeLoad load = {0}; load.addr.nodeId = pInfo->vgId; load.addr.epSet = pInfo->epSet; - + taosArrayPush(nodeList, &load); } } @@ -495,17 +496,16 @@ _return: return TSDB_CODE_SUCCESS; } - -int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList, SMetaData *pResultMeta) { +int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList, SMetaData* pResultMeta) { SArray* pDbVgList = NULL; SArray* pQnodeList = NULL; int32_t code = 0; - + switch (tsQueryPolicy) { case QUERY_POLICY_VNODE: { if (pResultMeta) { pDbVgList = taosArrayInit(4, POINTER_BYTES); - + int32_t dbNum = taosArrayGetSize(pResultMeta->pDbVgroup); for (int32_t i = 0; i < dbNum; ++i) { SMetaRes* pRes = taosArrayGet(pResultMeta->pDbVgroup, i); @@ -514,9 +514,9 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray } taosArrayPush(pDbVgList, &pRes->pRes); - } + } } - + code = buildVnodePolicyNodeList(pRequest, pNodeList, pMnodeList, pDbVgList); break; } @@ -537,7 +537,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray } taosThreadMutexUnlock(&pInst->qnodeMutex); } - + code = buildQnodePolicyNodeList(pRequest, pNodeList, pMnodeList, pQnodeList); break; } @@ -548,7 +548,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray taosArrayDestroy(pDbVgList); taosArrayDestroy(pQnodeList); - + return code; } @@ -556,43 +556,43 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* SArray* pDbVgList = NULL; SArray* pQnodeList = NULL; int32_t code = 0; - + switch (tsQueryPolicy) { case QUERY_POLICY_VNODE: { int32_t dbNum = taosArrayGetSize(pRequest->dbList); if (dbNum > 0) { - SCatalog* pCtg = NULL; + SCatalog* pCtg = NULL; SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo; code = catalogGetHandle(pInst->clusterId, &pCtg); if (code != TSDB_CODE_SUCCESS) { goto _return; } - pDbVgList = taosArrayInit(dbNum, POINTER_BYTES); + pDbVgList = taosArrayInit(dbNum, POINTER_BYTES); SArray* pVgList = NULL; for (int32_t i = 0; i < dbNum; ++i) { - char* dbFName = taosArrayGet(pRequest->dbList, i); + char* dbFName = taosArrayGet(pRequest->dbList, i); SRequestConnInfo conn = {.pTrans = pInst->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pInst->mgmtEp)}; - + .mgmtEps = getEpSet_s(&pInst->mgmtEp)}; + code = catalogGetDBVgInfo(pCtg, &conn, dbFName, &pVgList); if (code) { goto _return; } - + taosArrayPush(pDbVgList, &pVgList); - } + } } - + code = buildVnodePolicyNodeList(pRequest, pNodeList, pMnodeList, pDbVgList); break; } case QUERY_POLICY_HYBRID: case QUERY_POLICY_QNODE: { getQnodeList(pRequest, &pQnodeList); - + code = buildQnodePolicyNodeList(pRequest, pNodeList, pMnodeList, pQnodeList); break; } @@ -605,11 +605,10 @@ _return: taosArrayDestroy(pDbVgList); taosArrayDestroy(pQnodeList); - + return code; } - int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { tsem_init(&schdRspSem, 0, 0); @@ -833,8 +832,8 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { } } - tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64, - pRequest->self, code, tstrerror(code), pRequest->requestId); + tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, + tstrerror(code), pRequest->requestId); STscObj* pTscObj = pRequest->pTscObj; if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) { @@ -880,7 +879,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildSyncExecNodeList(pRequest, &pNodeList, pMnodeList); - + code = scheduleQuery(pRequest, pRequest->body.pDag, pNodeList); taosArrayDestroy(pNodeList); } @@ -935,7 +934,7 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool val return launchQueryImpl(pRequest, pQuery, false, NULL); } -void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultMeta) { +void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta) { int32_t code = 0; switch (pQuery->execMode) { @@ -968,7 +967,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta); - + SRequestConnInfo conn = { .pTrans = pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self}; SSchedulerReq req = {.pConn = &conn, @@ -1328,7 +1327,7 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons if (pObj) { return pObj->id; } - + return NULL; } @@ -1500,10 +1499,10 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int return TSDB_CODE_SUCCESS; } -static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows){ +static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) { char* p = (char*)pResultInfo->pData; - int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t)); + int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t)); int32_t* colLength = (int32_t*)(p + len); len += sizeof(int32_t) * numOfCols; @@ -1513,7 +1512,7 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) { int32_t* offset = (int32_t*)pStart; - int32_t lenTmp = numOfRows * sizeof(int32_t); + int32_t lenTmp = numOfRows * sizeof(int32_t); len += lenTmp; pStart += lenTmp; @@ -1538,7 +1537,6 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i } else { ASSERT(0); } - } } else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) { int32_t lenTmp = numOfRows * sizeof(int32_t); @@ -1562,13 +1560,13 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int break; } } - if(!needConvert) return TSDB_CODE_SUCCESS; + if (!needConvert) return TSDB_CODE_SUCCESS; - char* p = (char*)pResultInfo->pData; + char* p = (char*)pResultInfo->pData; int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows); pResultInfo->convertJson = taosMemoryCalloc(1, dataLen); - if(pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; char* p1 = pResultInfo->convertJson; int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t)); @@ -1637,7 +1635,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int ASSERT(0); } - offset1[j]= len; + offset1[j] = len; memcpy(pStart1 + len, dst, varDataTLen(dst)); len += varDataTLen(dst); } @@ -1655,7 +1653,6 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int pStart += len; pStart1 += len; memcpy(pStart1, pStart, colLen); - } pStart += colLen; pStart1 += colLen1; @@ -1723,7 +1720,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 pStart += colLength[i]; } - if(convertUcs4){ + if (convertUcs4) { code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength); } @@ -1840,17 +1837,18 @@ _OVER: return code; } -int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str, int32_t acctId, char* db) { +int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str, + int32_t acctId, char* db) { SName name; - + if (len1 <= 0) { return -1; } - const char *dbName = db; - const char *tbName = NULL; - int32_t dbLen = 0; - int32_t tbLen = 0; + const char* dbName = db; + const char* tbName = NULL; + int32_t dbLen = 0; + int32_t tbLen = 0; if (len2 > 0) { dbName = str + pos1; dbLen = len1; @@ -1861,7 +1859,7 @@ int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, i tbName = str + pos1; tbLen = len1; } - + if (tNameSetDbName(&name, acctId, dbName, dbLen)) { return -1; } @@ -1881,18 +1879,18 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - - bool inEscape = false; + + bool inEscape = false; int32_t code = 0; - + int32_t vIdx = 0; int32_t vPos[2]; int32_t vLen[2]; memset(vPos, -1, sizeof(vPos)); memset(vLen, 0, sizeof(vLen)); - - for (int32_t i = 0; ; ++i) { + + for (int32_t i = 0;; ++i) { if (0 == *(tbList + i)) { if (vPos[vIdx] >= 0 && vLen[vIdx] <= 0) { vLen[vIdx] = i - vPos[vIdx]; @@ -1905,7 +1903,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, break; } - + if ('`' == *(tbList + i)) { inEscape = !inEscape; if (!inEscape) { @@ -1952,7 +1950,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, if (code) { goto _return; } - + memset(vPos, -1, sizeof(vPos)); memset(vLen, 0, sizeof(vLen)); vIdx = 0; @@ -1966,8 +1964,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, continue; } - if (('a' <= *(tbList + i) && 'z' >= *(tbList + i)) || - ('A' <= *(tbList + i) && 'Z' >= *(tbList + i)) || + if (('a' <= *(tbList + i) && 'z' >= *(tbList + i)) || ('A' <= *(tbList + i) && 'Z' >= *(tbList + i)) || ('0' <= *(tbList + i) && '9' >= *(tbList + i))) { if (vLen[vIdx] > 0) { goto _return; @@ -1989,32 +1986,31 @@ _return: taosArrayDestroy(*pReq); *pReq = NULL; - + return terrno; } void syncCatalogFn(SMetaData* pResult, void* param, int32_t code) { - SSyncQueryParam *pParam = param; + SSyncQueryParam* pParam = param; pParam->pRequest->code = code; tsem_post(&pParam->sem); } - -void syncQueryFn(void *param, void *res, int32_t code) { - SSyncQueryParam *pParam = param; +void syncQueryFn(void* param, void* res, int32_t code) { + SSyncQueryParam* pParam = param; pParam->pRequest = res; pParam->pRequest->code = code; tsem_post(&pParam->sem); } -void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, bool validateOnly) { - STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); +void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) { + STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); if (pTscObj == NULL || sql == NULL || NULL == fp) { terrno = TSDB_CODE_INVALID_PARA; if (pTscObj) { - releaseTscObj(*(int64_t *)taos); + releaseTscObj(*(int64_t*)taos); } else { terrno = TSDB_CODE_TSC_DISCONNECTED; } @@ -2031,7 +2027,7 @@ void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void return; } - SRequestObj *pRequest = NULL; + SRequestObj* pRequest = NULL; int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); if (code != TSDB_CODE_SUCCESS) { terrno = code; @@ -2045,45 +2041,41 @@ void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void doAsyncQuery(pRequest, false); } - -TAOS_RES *taosQueryImpl(TAOS *taos, const char *sql, bool validateOnly) { +TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { if (NULL == taos) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } - STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); if (pTscObj == NULL || sql == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } #if SYNC_ON_TOP_OF_ASYNC - SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); tsem_init(¶m->sem, 0, 0); taosAsyncQueryImpl(taos, sql, syncQueryFn, param, validateOnly); tsem_wait(¶m->sem); - releaseTscObj(*(int64_t *)taos); + releaseTscObj(*(int64_t*)taos); return param->pRequest; #else size_t sqlLen = strlen(sql); if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { - releaseTscObj(*(int64_t *)taos); + releaseTscObj(*(int64_t*)taos); tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; return NULL; } - TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen, validateOnly); + TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen, validateOnly); - releaseTscObj(*(int64_t *)taos); + releaseTscObj(*(int64_t*)taos); return pRes; #endif } - - - diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1858918e4a..514d65d52e 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -2294,6 +2294,7 @@ static const char* jkSubplanType = "SubplanType"; static const char* jkSubplanMsgType = "MsgType"; static const char* jkSubplanLevel = "Level"; static const char* jkSubplanDbFName = "DbFName"; +static const char* jkSubplanUser = "User"; static const char* jkSubplanNodeAddr = "NodeAddr"; static const char* jkSubplanRootNode = "RootNode"; static const char* jkSubplanDataSink = "DataSink"; @@ -2316,6 +2317,9 @@ static int32_t subplanToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddStringToObject(pJson, jkSubplanDbFName, pNode->dbFName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkSubplanUser, pNode->user); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkSubplanNodeAddr, queryNodeAddrToJson, &pNode->execNode); } @@ -2352,6 +2356,9 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetStringValue(pJson, jkSubplanDbFName, pNode->dbFName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkSubplanUser, pNode->user); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonToObject(pJson, jkSubplanNodeAddr, jsonToQueryNodeAddr, &pNode->execNode); } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index efb0f790e1..a16287cd4a 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1453,6 +1453,7 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl pSubplan->id = pLogicSubplan->id; pSubplan->subplanType = pLogicSubplan->subplanType; pSubplan->level = pLogicSubplan->level; + strcpy(pSubplan->user, pCxt->pPlanCxt->pUser); return pSubplan; } diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index f1ab9c8196..c197a02dd1 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -85,8 +85,9 @@ class PlannerTestBaseImpl { public: PlannerTestBaseImpl() : sqlNo_(0) {} - void useDb(const string& acctId, const string& db) { - caseEnv_.acctId_ = acctId; + void useDb(const string& user, const string& db) { + caseEnv_.acctId_ = 0; + caseEnv_.user_ = user; caseEnv_.db_ = db; caseEnv_.nsql_ = g_skipSql; } @@ -193,7 +194,8 @@ class PlannerTestBaseImpl { private: struct caseEnv { - string acctId_; + int32_t acctId_; + string user_; string db_; int32_t nsql_; @@ -295,7 +297,7 @@ class PlannerTestBaseImpl { transform(stmtEnv_.sql_.begin(), stmtEnv_.sql_.end(), stmtEnv_.sql_.begin(), ::tolower); SParseContext cxt = {0}; - cxt.acctId = atoi(caseEnv_.acctId_.c_str()); + cxt.acctId = caseEnv_.acctId_; cxt.db = caseEnv_.db_.c_str(); cxt.pSql = stmtEnv_.sql_.c_str(); cxt.sqlLen = stmtEnv_.sql_.length(); @@ -319,12 +321,13 @@ class PlannerTestBaseImpl { void doParseBoundSql(SQuery* pQuery) { SParseContext cxt = {0}; - cxt.acctId = atoi(caseEnv_.acctId_.c_str()); + cxt.acctId = caseEnv_.acctId_; 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(); + cxt.pUser = caseEnv_.user_.c_str(); DO_WITH_THROW(qStmtParseQuerySql, &cxt, pQuery); res_.ast_ = toString(pQuery->pRoot); @@ -364,6 +367,7 @@ class PlannerTestBaseImpl { void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) { pCxt->queryId = 1; + pCxt->pUser = caseEnv_.user_.c_str(); if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) { pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery; pCxt->topicQuery = true; @@ -403,7 +407,7 @@ PlannerTestBase::PlannerTestBase() : impl_(new PlannerTestBaseImpl()) {} PlannerTestBase::~PlannerTestBase() {} -void PlannerTestBase::useDb(const std::string& acctId, const std::string& db) { impl_->useDb(acctId, db); } +void PlannerTestBase::useDb(const std::string& user, const std::string& db) { impl_->useDb(user, db); } void PlannerTestBase::run(const std::string& sql) { return impl_->run(sql); } diff --git a/source/libs/planner/test/planTestUtil.h b/source/libs/planner/test/planTestUtil.h index b188a7a054..7d2a9e533f 100644 --- a/source/libs/planner/test/planTestUtil.h +++ b/source/libs/planner/test/planTestUtil.h @@ -30,7 +30,7 @@ class PlannerTestBase : public testing::Test { PlannerTestBase(); virtual ~PlannerTestBase(); - void useDb(const std::string& acctId, const std::string& db); + void useDb(const std::string& user, const std::string& db); void run(const std::string& sql); // stmt mode APIs void prepare(const std::string& sql); From 62ce46771115df469692a7c60d2a6ea64609ff3c Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 24 Jun 2022 17:37:30 +0800 Subject: [PATCH 67/81] fix:error in compile --- source/dnode/vnode/inc/vnode.h | 2 +- source/libs/executor/src/executorimpl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index c929205731..a32bf0ecdb 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -117,7 +117,7 @@ typedef void *tsdbReaderT; #define BLOCK_LOAD_TABLE_RR_ORDER 3 int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList); -tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableInfoGroup, uint64_t qId, +tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableList, uint64_t qId, uint64_t taskId); tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableListInfo *groupList, uint64_t qId, void *pMemRef); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ac68fced8a..09673b3699 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4389,7 +4389,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* goto _error; } - tsdbReaderT pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo, queryId, taskId); + tsdbReaderT pReader = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, queryId, taskId); cleanupQueryTableDataCond(&cond); return pReader; From 41eaee7623cc96e018ca9a69ac2094a9b32a06c3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 17:53:18 +0800 Subject: [PATCH 68/81] test: fix unitest after enable sysinfo option --- source/dnode/mgmt/node_util/src/dmFile.c | 2 +- source/dnode/mnode/impl/src/mndUser.c | 2 +- source/dnode/mnode/impl/test/user/user.cpp | 26 ++++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c index ce592b8375..9ec17a18b5 100644 --- a/source/dnode/mgmt/node_util/src/dmFile.c +++ b/source/dnode/mgmt/node_util/src/dmFile.c @@ -136,7 +136,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) { taosMsleep(1000); retryTimes++; dError("failed to lock file:%s since %s, retryTimes:%d", filepath, terrstr(), retryTimes); - } while (retryTimes < 6); + } while (retryTimes < 12); if (ret < 0) { terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index eb0a818a60..03c9647bfe 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -295,7 +295,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate tstrncpy(userObj.acct, acct, TSDB_USER_LEN); userObj.createdTime = taosGetTimestampMs(); userObj.updateTime = userObj.createdTime; - userObj.superUser = pCreate->superUser; + userObj.superUser = 0;//pCreate->superUser; userObj.sysInfo = pCreate->sysInfo; userObj.enable = pCreate->enable; diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 6aa28a9007..3b1a5fa3c5 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -33,6 +33,8 @@ TEST_F(MndTestUser, 01_Show_User) { TEST_F(MndTestUser, 02_Create_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, ""); strcpy(createReq.pass, "p1"); @@ -47,6 +49,8 @@ TEST_F(MndTestUser, 02_Create_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u1"); strcpy(createReq.pass, ""); @@ -61,6 +65,8 @@ TEST_F(MndTestUser, 02_Create_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "root"); strcpy(createReq.pass, "1"); @@ -75,6 +81,8 @@ TEST_F(MndTestUser, 02_Create_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u1"); strcpy(createReq.pass, "p1"); @@ -108,9 +116,11 @@ TEST_F(MndTestUser, 02_Create_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u2"); strcpy(createReq.pass, "p1"); - createReq.superUser = 1; + createReq.superUser = 0; int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -144,9 +154,11 @@ TEST_F(MndTestUser, 02_Create_User) { TEST_F(MndTestUser, 03_Alter_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u3"); strcpy(createReq.pass, "p1"); - createReq.superUser = 1; + createReq.superUser = 0; int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -225,7 +237,7 @@ TEST_F(MndTestUser, 03_Alter_User) { alterReq.alterType = TSDB_ALTER_USER_SUPERUSER; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); - alterReq.superUser = 1; + alterReq.superUser = 0; int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); void* pReq = rpcMallocCont(contLen); @@ -361,7 +373,7 @@ TEST_F(MndTestUser, 03_Alter_User) { SGetUserAuthRsp authRsp = {0}; tDeserializeSGetUserAuthRsp(pRsp->pCont, pRsp->contLen, &authRsp); EXPECT_STREQ(authRsp.user, "u3"); - EXPECT_EQ(authRsp.superAuth, 1); + EXPECT_EQ(authRsp.superAuth, 0); int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs); int32_t numOfWriteDbs = taosHashGetSize(authRsp.writeDbs); EXPECT_EQ(numOfReadDbs, 1); @@ -436,6 +448,8 @@ TEST_F(MndTestUser, 05_Drop_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u1"); strcpy(createReq.pass, "p1"); @@ -468,6 +482,8 @@ TEST_F(MndTestUser, 05_Drop_User) { TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u1"); strcpy(createReq.pass, "p1"); @@ -482,6 +498,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { { SCreateUserReq createReq = {0}; + createReq.enable = 1; + createReq.sysInfo = 1; strcpy(createReq.user, "u2"); strcpy(createReq.pass, "p2"); From 4bc09c22adb0922ef2705869989e35222f0fc41c Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 24 Jun 2022 18:05:57 +0800 Subject: [PATCH 69/81] test:merge 3.0 --- tests/test/c/tmqSim.c | 122 ++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 59005fae94..c2fba52e6e 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -22,9 +22,9 @@ #include #include "taos.h" +#include "taosdef.h" #include "taoserror.h" #include "tlog.h" -#include "taosdef.h" #include "types.h" #define GREEN "\033[1;32m" @@ -36,11 +36,7 @@ #define MAX_CONSUMER_THREAD_CNT (16) #define MAX_VGROUP_CNT (32) -typedef enum { - NOTIFY_CMD_START_CONSUM, - NOTIFY_CMD_START_COMMIT, - NOTIFY_CMD_ID_BUTT -}NOTIFY_CMD_ID; +typedef enum { NOTIFY_CMD_START_CONSUM, NOTIFY_CMD_START_COMMIT, NOTIFY_CMD_ID_BUTT } NOTIFY_CMD_ID; typedef struct { TdThread thread; @@ -52,8 +48,8 @@ typedef struct { // char autoOffsetRest[16]; // none, earliest, latest TdFilePtr pConsumeRowsFile; - int32_t ifCheckData; - int64_t expectMsgCnt; + int32_t ifCheckData; + int64_t expectMsgCnt; int64_t consumeMsgCnt; int64_t consumeRowCnt; @@ -89,6 +85,7 @@ typedef struct { int32_t saveRowFlag; int32_t consumeDelay; // unit s int32_t numOfThread; + int32_t useSnapshot; SThreadInfo stThreads[MAX_CONSUMER_THREAD_CNT]; } SConfInfo; @@ -217,6 +214,8 @@ void parseArgument(int32_t argc, char* argv[]) { g_stConfInfo.saveRowFlag = atol(argv[++i]); } else if (strcmp(argv[i], "-y") == 0) { g_stConfInfo.consumeDelay = atol(argv[++i]); + } else if (strcmp(argv[i], "-e") == 0) { + g_stConfInfo.useSnapshot = atol(argv[++i]); } else { pError("%s unknow para: %s %s", GREEN, argv[++i], NC); exit(-1); @@ -310,11 +309,11 @@ int32_t saveConsumeContentToTbl(SThreadInfo* pInfo, char* buf) { return 0; } -static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { - //if (shell.args.is_raw_time) { - // sprintf(buf, "%" PRId64, val); - // return buf; - //} +static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { + // if (shell.args.is_raw_time) { + // sprintf(buf, "%" PRId64, val); + // return buf; + // } time_t tt; int32_t ms = 0; @@ -352,7 +351,7 @@ static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { } } - struct tm *ptm = taosLocalTime(&tt, NULL); + struct tm* ptm = taosLocalTime(&tt, NULL); size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm); if (precision == TSDB_TIME_PRECISION_NANO) { @@ -366,7 +365,8 @@ static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { return buf; } -static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision) { +static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length, + int32_t precision) { if (val == NULL) { taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR); return; @@ -376,31 +376,31 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *f char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - taosFprintfFile(pFile, "%d", ((((int32_t)(*((char *)val))) == 1) ? 1 : 0)); + taosFprintfFile(pFile, "%d", ((((int32_t)(*((char*)val))) == 1) ? 1 : 0)); break; case TSDB_DATA_TYPE_TINYINT: - taosFprintfFile(pFile, "%d", *((int8_t *)val)); + taosFprintfFile(pFile, "%d", *((int8_t*)val)); break; case TSDB_DATA_TYPE_UTINYINT: - taosFprintfFile(pFile, "%u", *((uint8_t *)val)); + taosFprintfFile(pFile, "%u", *((uint8_t*)val)); break; case TSDB_DATA_TYPE_SMALLINT: - taosFprintfFile(pFile, "%d", *((int16_t *)val)); + taosFprintfFile(pFile, "%d", *((int16_t*)val)); break; case TSDB_DATA_TYPE_USMALLINT: - taosFprintfFile(pFile, "%u", *((uint16_t *)val)); + taosFprintfFile(pFile, "%u", *((uint16_t*)val)); break; case TSDB_DATA_TYPE_INT: - taosFprintfFile(pFile, "%d", *((int32_t *)val)); + taosFprintfFile(pFile, "%d", *((int32_t*)val)); break; case TSDB_DATA_TYPE_UINT: - taosFprintfFile(pFile, "%u", *((uint32_t *)val)); + taosFprintfFile(pFile, "%u", *((uint32_t*)val)); break; case TSDB_DATA_TYPE_BIGINT: - taosFprintfFile(pFile, "%" PRId64, *((int64_t *)val)); + taosFprintfFile(pFile, "%" PRId64, *((int64_t*)val)); break; case TSDB_DATA_TYPE_UBIGINT: - taosFprintfFile(pFile, "%" PRIu64, *((uint64_t *)val)); + taosFprintfFile(pFile, "%" PRIu64, *((uint64_t*)val)); break; case TSDB_DATA_TYPE_FLOAT: taosFprintfFile(pFile, "%.5f", GET_FLOAT_VAL(val)); @@ -421,7 +421,7 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *f taosFprintfFile(pFile, "\'%s\'", buf); break; case TSDB_DATA_TYPE_TIMESTAMP: - shellFormatTimestamp(buf, *(int64_t *)val, precision); + shellFormatTimestamp(buf, *(int64_t*)val, precision); taosFprintfFile(pFile, "'%s'", buf); break; default: @@ -429,12 +429,13 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *f } } -static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields, int32_t precision) { +static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields, + int32_t precision) { for (int32_t i = 0; i < num_fields; i++) { if (i > 0) { taosFprintfFile(pFile, "\n"); } - shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision); + shellDumpFieldToFile(pFile, (const char*)row[i], fields + i, length[i], precision); } taosFprintfFile(pFile, "\n"); } @@ -444,40 +445,42 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex) int32_t totalRows = 0; // printf("topic: %s\n", tmq_get_topic_name(msg)); - int32_t vgroupId = tmq_get_vgroup_id(msg); - const char* dbName = tmq_get_db_name(msg); + int32_t vgroupId = tmq_get_vgroup_id(msg); + const char* dbName = tmq_get_db_name(msg); taosFprintfFile(g_fp, "consumerId: %d, msg index:%" PRId64 "\n", pInfo->consumerId, msgIndex); - taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", tmq_get_topic_name(msg), vgroupId); + taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", + tmq_get_topic_name(msg), vgroupId); while (1) { TAOS_ROW row = taos_fetch_row(msg); if (row == NULL) break; - TAOS_FIELD* fields = taos_fetch_fields(msg); + TAOS_FIELD* fields = taos_fetch_fields(msg); int32_t numOfFields = taos_field_count(msg); - int32_t* length = taos_fetch_lengths(msg); - int32_t precision = taos_result_precision(msg); - const char* tbName = tmq_get_table_name(msg); + int32_t* length = taos_fetch_lengths(msg); + int32_t precision = taos_result_precision(msg); + const char* tbName = tmq_get_table_name(msg); - #if 0 + #if 0 // get schema //============================== stub =================================================// for (int32_t i = 0; i < numOfFields; i++) { taosFprintfFile(g_fp, "%02d: name: %s, type: %d, len: %d\n", i, fields[i].name, fields[i].type, fields[i].bytes); } //============================== stub =================================================// - #endif - - dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); + #endif + + dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); + taos_print_row(buf, row, fields, numOfFields); if (0 != g_stConfInfo.showRowFlag) { taosFprintfFile(g_fp, "tbname:%s, rows[%d]: %s\n", (tbName != NULL ? tbName : "null table"), totalRows, buf); - //if (0 != g_stConfInfo.saveRowFlag) { - // saveConsumeContentToTbl(pInfo, buf); - //} + // if (0 != g_stConfInfo.saveRowFlag) { + // saveConsumeContentToTbl(pInfo, buf); + // } } totalRows++; @@ -500,8 +503,7 @@ int queryDB(TAOS* taos, char* command) { return 0; } -static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) { -} +static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) {} int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { char sqlStr[1024] = {0}; @@ -509,11 +511,8 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { int64_t now = taosGetTimestampMs(); // schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int - sprintf(sqlStr, "insert into %s.notifyinfo values (%"PRId64", %d, %d)", - g_stConfInfo.cdbName, - now, - cmdId, - pInfo->consumerId); + sprintf(sqlStr, "insert into %s.notifyinfo values (%" PRId64 ", %d, %d)", g_stConfInfo.cdbName, now, cmdId, + pInfo->consumerId); taos_query_a(pInfo->taos, sqlStr, appNothing, NULL); @@ -523,12 +522,12 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { } static int32_t g_once_commit_flag = 0; -static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { - pError("tmq_commit_cb_print() commit %d\n", code); +static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { + pError("tmq_commit_cb_print() commit %d\n", code); if (0 == g_once_commit_flag) { g_once_commit_flag = 1; - notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); + notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); } char tmpString[128]; @@ -564,6 +563,10 @@ void build_consumer(SThreadInfo* pInfo) { // tmq_conf_set(conf, "auto.offset.reset", "none"); // tmq_conf_set(conf, "auto.offset.reset", "earliest"); // tmq_conf_set(conf, "auto.offset.reset", "latest"); + // + if (g_stConfInfo.useSnapshot) { + tmq_conf_set(conf, "experiment.use.snapshot", "true"); + } pInfo->tmq = tmq_consumer_new(conf, NULL, 0); @@ -618,12 +621,13 @@ void loop_consume(SThreadInfo* pInfo) { pInfo->consumerId); pInfo->ts = taosGetTimestampMs(); - + if (pInfo->ifCheckData) { - char filename[256] = {0}; + char filename[256] = {0}; char tmpString[128]; - //sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId, getCurrentTimeString(tmpString)); - sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId); + // sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId, + // getCurrentTimeString(tmpString)); + sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId); pInfo->pConsumeRowsFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); if (pInfo->pConsumeRowsFile == NULL) { taosFprintfFile(g_fp, "%s create file fail for save rows content\n", getCurrentTimeString(tmpString)); @@ -642,10 +646,10 @@ void loop_consume(SThreadInfo* pInfo) { totalMsgs++; - if (0 == once_flag) { + if (0 == once_flag) { once_flag = 1; - notifyMainScript(pInfo, NOTIFY_CMD_START_CONSUM); - } + notifyMainScript(pInfo, NOTIFY_CMD_START_CONSUM); + } if (totalRows >= pInfo->expectMsgCnt) { char tmpString[128]; @@ -678,7 +682,7 @@ void* consumeThreadFunc(void* param) { pInfo->taos = taos_connect(NULL, "root", "taosdata", NULL, 0); if (pInfo->taos == NULL) { taosFprintfFile(g_fp, "taos_connect() fail, can not notify and save consume result to main scripte\n"); - return NULL; + return NULL; } build_consumer(pInfo); From e3698b0bd389e894924a7b24ed8029f4e85cd6d7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 18:09:07 +0800 Subject: [PATCH 70/81] test: fix unitest after enable sysinfo option --- source/dnode/mnode/impl/src/mndMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 26fe593c36..d07de7c048 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -540,7 +540,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { mError("msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d", pMsg, terrstr(), TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse); for (int32_t i = 0; i < epSet.numOfEps; ++i) { - mTrace("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); + mInfo("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); } int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); From f3c29576284f97f8eee43bb94ea14598a150dc49 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 24 Jun 2022 18:38:06 +0800 Subject: [PATCH 71/81] opti:ttl/comment log and parameters --- source/common/src/tglobal.c | 4 ++++ source/dnode/vnode/src/meta/metaTable.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index e4bb30b001..b104e1c2be 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -963,6 +963,10 @@ int32_t taosSetCfg(SConfig *pCfg, char* name) { tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32; } else if (strcasecmp("transPullupInterval", name) == 0) { tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; + } else if (strcasecmp("ttlUnit", name) == 0) { + tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32; + } else if (strcasecmp("ttlPushInterval", name) == 0) { + tsTtlPushInterval = cfgGetItem(pCfg, "ttlPushInterval")->i32; } else if (strcasecmp("tmrDebugFlag", name) == 0) { tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32; } else if (strcasecmp("tsdbDebugFlag", name) == 0) { diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 5956df1ba9..4a3feca8d0 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -381,6 +381,7 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) { for (int i = 0; i < taosArrayGetSize(tbUids); ++i) { tb_uid_t *uid = (tb_uid_t *)taosArrayGet(tbUids, i); metaDropTableByUid(pMeta, *uid, NULL); + metaDebug("ttl drop table:%"PRId64, *uid); } metaULock(pMeta); return 0; @@ -443,7 +444,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { // drop schema.db (todo) } - metaError("ttl drop table:%s", e.name); tDecoderClear(&dc); tdbFree(pData); From 0701da48f4fa2a2c51bf1f76a1f957b26ce83874 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 24 Jun 2022 18:39:44 +0800 Subject: [PATCH 72/81] feat: subplan adds 'user' field --- source/client/src/clientImpl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 73d449412f..489966b636 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -955,7 +955,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM .pAstRoot = pQuery->pRoot, .showRewrite = pQuery->showRewrite, .pMsg = pRequest->msgBuf, - .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE}; + .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, + .pUser = pRequest->pTscObj->user}; SAppInstInfo* pAppInfo = getAppInfo(pRequest); code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pMnodeList); From f810212d29f649b6e9669cfd67f9a8f3c1742953 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 24 Jun 2022 19:03:56 +0800 Subject: [PATCH 73/81] fix: no redirect resp --- source/dnode/mnode/impl/src/mndMain.c | 31 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 000e1041d0..320dd4127e 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -529,24 +529,33 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0; if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER || - pMsg->msgType == TDMT_MND_TRANS_TIMER || TDMT_MND_TTL_TIMER) { + pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER) { return -1; } - const STraceId *trace = &pMsg->info.traceId; - mError("msg:%p, failed to check mnode state since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); - SEpSet epSet = {0}; mndGetMnodeEpSet(pMsg->info.node, &epSet); - int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); - pMsg->info.rsp = rpcMallocCont(contLen); - if (pMsg->info.rsp != NULL) { - tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); - pMsg->info.rspLen = contLen; - terrno = TSDB_CODE_RPC_REDIRECT; + const STraceId *trace = &pMsg->info.traceId; + mError("msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d", pMsg, terrstr(), + TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse); + + if (epSet.numOfEps > 0) { + for (int32_t i = 0; i < epSet.numOfEps; ++i) { + mInfo("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); + } + + int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); + pMsg->info.rsp = rpcMallocCont(contLen); + if (pMsg->info.rsp != NULL) { + tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); + pMsg->info.rspLen = contLen; + terrno = TSDB_CODE_RPC_REDIRECT; + } else { + terrno = TSDB_CODE_OUT_OF_MEMORY; + } } else { - terrno = TSDB_CODE_OUT_OF_MEMORY; + terrno = TSDB_CODE_APP_NOT_READY; } return -1; From 994232c7ac372b0bcecea97601e8246d06482d9f Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 24 Jun 2022 19:10:00 +0800 Subject: [PATCH 74/81] feat: subplan adds 'user' field --- source/libs/planner/src/planPhysiCreater.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index a16287cd4a..37b69ffdfe 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1453,7 +1453,9 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl pSubplan->id = pLogicSubplan->id; pSubplan->subplanType = pLogicSubplan->subplanType; pSubplan->level = pLogicSubplan->level; - strcpy(pSubplan->user, pCxt->pPlanCxt->pUser); + if (NULL != pCxt->pPlanCxt->pUser) { + strcpy(pSubplan->user, pCxt->pPlanCxt->pUser); + } return pSubplan; } From bd13d0b7ad27909026852ededf0fe34ed6822729 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 24 Jun 2022 19:31:45 +0800 Subject: [PATCH 75/81] test: modify case --- tests/system-test/6-cluster/5dnode3mnodeStop.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index 69b9c3d879..3a85207af6 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -227,6 +227,7 @@ class TDTestCase: # fisr add three mnodes; tdSql.execute("create mnode on dnode 2") + time.sleep(10) tdSql.execute("create mnode on dnode 3") # fisrt check statut ready From f8bb36ce2c8b5c2e3b536a2a513b316fa1896536 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 24 Jun 2022 20:08:07 +0800 Subject: [PATCH 76/81] enh(query): add _group_key function for partion by TD-16805 --- include/libs/function/functionMgt.h | 1 + source/libs/function/inc/builtinsimpl.h | 3 +++ source/libs/function/src/builtins.c | 22 ++++++++++++++++++- source/libs/function/src/builtinsimpl.c | 28 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 1ca51b3043..1ed78750d1 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -124,6 +124,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function FUNCTION_TYPE_TO_COLUMN, + FUNCTION_TYPE_GROUP_KEY, // distributed splitting functions FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 4d2f926c12..b3ce6abe87 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -202,6 +202,9 @@ bool blockDistSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t blockDistFunction(SqlFunctionCtx *pCtx); int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +int32_t groupKeyFunction(SqlFunctionCtx* pCtx); + #ifdef __cplusplus } #endif diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 6516a10795..f3f1097148 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1515,6 +1515,16 @@ static bool getBlockDistFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv return true; } +static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return TSDB_CODE_SUCCESS; + } + + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + pFunc->node.resType = ((SExprNode*)pPara)->resType; + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { @@ -2499,7 +2509,17 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .type = FUNCTION_TYPE_BLOCK_DIST_INFO, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC, .translateFunc = translateBlockDistInfoFunc, - } + }, + { + .name = "_group_key", + .type = FUNCTION_TYPE_GROUP_KEY, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateGroupKey, + .getEnvFunc = getGroupKeyFuncEnv, + .initFunc = functionSetup, + .processFunc = groupKeyFunction, + .finalizeFunc = functionFinalize, + }, }; // clang-format on diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 4ec6432fc8..42c316b01d 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2402,6 +2402,12 @@ bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { return true; } +bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { + SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); + pEnv->calcMemSize = pNode->node.resType.bytes; + return true; +} + static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowIndex) { if (pTsColInfo == NULL) { return 0; @@ -5349,6 +5355,28 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } +int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + char* buf = GET_ROWCELL_INTERBUF(pResInfo); + + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pInputCol = pInput->pData[0]; + + int32_t bytes = pInputCol->info.bytes; + + int32_t startIndex = pInput->startRowIndex; + if (colDataIsNull_s(pInputCol, startIndex)) { + pResInfo->numOfRes = 0; + return TSDB_CODE_SUCCESS; + } + + char* data = colDataGetData(pInputCol, startIndex); + memcpy(buf, data, bytes); + SET_VAL(pResInfo, 1, 1); + + return TSDB_CODE_SUCCESS; +} + int32_t interpFunction(SqlFunctionCtx* pCtx) { #if 0 int32_t fillType = (int32_t) pCtx->param[2].i64; From 5c3fae340ecbd16fc34a9fdd6a27fdc0454dedec Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 24 Jun 2022 20:26:46 +0800 Subject: [PATCH 77/81] add NULL logic for _group_key --- source/libs/function/inc/builtinsimpl.h | 1 + source/libs/function/src/builtins.c | 2 +- source/libs/function/src/builtinsimpl.c | 33 ++++++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index b3ce6abe87..0820e884ce 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -204,6 +204,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t groupKeyFunction(SqlFunctionCtx* pCtx); +int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); #ifdef __cplusplus } diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index f3f1097148..6744ebe4b9 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2518,7 +2518,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getGroupKeyFuncEnv, .initFunc = functionSetup, .processFunc = groupKeyFunction, - .finalizeFunc = functionFinalize, + .finalizeFunc = groupKeyFinalize, }, }; // clang-format on diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 42c316b01d..61f3154811 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -262,6 +262,12 @@ typedef struct SRateInfo { int8_t hasResult; // flag to denote has value } SRateInfo; +typedef struct SGroupKeyInfo{ + bool hasResult; + char data[]; +} SGroupKeyInfo; + + #define SET_VAL(_info, numOfElem, res) \ do { \ if ((numOfElem) <= 0) { \ @@ -2404,7 +2410,7 @@ bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); - pEnv->calcMemSize = pNode->node.resType.bytes; + pEnv->calcMemSize = sizeof(SGroupKeyInfo) + pNode->node.resType.bytes; return true; } @@ -5357,7 +5363,7 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - char* buf = GET_ROWCELL_INTERBUF(pResInfo); + SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; @@ -5366,17 +5372,32 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { int32_t startIndex = pInput->startRowIndex; if (colDataIsNull_s(pInputCol, startIndex)) { - pResInfo->numOfRes = 0; - return TSDB_CODE_SUCCESS; + pInfo->hasResult = false; + goto _group_key_over; } + pInfo->hasResult = true; char* data = colDataGetData(pInputCol, startIndex); - memcpy(buf, data, bytes); - SET_VAL(pResInfo, 1, 1); + memcpy(pInfo->data, data, bytes); +_group_key_over: + + SET_VAL(pResInfo, 1, 1); return TSDB_CODE_SUCCESS; } +int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + + SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + colDataAppend(pCol, pBlock->info.rows, pInfo->data, pInfo->hasResult ? false : true); + + return pResInfo->numOfRes; +} + int32_t interpFunction(SqlFunctionCtx* pCtx) { #if 0 int32_t fillType = (int32_t) pCtx->param[2].i64; From 0964b072290ae1c64bcd9168db31c750b30af046 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 24 Jun 2022 21:44:53 +0800 Subject: [PATCH 78/81] fix(stream): support none type in submit msg --- examples/c/stream_demo.c | 17 ++++++++++++----- source/dnode/vnode/src/tq/tqRead.c | 2 +- source/libs/stream/src/streamDispatch.c | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/c/stream_demo.c b/examples/c/stream_demo.c index 961eb6c93a..a4fc30ff65 100644 --- a/examples/c/stream_demo.c +++ b/examples/c/stream_demo.c @@ -25,7 +25,7 @@ int32_t init_env() { return -1; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return -1; @@ -68,6 +68,14 @@ int32_t init_env() { return -1; } taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists tu3 using st1 tags(3)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table tu3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + return 0; } @@ -90,10 +98,9 @@ int32_t create_stream() { /*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/ /*const char* sql = "select sum(k) from tu1 interval(10m)";*/ /*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/ - pRes = taos_query( - pConn, - "create stream stream1 trigger window_close watermark 10s into outstb as select _wstartts, sum(k) from st1 " - "interval(10s) "); + pRes = taos_query(pConn, + "create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 " + "partition by tbname interval(10s) "); if (taos_errno(pRes) != 0) { printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 0243f2a9f0..6184d8f810 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -243,7 +243,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_ if (!tdSTSRowIterNext(&iter, pColData->info.colId, pColData->info.type, &sVal)) { break; } - if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) { + if (colDataAppend(pColData, curRow, sVal.val, sVal.valType != TD_VTYPE_NORM) < 0) { goto FAIL; } } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 179dc88d2a..a8b18210dd 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -63,7 +63,6 @@ int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) { } int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq) { - // if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->dstNodeId) < 0) return -1; @@ -84,7 +83,7 @@ int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) { if (tDecodeI32(pDecoder, &pReq->srcTaskId) < 0) return -1; uint64_t len = 0; if (tDecodeBinaryAlloc(pDecoder, (void**)&pReq->pRetrieve, &len) < 0) return -1; - pReq->retrieveLen = len; + pReq->retrieveLen = (int32_t)len; tEndDecode(pDecoder); return 0; } From 0cc28d6ee2fd3e86a1080ef8b560bc5289cd7323 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 25 Jun 2022 08:27:11 +0800 Subject: [PATCH 79/81] test: minor changes --- tests/script/tsim/mnode/basic5.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/tsim/mnode/basic5.sim b/tests/script/tsim/mnode/basic5.sim index 23f5f6d782..c017d7f23f 100644 --- a/tests/script/tsim/mnode/basic5.sim +++ b/tests/script/tsim/mnode/basic5.sim @@ -157,7 +157,7 @@ step61: if $x == 10 then return -1 endi -sql show mnodes +sql show mnodes -x step61 print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data20 $data21 $data22 $data23 $data24 $data25 From cdfb47cb550771bc5c87b0cdc057ecb8124147eb Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 25 Jun 2022 08:56:47 +0800 Subject: [PATCH 80/81] feat: check oper privilege --- source/dnode/mnode/impl/inc/mndAuth.h | 2 ++ source/dnode/mnode/impl/src/mndBnode.c | 14 +++++------- source/dnode/mnode/impl/src/mndDnode.c | 19 ++++++++-------- source/dnode/mnode/impl/src/mndFunc.c | 14 +++++------- source/dnode/mnode/impl/src/mndMnode.c | 16 ++++++-------- source/dnode/mnode/impl/src/mndQnode.c | 29 +++++++++++-------------- source/dnode/mnode/impl/src/mndSnode.c | 14 +++++------- source/dnode/mnode/impl/src/mndVgroup.c | 15 ++++++++----- 8 files changed, 59 insertions(+), 64 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndAuth.h b/source/dnode/mnode/impl/inc/mndAuth.h index 9af4792665..81a776b652 100644 --- a/source/dnode/mnode/impl/inc/mndAuth.h +++ b/source/dnode/mnode/impl/inc/mndAuth.h @@ -31,6 +31,7 @@ typedef enum { MND_OPER_DROP_BNODE, MND_OPER_CREATE_DNODE, MND_OPER_DROP_DNODE, + MND_OPER_CONFIG_DNODE, MND_OPER_CREATE_MNODE, MND_OPER_DROP_MNODE, MND_OPER_CREATE_QNODE, @@ -38,6 +39,7 @@ typedef enum { MND_OPER_CREATE_SNODE, MND_OPER_DROP_SNODE, MND_OPER_REDISTRIBUTE_VGROUP, + MND_OPER_MERGE_VGROUP, MND_OPER_SPLIT_VGROUP, MND_OPER_BALANCE_VGROUP, MND_OPER_CREATE_FUNC, diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index 0de40ca671..e2b1aad008 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -277,6 +277,9 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) { } mDebug("bnode:%d, start to create", createReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_BNODE) != 0) { + goto _OVER; + } pObj = mndAcquireBnode(pMnode, createReq.dnodeId); if (pObj != NULL) { @@ -292,10 +295,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_BNODE) != 0) { - goto _OVER; - } - code = mndCreateBnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -383,6 +382,9 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) { } mDebug("bnode:%d, start to drop", dropReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_BNODE) != 0) { + goto _OVER; + } if (dropReq.dnodeId <= 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -394,10 +396,6 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_BNODE) != 0) { - goto _OVER; - } - code = mndDropBnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 0eab364e90..113777bc1f 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -609,7 +609,6 @@ _OVER: return code; } - static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; @@ -622,6 +621,9 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { } mInfo("dnode:%s:%d, start to create", createReq.fqdn, createReq.port); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE) != 0) { + goto _OVER; + } if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) { terrno = TSDB_CODE_MND_INVALID_DNODE_EP; @@ -635,10 +637,6 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_DNODE) != 0) { - goto _OVER; - } - code = mndCreateDnode(pMnode, pReq, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -717,6 +715,9 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { } mInfo("dnode:%d, start to drop, ep:%s:%d", dropReq.dnodeId, dropReq.fqdn, dropReq.port); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) { + goto _OVER; + } pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId); if (pDnode == NULL) { @@ -753,10 +754,6 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { } } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) { - goto _OVER; - } - code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -782,6 +779,10 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) { + return -1; + } + SDnodeObj *pDnode = mndAcquireDnode(pMnode, cfgReq.dnodeId); if (pDnode == NULL) { mError("dnode:%d, failed to config since %s ", cfgReq.dnodeId, terrstr()); diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index 832f1b8e68..37e0a719dd 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -283,6 +283,9 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) { } mDebug("func:%s, start to create", createReq.name); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC) != 0) { + goto _OVER; + } pFunc = mndAcquireFunc(pMnode, createReq.name); if (pFunc != NULL) { @@ -318,10 +321,6 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_FUNC) != 0) { - goto _OVER; - } - code = mndCreateFunc(pMnode, pReq, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -347,6 +346,9 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) { } mDebug("func:%s, start to drop", dropReq.name); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC) != 0) { + goto _OVER; + } if (dropReq.name[0] == 0) { terrno = TSDB_CODE_MND_INVALID_FUNC_NAME; @@ -365,10 +367,6 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) { } } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_FUNC) != 0) { - goto _OVER; - } - code = mndDropFunc(pMnode, pReq, pFunc); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index b40cd713e5..bc3d23282c 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -389,6 +389,9 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { } mDebug("mnode:%d, start to create", createReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_MNODE) != 0) { + goto _OVER; + } pObj = mndAcquireMnode(pMnode, createReq.dnodeId); if (pObj != NULL) { @@ -414,10 +417,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_MNODE) != 0) { - goto _OVER; - } - code = mndCreateMnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -495,7 +494,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode { int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead); void *pReq = taosMemoryMalloc(contLen); - tSerializeSSetStandbyReq((char*)pReq + sizeof(SMsgHead), contLen, &standbyReq); + tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq); SMsgHead *pHead = pReq; pHead->contLen = htonl(contLen); pHead->vgId = htonl(MNODE_HANDLE); @@ -595,6 +594,9 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { } mDebug("mnode:%d, start to drop", dropReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) { + goto _OVER; + } if (dropReq.dnodeId <= 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -621,10 +623,6 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_MNODE) != 0) { - goto _OVER; - } - code = mndDropMnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 0a6c97e63c..9f1eb4ee24 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -279,6 +279,9 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) { } mDebug("qnode:%d, start to create", createReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_QNODE) != 0) { + goto _OVER; + } pObj = mndAcquireQnode(pMnode, createReq.dnodeId); if (pObj != NULL) { @@ -294,10 +297,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_QNODE) != 0) { - goto _OVER; - } - code = mndCreateQnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -391,6 +390,9 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) { } mDebug("qnode:%d, start to drop", dropReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_QNODE) != 0) { + goto _OVER; + } if (dropReq.dnodeId <= 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -402,10 +404,6 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_QNODE) != 0) { - goto _OVER; - } - code = mndDropQnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -418,19 +416,19 @@ _OVER: return code; } -int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit) { - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - SQnodeObj *pObj = NULL; - int32_t numOfRows = 0; +int32_t mndCreateQnodeList(SMnode *pMnode, SArray **pList, int32_t limit) { + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + SQnodeObj *pObj = NULL; + int32_t numOfRows = 0; - SArray* qnodeList = taosArrayInit(5, sizeof(SQueryNodeLoad)); + SArray *qnodeList = taosArrayInit(5, sizeof(SQueryNodeLoad)); if (NULL == qnodeList) { mError("failed to alloc epSet while process qnode list req"); terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - + while (1) { pIter = sdbFetch(pSdb, SDB_QNODE, pIter, (void **)&pObj); if (pIter == NULL) break; @@ -457,7 +455,6 @@ int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit) return TSDB_CODE_SUCCESS; } - static int32_t mndProcessQnodeListReq(SRpcMsg *pReq) { int32_t code = -1; SMnode *pMnode = pReq->info.node; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index df1330197a..a638bdf61f 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -285,6 +285,9 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) { } mDebug("snode:%d, start to create", createReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_SNODE) != 0) { + goto _OVER; + } pObj = mndAcquireSnode(pMnode, createReq.dnodeId); if (pObj != NULL) { @@ -300,10 +303,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_CREATE_SNODE) != 0) { - goto _OVER; - } - code = mndCreateSnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -398,6 +397,9 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) { } mDebug("snode:%d, start to drop", dropReq.dnodeId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_SNODE) != 0) { + goto _OVER; + } if (dropReq.dnodeId <= 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -409,10 +411,6 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_DROP_SNODE) != 0) { - goto _OVER; - } - // check deletable code = mndDropSnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index ae13987d25..1c5d73031f 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1212,8 +1212,9 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { } mInfo("vgId:%d, start to redistribute vgroup to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3); - - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) goto _OVER; + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) { + goto _OVER; + } pVgroup = mndAcquireVgroup(pMnode, req.vgId); if (pVgroup == NULL) goto _OVER; @@ -1506,6 +1507,9 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) { SDbObj *pDb = NULL; mDebug("vgId:%d, start to split", vgId); + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_SPLIT_VGROUP) != 0) { + goto _OVER; + } pVgroup = mndAcquireVgroup(pMnode, vgId); if (pVgroup == NULL) goto _OVER; @@ -1513,8 +1517,6 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) { pDb = mndAcquireDb(pMnode, pVgroup->dbName); if (pDb == NULL) goto _OVER; - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_SPLIT_VGROUP) != 0) goto _OVER; - code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -1655,8 +1657,9 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) { } mInfo("start to balance vgroup"); - - if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_BALANCE_VGROUP) != 0) goto _OVER; + if (mndCheckOperAuth(pMnode, pReq->info.conn.user, MND_OPER_BALANCE_VGROUP) != 0) { + goto _OVER; + } while (1) { SDnodeObj *pDnode = NULL; From 4fb79dd0c3cbad70a1c58e45669caf4c9f5d930d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 25 Jun 2022 09:01:16 +0800 Subject: [PATCH 81/81] fix: compile errors --- source/dnode/mnode/impl/src/mndMain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index ae549d8678..f76dd31614 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -557,6 +557,8 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { } else { terrno = TSDB_CODE_APP_NOT_READY; } + + return -1; } static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {